midnight.js icon indicating copy to clipboard operation
midnight.js copied to clipboard

Add destroy or reset method

Open HugoHeneault opened this issue 9 years ago • 7 comments

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. :)

HugoHeneault avatar Apr 20 '15 15:04 HugoHeneault

Yes please!

yayromina avatar Jun 23 '15 21:06 yayromina

Anyone have any success adding a destroy method?

gjhead avatar Aug 07 '16 19:08 gjhead

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:

benjamenjohnsondev avatar Nov 13 '17 17:11 benjamenjohnsondev

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

HugoHeneault avatar Nov 13 '17 17:11 HugoHeneault

@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.

RobertoGonzalez avatar Nov 14 '17 00:11 RobertoGonzalez

+1

jordan26 avatar Oct 19 '18 15:10 jordan26

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.

jackfowler avatar Jun 13 '19 06:06 jackfowler