scrollIt.js icon indicating copy to clipboard operation
scrollIt.js copied to clipboard

Multiple clicking the same link bug

Open yankopetrov opened this issue 9 years ago • 1 comments

When you click on the same data-scroll-nav a lot of times and try to scroll the page after that, the script scroll to data-scroll-index exact the same times of clicks count.

This create bad glitch effect.

I am using Mac with Firefox 47.0

yankopetrov avatar Jul 08 '16 08:07 yankopetrov

The bug happen, because you do not disable click on the same data-scroll-nav. When i click 10 times, it take 10xsettings.scrollTime.

You can update your doScroll method to disabled animation if target and current data-scroll-nav are the same.

var doScroll = function (e) {
    var target = $(e.target).closest("[data-scroll-nav]").attr('data-scroll-nav') ||
    $(e.target).closest("[data-scroll-goto]").attr('data-scroll-goto');

    var current = $('[data-scroll-nav].active').attr('data-scroll-nav');
    if (target === current) {
        return;
    }

    navigate(parseInt(target));
};

yankopetrov avatar Jul 08 '16 09:07 yankopetrov