Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Feature was originally introduced (as far as I can tell): #284413: Smooth scroll to top of page with AJAX page loading
Just looking at making a view option that allows it to be skipped, particularly in the case of something like http://drupal.org/project/views_load_more
For reference, javascript code that is triggering this behavior is found: http://drupalcode.org/project/views.git/blob/refs/heads/6.x-3.x:/js/ajax...
Comment | File | Size | Author |
---|---|---|---|
#2 | views_scroll-top-optional-6x-1447332-2.patch | 10.33 KB | wjaspers |
Comments
Comment #1
wjaspers CreditAttribution: wjaspers commentedFound and modified all the code i think is necessary to accomplish this. Patch OTW.
Comment #2
wjaspers CreditAttribution: wjaspers commentedHere's a patch. This should cover all necessities, and falls back to the default scrolling behavior if the option hasn't been used before. Will not tag for Backport to 7.x until it has been reviewed.
Comment #3
wjaspers CreditAttribution: wjaspers commentedComment #4
hachreak CreditAttribution: hachreak commented+1.
Also I need to resolve this "bug"... XD
Comment #5
jcisio CreditAttribution: jcisio commentedJust a note that in D7 this behavior is already optional as it can be removed using hook_views_ajax_data_alter() to unset the scroll command (which was introduced in #1233334: Scroll to the top of a view after pager page load).
Comment #6
hachreak CreditAttribution: hachreak commentedCan we port this functionality for D6? :)
Comment #7
dawehnerAre you sure it make sense to set this as definition for display plugins. Isn't it enough to have a setting?
In general the point of jcisio is also strong.
Comment #8
wjaspers CreditAttribution: wjaspers commented@dawehner,
My original patch set that definition so the default value would continue to "scroll to top".
If this patch were rolled-in, it prevents existing views definitions from getting goofed up.
Comment #9
Manuel Garcia CreditAttribution: Manuel Garcia commentedJust for people looking to solve this right away:
Will remove the scroll to top behaviour for all views_load_more pager enabled views.
Comment #10
AdamGerthel CreditAttribution: AdamGerthel commented@Manuel just tried you solution (in template.php though) and it didn't work for me. I only have this issue in iOS (mobile safari) though
Edit: Solved. We were running the following script in behaviors (causing it to get triggered on all ajax requests):
Comment #11
wjaspers CreditAttribution: wjaspers commented@AdamGerthel,
@Manuel's solution shouldn't be placed in your template.php. It should exist in your own module for the site.
Comment #12
funature CreditAttribution: funature commentedpatch of #9 used, but still scroll to top.
Comment #13
jcisio CreditAttribution: jcisio commented#9 is for D7. The only patch to test is #2, but it's NW because of #7.
Comment #14
wjaspers CreditAttribution: wjaspers commentedI set that so older views aren't inadvertently affected by this change.
By making the display plugin default "will_scroll_top" TRUE, they maintain their original behavior.
Comment #15
krisrobinson CreditAttribution: krisrobinson commentedApplied patch from #2 to views 6.x-3.0 (2012-Jan-04) and it worked fine, new setting available in views to enable/disable scroll to top. No errors so far, works good with views_load_more.
Comment #16
MustangGB CreditAttribution: MustangGB commented