AntoineW/luge

Disabling plugins

Closed this issue · 5 comments

blzzz commented

When Luge is used within another framework like Nextjs, which handles routing and page preloading, I don't want it to have any influence on history management. In this situation it would be helpful if plugins like transition could be deactivated.

The transition plugin adds a listener to route changes. Even if no data-lg-page attributes are set, this is disturbing once the user wants to navigate backwards (or a window.history.back() is triggered) because with Luge this results in a reload (even if {transition: {reload: false}}) is set:

window.location = this.url

At the moment my workaround is an "eternal" pageOut event which never ends in calling done() – pretty problematic but it works :)

// hook into luge's lifecycle to prevent a hard reload when navigating backwards
function onPageOut(done: any) {
    console.log('ETERNAL PAGE OUT...') // prevents luge's hard reload as done() never gets called
}
luge.lifecycle.add('pageOut', onPageOut)

What about an excluded section in the settings?

{
  excluded: ["transition"] 
}

Hello @blzzz,
Thanks for your suggestion!

It's already possible to disable plugins (https://luge.cool/docs/browser-detection/#disable) but Transition was not considered as a "plugin" so far, and I also noticed a bug in the plugins' disabled setting.

I made an update that fixes that and add the setting to the Transition as well. Could you give it a try?

You have to replace the dist folder in the node_modules/@waaark/luge folder by the one in the zip.
luge-0.6.3-beta.zip

Then you can disable transition like that:

luge.settings({
  transition: {
    disabled: true
  }
})

(The update should also fixes the other bug you reported with the cursor trails.)

blzzz commented

Hey @AntoineW ,

Thanks for your quick reply and your effort!
I just tested your updated version and as you promised, both things are fixed now. Perfect!

Thanks a lot for your support.

Hey @AntoineW,

I'm working together with Balz - also many thanks for your quick reply and effort from me, we really appreciate that!

@blzzz @CrispinMartens thank you for using luge 🙏

Version 0.6.3-beta fixes that issue.