From 84c871dc9e9050d1973ec43fa4f528bc69b60920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=BB=99?= <2271007263A@gmail.com> Date: Sat, 17 Feb 2024 21:53:17 +0800 Subject: [PATCH 1/2] es5... --- .../Compatibility/Scroller/Scroller.js | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Gadgets/Compatibility/Scroller/Scroller.js b/src/Gadgets/Compatibility/Scroller/Scroller.js index 8241aa6..e391688 100644 --- a/src/Gadgets/Compatibility/Scroller/Scroller.js +++ b/src/Gadgets/Compatibility/Scroller/Scroller.js @@ -18,26 +18,24 @@ /* */ "use strict"; -function Scroller(element){ +function Scroller(element) { function wheelHandler(e) { if (e.deltaY && !e.deltaX) { - e.preventDefault() - requestAnimationFrame(() => { - element.scrollBy(e.deltaY, 0) - }) + e.preventDefault(); + requestAnimationFrame(function () { + element.scrollBy(e.deltaY, 0); + }); } } - - element.addEventListener('wheel', wheelHandler) - element.style.scrollSnapType = 'none' - return () => { - element.removeEventListener('wheel', wheelHandler) - element.style.scrollSnapType = '' - } + element.addEventListener('wheel', wheelHandler); + element.style.scrollSnapType = 'none'; + return function () { + element.removeEventListener('wheel', wheelHandler); + element.style.scrollSnapType = ''; + }; } - -const scroller_containers = document.getElementsByClassName('scroller-container') -for (let index = 0; index < scroller_containers.length; index++) { - const element = scroller_containers[index]; - Scroller(element) +var scroller_containers = document.getElementsByClassName('scroller-container'); +for (var index = 0; index < scroller_containers.length; index++) { + var element = scroller_containers[index]; + Scroller(element); } \ No newline at end of file From 007c16c565a965d72dac53d041470c968c184504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=BB=99?= <2271007263A@gmail.com> Date: Sat, 17 Feb 2024 21:55:14 +0800 Subject: [PATCH 2/2] fix css --- src/Gadgets/Compatibility/Scroller/Scroller.css | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/Gadgets/Compatibility/Scroller/Scroller.css diff --git a/src/Gadgets/Compatibility/Scroller/Scroller.css b/src/Gadgets/Compatibility/Scroller/Scroller.css new file mode 100644 index 0000000..3e78866 --- /dev/null +++ b/src/Gadgets/Compatibility/Scroller/Scroller.css @@ -0,0 +1 @@ +.scroller-item {scroll-behavior: smooth;} \ No newline at end of file