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.
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();
}
Comment | File | Size | Author |
---|---|---|---|
#2 | clientside_validation-scroll-loop-fix-2279399-2.patch | 2.09 KB | kevinsar |
Comments
Comment #1
attiks CreditAttribution: attiks commentedThanks 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
Comment #2
kevinsar CreditAttribution: kevinsar commentedHere is the patch attiks, thanks for pointing me in the direction on how to contribute a patch.
Thanks!
Comment #3
Jelle_SFixed in latest dev