@pushword/js-helper 0.0.101 → 0.0.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ScrollEnhancer.js +20 -4
package/package.json
CHANGED
package/src/ScrollEnhancer.js
CHANGED
|
@@ -27,9 +27,17 @@ class ScrollYEnhancer {
|
|
|
27
27
|
wheelScroll(element) {
|
|
28
28
|
element.addEventListener('wheel', (evt) => {
|
|
29
29
|
evt.preventDefault()
|
|
30
|
-
element.classList.toggle('scroll-smooth')
|
|
30
|
+
//element.classList.toggle('scroll-smooth')
|
|
31
|
+
const before = element.scrollTop
|
|
31
32
|
element.scrollTop += evt.deltaY
|
|
32
|
-
element.
|
|
33
|
+
const after = element.scrollTop
|
|
34
|
+
if (before === after) {
|
|
35
|
+
window.scrollWithoutDoingNothing++
|
|
36
|
+
if (window.scrollWithoutDoingNothing > 10) window.scrollBy(0, evt.deltaY / 2)
|
|
37
|
+
} else {
|
|
38
|
+
window.scrollWithoutDoingNothing = 0
|
|
39
|
+
}
|
|
40
|
+
//element.classList.toggle('scroll-smooth')
|
|
33
41
|
})
|
|
34
42
|
return this
|
|
35
43
|
}
|
|
@@ -127,9 +135,17 @@ class ScrollXEnhancer {
|
|
|
127
135
|
evt.preventDefault()
|
|
128
136
|
if (evt.target.closest('.enhance-scroll-y')) return
|
|
129
137
|
if (window.isScrolling === true) return
|
|
130
|
-
element.classList.toggle('scroll-smooth')
|
|
138
|
+
//element.classList.toggle('scroll-smooth')
|
|
139
|
+
const before = element.scrollLeft
|
|
131
140
|
element.scrollLeft += evt.deltaY
|
|
132
|
-
element.
|
|
141
|
+
const after = element.scrollLeft
|
|
142
|
+
if (before === after) {
|
|
143
|
+
window.scrollWithoutDoingNothing++
|
|
144
|
+
if (window.scrollWithoutDoingNothing > 10) window.scrollBy(0, evt.deltaY / 2)
|
|
145
|
+
} else {
|
|
146
|
+
window.scrollWithoutDoingNothing = 0
|
|
147
|
+
}
|
|
148
|
+
//element.classList.toggle('scroll-smooth')
|
|
133
149
|
})
|
|
134
150
|
}
|
|
135
151
|
|