Aerolab / midnight.js

Switch your nav's design on the fly
http://aerolab.github.io/midnight.js/
Other
3.67k stars 380 forks source link

Add destroy or reset method #32

Open HugoHeneault opened 9 years ago

HugoHeneault commented 9 years ago

Hello,

Thanks for your great plugin! I'd like to have a method to reset all the midnight's stuff :

    $('.nav').midnight('destroy');

could be great. :)

yayromina commented 9 years ago

Yes please!

gjhead commented 8 years ago

Anyone have any success adding a destroy method?

benjamenjohnsondev commented 6 years ago

I know it's over two years since this was requested... but this is 100% needed.

I have a logo I want to midnightjs - but only when scroll position reaches a certain point gonna have to hack this functionality in myself :-1:

HugoHeneault commented 6 years ago

If you hack it by yourself, don't forget to let a comment here saying what you did. Or better, open a PR :)

RobertoGonzalez commented 6 years ago

@benjamenhogben @HugoHeneault I'd be happy to accept a PR with this feature. I'm guessing the destroy() method only needs to clean up all the bindings (mostly the requestAnimationFrame and resize ones) and roll back the markup changes.

jordan26 commented 6 years ago

+1

jackfowler commented 5 years ago

I was looking for a destroy method because I needed to reinit on ajax page change. While it isn't a destroy method, the refresh method did the trick for me, which you can access by doing the following. $('.header').midnight('instance').refresh(); Thought it might be helpful for someone! Credit to @tkatchenko for figuring this out.