theia-sticky-sidebar icon indicating copy to clipboard operation
theia-sticky-sidebar copied to clipboard

Add setIntervall for scrolling

Open derSteffen opened this issue 4 years ago • 1 comments

Hello, a very nice script but in the development tool I get a notice that the scroll-function fired too much.

No I want to include a setIntervall for the scrolling, for example

var scrollnow;
			$(window).scroll(function(event){
				scrollnow = true;
			});
			
			setInterval(function() {
				if (scrollnow) {
					thefunction();
					scrollnow = false;
				}
			}, 250);

here

$(document).on('scroll.' + options.namespace, function (options, $that) {
                    return function (evt) {
                        var success = tryInit(options, $that);

                        if (success) {
                            $(this).unbind(evt);
                        }
                    };
                }(options, $that));

and here

                $(document).on('scroll.' + o.options.namespace, function (o) {
                    return function () {
                        o.onScroll(o);
                    };
                }(o));

But my try was not successfull.

Please, can somebody help me?

Thanks

derSteffen avatar Oct 20 '21 05:10 derSteffen

This might be fixable using window.requestAnimationFrame, which should improve performance especially on slower PCs. I've made a pull request here if you want to check it out, it enables requestAnimationFrame by default: https://github.com/WeCodePixels/theia-sticky-sidebar/pull/78

liviucmg avatar Apr 06 '25 10:04 liviucmg