@pushword/js-helper 0.0.100 → 0.0.102
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 +16 -6
package/package.json
CHANGED
package/src/ScrollEnhancer.js
CHANGED
|
@@ -27,9 +27,14 @@ 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.scrollBy(0, evt.deltaY / 2)
|
|
36
|
+
}
|
|
37
|
+
//element.classList.toggle('scroll-smooth')
|
|
33
38
|
})
|
|
34
39
|
return this
|
|
35
40
|
}
|
|
@@ -105,13 +110,13 @@ class ScrollXEnhancer {
|
|
|
105
110
|
arrowRight = '<div class="scroll-right relative left-[calc(100vw-62px)] -mt-[44px] top-1/3 z-20 h-[44px] w-[44px] cursor-pointer select-none rounded-full border border-gray-200 bg-white pt-[3px] text-center text-3xl leading-none text-gray-500 hover:text-gray-700" onclick="scrollX(this)">›</div>',
|
|
106
111
|
arrowLeft = '<div class="scroll-left relative left-[22px] top-1/3 z-20 h-[44px] w-[44px] cursor-pointer select-none rounded-full border border-gray-200 bg-white pt-[3px] text-center text-3xl leading-none text-gray-500 hover:text-gray-700" onclick="scrollX(this)">‹</div>',
|
|
107
112
|
) {
|
|
108
|
-
this.arrowLeft = arrowLeft
|
|
109
|
-
this.arrowRight = arrowRight
|
|
110
113
|
window.scrollLeft = this.scrollLeft
|
|
111
114
|
window.scrollX = this.scrollX
|
|
112
115
|
window.manageScrollXControllerVisibility = this.manageScrollXControllerVisibility
|
|
113
116
|
|
|
114
117
|
document.querySelectorAll(selector).forEach((element) => {
|
|
118
|
+
this.arrowLeft = element.dataset.arrowleft ?? arrowLeft
|
|
119
|
+
this.arrowRight = element.dataset.arrowright ?? arrowRight
|
|
115
120
|
element.classList.remove(selector)
|
|
116
121
|
this.enhanceScrollX(element)
|
|
117
122
|
this.mouseSliderX(element)
|
|
@@ -127,9 +132,14 @@ class ScrollXEnhancer {
|
|
|
127
132
|
evt.preventDefault()
|
|
128
133
|
if (evt.target.closest('.enhance-scroll-y')) return
|
|
129
134
|
if (window.isScrolling === true) return
|
|
130
|
-
element.classList.toggle('scroll-smooth')
|
|
135
|
+
//element.classList.toggle('scroll-smooth')
|
|
136
|
+
const before = element.scrollLeft
|
|
131
137
|
element.scrollLeft += evt.deltaY
|
|
132
|
-
element.
|
|
138
|
+
const after = element.scrollLeft
|
|
139
|
+
if (before === after) {
|
|
140
|
+
window.scrollBy(0, evt.deltaY / 2)
|
|
141
|
+
}
|
|
142
|
+
//element.classList.toggle('scroll-smooth')
|
|
133
143
|
})
|
|
134
144
|
}
|
|
135
145
|
|