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

Files: 
CommentFileSizeAuthor
#2 views_scroll-top-optional-6x-1447332-2.patch10.33 KBwjaspers
Test request sent.
[ View ]

Comments

Found and modified all the code i think is necessary to accomplish this. Patch OTW.

Status:Active» Needs review
StatusFileSize
new10.33 KB
Test request sent.
[ View ]

Here'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.

Assigned:wjaspers» Unassigned

+1.

Also I need to resolve this "bug"... XD

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

Can we port this functionality for D6? :)

Status:Needs review» Needs work

+++ b/includes/plugins.incundefined
@@ -28,6 +28,7 @@ function views_views_plugins() {
+        'will scroll top' => TRUE,

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

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

Just for people looking to solve this right away:

<?php
/**
* Implement hook_views_ajax_data_alter().
*/
function YOURMODULE_views_ajax_data_alter(&$commands, $view) {
 
// Remove scroll to top behaviour from views ajax if using load_more pager.
 
if ($view->display[$view->current_display]->display_options['pager']['type'] == 'load_more') {
    foreach (
$commands as $key => $command) {
      if (
$command['command'] == 'viewsScrollTop') {
        unset(
$commands[$key]);
        break;
      }
    }
  }
}
?>

Will remove the scroll to top behaviour for all views_load_more pager enabled views.

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

  // Hide address bar
  if (navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
    window.scrollTo(0,0.9);
  };

@AdamGerthel,
@Manuel's solution shouldn't be placed in your template.php. It should exist in your own module for the site.

patch of #9 used, but still scroll to top.

#9 is for D7. The only patch to test is #2, but it's NW because of #7.

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

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