dgileadi / zepto-page-transitions

HTML5 Page Transitions similar to JQuery Mobile page transitions, but standalone (13k) and using Zepto.js
167 stars 46 forks source link

keep page position on scroll? #7

Closed webdpro closed 11 years ago

webdpro commented 11 years ago

Hi,

I have made a few changes to your code just because on mobile android transitions just do not work well :) anyhow I have updated it so it uses your ajax load and navigation structure but with no transitions like slide etc.

Anyhow I was wondering if you knew of a way to prevent the page from jumping to the top when you select a link?

For my app it uses a lot of list elements so if there was a way to go to have the list stay in the same spot when going to the next page etc.

Anyhow thanks for any help.

richiesun commented 11 years ago

Which href link are you using? Something like this href="#link"?

webdpro commented 11 years ago

I'm doing it programatically so it's just in my click handler On 5 Feb 2013 17:46, "richiesun" notifications@github.com wrote:

Which href link are you using? Something like this href="#link"?

— Reply to this email directly or view it on GitHubhttps://github.com/dgileadi/zepto-page-transitions/issues/7#issuecomment-13162868.

webdpro commented 11 years ago

I'm doing it programatically so it's just in my click handler On 5 Feb 2013 17:46, "richiesun" notifications@github.com wrote:

Which href link are you using? Something like this href="#link"?

— Reply to this email directly or view it on GitHubhttps://github.com/dgileadi/zepto-page-transitions/issues/7#issuecomment-13162868.

dgileadi commented 11 years ago

Some example code demonstrating the problem would help; I'm not entirely sure what might be going wrong from your description.

On Feb 5, 2013, at 7:19 PM, Michael notifications@github.com wrote:

I'm doing it programatically so it's just in my click handler On 5 Feb 2013 17:46, "richiesun" notifications@github.com wrote:

Which href link are you using? Something like this href="#link"?

— Reply to this email directly or view it on GitHubhttps://github.com/dgileadi/zepto-page-transitions/issues/7#issuecomment-13162868. — Reply to this email directly or view it on GitHub.

Ruffio commented 11 years ago

Actually I think I know what webdpro is talking about. Imagine that you have two pages, where the first one is longer than one screen height. If you transition to page two from 'below one screen height' at page one and back again (to page one), then you will be at the top of page one and not at the position where you initially started the transition. I don't think it's a bug, more like a feature. If it's decided to implement this feature, the developer should have the opportunity to enable/disable this by using a setting. A 'simple' way to implement this would be to remember the position from the page you are transitioning from and when you transition to a new page then look up this offset value in a table. If there is a value for the page you are transitioning to, then the page should be offset by this value and the value in the table should be removed. In some way one could argue that this feature has a little to do with the offsetting implemented by fix of issue # 18 (Jumping transition on new page if page two is shorter than page one). As mentioned above, this is a (new) feature and not a bug.

Kindly regards Ruffio

dgileadi commented 11 years ago

Thanks for the comment, now it makes sense. Added support for remembering the previous page's position when navigating backwards via the browser's back button or javascript like history.back().

@Ruffio I tested it by changing your example site to use history.back() on your back button's onclick instead of transition('to'). Thanks for the site and for all your help with polishing this code.