Problem/Motivation

On AJAX rebinds, the scrollTop animation gets fired multiple times, so it won't let you scroll down until all of the animation calls have finished.

Proposed resolution

I could not change the amount of times the animation function was called without effecting the module's functionality so I just added a conditional surrounding the animation call to see if the first animate call was fired, else don't call the animation function anymore.

Remaining tasks

Review needed or a better way to fix the problem is needed, this is more of a bandage.

// Added to line 209
var hasAnimated = false;
$("#"+f).submit(function(){
	hasAnimated = false;
});
// Changed block at line 368 to the following:

if(!hasAnimated){
	hasAnimated=true;
	if (self.forms[f].general.scrollTo) {
		var x;
		if ($("#" + errorel).length) {
			$("#" + errorel).show();
			x = $("#" + errorel).offset().top - $("#" + errorel).height() - 100; // provides buffer in viewport
		}else {
			x = $(validator.errorList[0].element).offset().top - $(validator.errorList[0].element).height() - 100;
		}
		$('html, body').animate({scrollTop: x}, self.forms[f].general.scrollSpeed, function(){
			hasAnimated = true;
		});
		$('.wysiwyg-toggle-wrapper a').each(function() {
			$(this).click();
			$(this).click();
		});
	}
}else{
	$('html, body').stop();
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

attiks’s picture

Thanks for the clear report, I've noticed it before as well.

Can you create a patch so we can easily test this, more info can be found at https://drupal.org/node/1319154

kevinsar’s picture

Here is the patch attiks, thanks for pointing me in the direction on how to contribute a patch.

Thanks!

Jelle_S’s picture

Status: Needs review » Fixed

Fixed in latest dev

  • Jelle_S committed bef66b2 on 7.x-1.x
    Issue #2279399 by kevinsar: Fixed AJAX Rebinding results in looping...

  • Jelle_S committed bef66b2 on 7.x-2.x
    Issue #2279399 by kevinsar: Fixed AJAX Rebinding results in looping...

Status: Fixed » Closed (fixed)

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