Prinzhorn / skrollr-menu

skrollr plugin for hash navigation
MIT License
285 stars 143 forks source link

Ensure that popstate event handler is removed when skrollr is destroyed #21

Closed LyleE closed 11 years ago

LyleE commented 11 years ago

Destroying Skrollr with this plugin initialised breaks any internal links in (at least) Chrome on OSX 10.8; any link scrolls to the top instead of the desired anchor.

This pull request: skrollr.addEvent is used instead of adding the event directly to window, which makes sure it gets removed when it should be.

Prinzhorn commented 11 years ago

Thanks. For now this is probably sufficient, it will leave the plugin in an inconsistent state though.

In the future there will be a destroy event emitted by skrollr which the plugins can react to and properly destroy themselves. Because with your fix the click handler is still bound and you end up with another one after each initialization.

LyleE commented 11 years ago

Cool, yeah I figured you'd have a plan for something like that. Thanks!