{"id":335,"date":"2022-08-30T14:59:38","date_gmt":"2022-08-30T14:59:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/06\/problem-about-debouncing-collection-of-common-programming-errors\/"},"modified":"2022-08-30T14:59:38","modified_gmt":"2022-08-30T14:59:38","slug":"problem-about-debouncing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-debouncing-collection-of-common-programming-errors\/","title":{"rendered":"problem about debouncing-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b6c3aa270812d9b251fdfcd99bf6efbd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nalexej_d<br \/>\njquery performance scrolling requestanimationframe debouncing<br \/>\nI have written a plugin for my personal homepage, which is supposed to scroll through a series of elements, snapping to each elements offsetTop. I am using requestanimationframe to debounce the scrolling events but sometimes slides are being skipped and I just can&#8217;t figure why. Additionally on Chrome and Safari I have the problem that window.pageYOffset can be smaller than 0 and bigger than document hight because of some kind of easing those browsers are using on mac (with the touchpad) \u2013 how would you handle that?Here is the Code:\/\/ requerstanimationframe for all browsers window.rAF = (function(){return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( callback ){window.setTimeout(callback, 1000 \/ 60);};})();\/\/ main plugin code var Slides = {el: &#8220;.slide&#8221;,arrowUp: $(&#8220;.btn-previous&#8221;),arrowDown: $(&#8220;.btn-next&#8221;),lastSlide: 0,lastY: 0,scrolling: false,scrollSpeed: 500,init: function(){this.$elem = $(thi<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-06 03:09:13. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>alexej_d jquery performance scrolling requestanimationframe debouncing I have written a plugin for my personal homepage, which is supposed to scroll through a series of elements, snapping to each elements offsetTop. I am using requestanimationframe to debounce the scrolling events but sometimes slides are being skipped and I just can&#8217;t figure why. Additionally on Chrome and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-335","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=335"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/335\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}