Problem: if we use infinite scroll - it causes "scroll_to_top" duplication (when it loads new content - it also inserts a second scroll_to_top)
I solved this simply by adding "context" in scroll_to_top.js

CommentFileSizeAuthor
#3 scroll_to_top-1624834.patch993 bytesquotesbro

Comments

quotesbro’s picture

Where exactly did you add "context"? Can you make a patch or share changed scroll_to_top.js?

lanzs’s picture

Changed scroll_to_top.js:

/**
 * Scroll to top behavior
 */
Drupal.behaviors.scroll_to_top = function (context) {
		// append  back to top link top body
		$("body", context).append("<p id='back-top'><a href='#top'><span></span><div id='link'>"+Drupal.t("Back to Top")+"</div></a></p>");
		// hide #back-top first
		$("#back-top", context).hide();
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});

		// scroll body to 0px on click
		$('#back-top a', context).click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		}); 
};
quotesbro’s picture

Title: Scroll top top appears on both sides when infinite scroll enabled » Scroll top top appears on both sides of page when using AJAX
Version: 6.x-2.0-beta1 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new993 bytes

Thank you!
Attaching a patch against 6.x-2.x-dev.

In my case this problem was caused by any AJAX activity on the page (clicking on Vote up/down voting widget, using AJAX in Views, Flag JavaScript toggle).
Also this issue looks similar: http://drupal.org/node/1556608

lanzs’s picture

No problem, good that it helps not just me :)

tarekdj’s picture

Status: Needs review » Fixed

Fix commited to dev release. Thx to all contributors.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.