MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / isTouchpad

Function isTouchpad

scripts/smoothScroll.js:723–748  ·  view source on GitHub ↗
(deltaY)

Source from the content-addressed store, hash-verified

721 }
722 }
723 function isTouchpad(deltaY) {
724 if (!deltaY) return;
725 if (!deltaBuffer.length) {
726 deltaBuffer = [deltaY, deltaY, deltaY];
727 }
728 deltaY = Math.abs(deltaY);
729 deltaBuffer.push(deltaY);
730 deltaBuffer.shift();
731 let dpiScaledWheelDelta = deltaY > 120 && allDeltasDivisableBy(deltaY); // win64
732 let tp =
733 !allDeltasDivisableBy(120) &&
734 !allDeltasDivisableBy(100) &&
735 !dpiScaledWheelDelta;
736 if (deltaY < 50) tp = true;
737 clearTimeout(deltaBufferTimer);
738 deltaBufferTimer = setTimeout(function () {
739 chrome?.storage?.local?.set?.({
740 deltaBuffer: deltaBuffer,
741 });
742 if (!tp)
743 chrome?.storage?.local?.set?.({
744 lastDiscreetWheel: dateNow(),
745 });
746 }, 1000);
747 return tp;
748 }
749 function isDivisible(n, divisor) {
750 return Math.floor(n / divisor) == n / divisor;
751 }

Callers 1

wheelFunction · 0.85

Calls 1

allDeltasDivisableByFunction · 0.85

Tested by

no test coverage detected