jakiestfu / Snap.js

A Library for creating beautiful mobile shelfs in Javascript (Facebook and Path style side menus)
http://jakiestfu.github.io/Snap.js/
5.99k stars 663 forks source link

Mobile Menu Animations #197

Open 0Neji opened 10 years ago

0Neji commented 10 years ago

Hi,

I'm trying to setup a Wordpress starter theme with an out-of-the-box mobile menu. I'm using SnapJS to create a slide out menu.

It's working fairly well - almost perfectly but I've run in to one issue that I just cannot fix.

You can find the menu in it's current state here: http://sandbox.benpalmer.me/flow/test/

The problem is that if you scroll down the page (in a browser width less than 700px) then hit the menu button, the menu will slide out but the content (in #wrapper) will jump back to the top.

I know precisely why this is happening - the positioning switches to fixed with a top set to 0px.

I've got the following JS setup:

snap.on('open', function() {

    wrapper.css({
        'top': '-' + $('body').scrollTop() + 'px'
    });

});

This almost does what I need but it basically jumps to the top and then scrolls down to this position.

I'm fairly sure in saying that this animation is coming from Snap but I'm really not sure what to remove or alter. Or even if there is a simple way to disabled this from happening?

Any help would be hugely appreciated! Thanks!

0Neji commented 10 years ago

You can ignore this - I fixed it by setting the transitionSpeed to 0.