@yoursurprise/slider 0.0.21 → 0.0.22
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/dist/Components/Controls/NextButton.d.ts +8 -0
- package/dist/Components/Controls/PreviousButton.d.ts +8 -0
- package/dist/Hooks/UseSider.test.d.ts +1 -0
- package/dist/Hooks/UseSlider.d.ts +22 -0
- package/dist/index.css +6 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +90 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Components/Controls/Button.scss +42 -0
- package/src/Components/Controls/NextButton.tsx +28 -0
- package/src/Components/Controls/PreviousButton.tsx +28 -0
- package/src/Hooks/UseSider.test.ts +123 -0
- package/src/Hooks/UseSlider.ts +84 -0
- package/src/Slider.scss +0 -39
- package/src/Slider.tsx +44 -94
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum Visibility {
|
|
2
|
+
FULL = 0,
|
|
3
|
+
PARTIAL = 1,
|
|
4
|
+
NONE = 2
|
|
5
|
+
}
|
|
6
|
+
export declare enum NavigationDirection {
|
|
7
|
+
PREV = 0,
|
|
8
|
+
NEXT = 1
|
|
9
|
+
}
|
|
10
|
+
interface UseSlider {
|
|
11
|
+
getLeftPositionToScrollTo: (direction: NavigationDirection, slideOffsetLeft: number, wrapperOffsetLeft: number, wrapperWidth: number, slideWidth: number) => number;
|
|
12
|
+
getVisibilityByIntersectionRatio: (intersectionRatio: number) => Visibility;
|
|
13
|
+
getFirstVisibleSlideIndex: () => number;
|
|
14
|
+
getLastVisibleSlideIndex: () => number;
|
|
15
|
+
addVisibleSlide: (index: number) => void;
|
|
16
|
+
addPartiallyVisibleSlide: (index: number) => void;
|
|
17
|
+
sortSlides: () => void;
|
|
18
|
+
removeVisibleSlide: (index: number) => void;
|
|
19
|
+
removePartiallyVisibleSlide: (index: number) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const useSlider: () => UseSlider;
|
|
22
|
+
export {};
|
package/dist/index.css
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
.slider {
|
|
2
|
-
position: relative;
|
|
3
|
-
}
|
|
4
1
|
.slider__button {
|
|
5
2
|
position: absolute;
|
|
6
3
|
top: 0;
|
|
@@ -19,6 +16,9 @@
|
|
|
19
16
|
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, 0.1);
|
|
20
17
|
transition: box-shadow 0.2s ease-in-out;
|
|
21
18
|
}
|
|
19
|
+
.slider__button__icon {
|
|
20
|
+
fill: #554c44;
|
|
21
|
+
}
|
|
22
22
|
.slider__button:hover {
|
|
23
23
|
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, 0.2);
|
|
24
24
|
}
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
.slider__button--prev {
|
|
37
37
|
left: 5px;
|
|
38
38
|
}
|
|
39
|
+
.slider {
|
|
40
|
+
position: relative;
|
|
41
|
+
}
|
|
39
42
|
.slider__wrapper {
|
|
40
43
|
overscroll-behavior-x: contain;
|
|
41
44
|
-ms-overflow-style: none;
|
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Slider.scss"],"names":[],"mappings":"AAAA;EACE,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["Button.scss","Slider.scss"],"names":[],"mappings":"AAAA;EACE,kBAAkB;EAClB,MAAM;EACN,SAAS;EACT,YAAY;EACZ,WAAW;EACX,cAAc;EACd,kBAAkB;EAClB,uBAAuB;EACvB,mBAAmB;EACnB,uBAAuB;EACvB,eAAe;EACf,aAAa;EACb,YAAY;EACZ,aAAa;EACb,iDAAiD;EACjD,uCAAuC;AACzC;AACA;EACE,aAAa;AACf;AACA;EACE,iDAAiD;AACnD;AACA;EACE;IACE,aAAa;EACf;AACF;AACA;EACE,aAAa;AACf;AACA;EACE,UAAU;AACZ;AACA;EACE,SAAS;AACX;ACrCA;EACE,kBAAkB;AACpB;AACA;EACE,8BAA8B;EAC9B,wBAAwB;EACxB,qBAAqB;EACrB,aAAa;EACb,mBAAmB;EACnB,gBAAgB;EAChB,6BAA6B;AAC/B;AACA;EACE,aAAa;AACf;AACA;EACE;IACE,yBAAyB;EAC3B;AACF;AACA;EACE,uBAAuB;AACzB;AACA;EACE,YAAY;AACd;AACA;EACE,gBAAgB;EAChB,iBAAiB;AACnB;AACA;EACE,wBAAwB;AAC1B","file":"index.css","sourcesContent":[".slider__button {\n position: absolute;\n top: 0;\n bottom: 0;\n height: 48px;\n width: 48px;\n margin: auto 0;\n border-radius: 50%;\n background-color: white;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n display: none;\n border: none;\n outline: none;\n box-shadow: inset 0 0 0 1px rgba(32, 32, 32, 0.1);\n transition: box-shadow 0.2s ease-in-out;\n}\n.slider__button__icon {\n fill: #554c44;\n}\n.slider__button:hover {\n box-shadow: inset 0 0 0 1px rgba(32, 32, 32, 0.2);\n}\n@media (hover: hover) {\n .slider__button {\n display: flex;\n }\n}\n.slider__button--hidden {\n display: none;\n}\n.slider__button--next {\n right: 5px;\n}\n.slider__button--prev {\n left: 5px;\n}",".slider {\n position: relative;\n}\n.slider__wrapper {\n overscroll-behavior-x: contain;\n -ms-overflow-style: none;\n scrollbar-width: none;\n display: flex;\n flex-direction: row;\n overflow-x: auto;\n scroll-snap-type: x proximity;\n}\n.slider__wrapper::-webkit-scrollbar {\n display: none;\n}\n@media (hover: hover) {\n .slider__wrapper {\n scroll-snap-type: initial;\n }\n}\n.slider__wrapper:not(.is-dragging) {\n scroll-behavior: smooth;\n}\n.slider__wrapper.is-scrollable {\n cursor: move;\n}\n.slider__wrapper.is-dragging {\n cursor: grabbing;\n user-select: none;\n}\n.slider__wrapper__slide {\n scroll-snap-align: start;\n}"]}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef, useState, useEffect, useCallback, Children } from 'react';
|
|
3
3
|
|
|
4
4
|
var classnamesExports = {};
|
|
@@ -66,22 +66,82 @@ var classnames = {
|
|
|
66
66
|
|
|
67
67
|
var classNames = classnamesExports;
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const NextButton = ({ onClick, isHidden }) => {
|
|
70
|
+
return (jsx("button", { "aria-label": "Next slide", type: "button", onClick: onClick, "aria-hidden": isHidden, className: classNames([
|
|
71
|
+
'slider__button',
|
|
72
|
+
'slider__button--next',
|
|
73
|
+
{ 'slider__button--hidden': isHidden },
|
|
74
|
+
]), children: jsx("svg", { className: "slider__button__icon", xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 256 256", children: jsx("path", { d: "M96,216a8.5,8.5,0,0,1-5.7-2.3,8.1,8.1,0,0,1,0-11.4L164.7,128,90.3,53.7a8.1,8.1,0,0,1,11.4-11.4l80,80a8.1,8.1,0,0,1,0,11.4l-80,80A8.5,8.5,0,0,1,96,216Z" }) }) }));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const PreviousButton = ({ onClick, isHidden }) => {
|
|
78
|
+
return (jsx("button", { "aria-label": "Previous slide", type: "button", onClick: onClick, "aria-hidden": isHidden, className: classNames([
|
|
79
|
+
'slider__button',
|
|
80
|
+
'slider__button--prev',
|
|
81
|
+
{ 'slider__button--hidden': isHidden },
|
|
82
|
+
]), children: jsx("svg", { className: "slider__button__icon", xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 256 256", children: jsx("path", { d: "M160,216a8.5,8.5,0,0,1-5.7-2.3l-80-80a8.1,8.1,0,0,1,0-11.4l80-80a8.1,8.1,0,0,1,11.4,11.4L91.3,128l74.4,74.3a8.1,8.1,0,0,1,0,11.4A8.5,8.5,0,0,1,160,216Z" }) }) }));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var Visibility;
|
|
86
|
+
(function (Visibility) {
|
|
87
|
+
Visibility[Visibility["FULL"] = 0] = "FULL";
|
|
88
|
+
Visibility[Visibility["PARTIAL"] = 1] = "PARTIAL";
|
|
89
|
+
Visibility[Visibility["NONE"] = 2] = "NONE";
|
|
90
|
+
})(Visibility || (Visibility = {}));
|
|
75
91
|
var NavigationDirection;
|
|
76
92
|
(function (NavigationDirection) {
|
|
77
93
|
NavigationDirection[NavigationDirection["PREV"] = 0] = "PREV";
|
|
78
94
|
NavigationDirection[NavigationDirection["NEXT"] = 1] = "NEXT";
|
|
79
95
|
})(NavigationDirection || (NavigationDirection = {}));
|
|
96
|
+
const useSlider = () => {
|
|
97
|
+
const visibleSlideIndices = useRef([]);
|
|
98
|
+
const partiallyVisibleSlideIndices = useRef([]);
|
|
99
|
+
const getFirstVisibleSlideIndex = () => visibleSlideIndices.current[0] ?? partiallyVisibleSlideIndices.current[0] ?? -1;
|
|
100
|
+
const getLastVisibleSlideIndex = () => visibleSlideIndices.current[visibleSlideIndices.current.length - 1]
|
|
101
|
+
?? partiallyVisibleSlideIndices.current[partiallyVisibleSlideIndices.current.length - 1] ?? -1;
|
|
102
|
+
const addVisibleSlide = (index) => visibleSlideIndices.current.push(index);
|
|
103
|
+
const addPartiallyVisibleSlide = (index) => partiallyVisibleSlideIndices.current.push(index);
|
|
104
|
+
const removePartiallyVisibleSlide = (index) => partiallyVisibleSlideIndices.current = partiallyVisibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
105
|
+
const removeVisibleSlide = (index) => visibleSlideIndices.current = visibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
106
|
+
const sortSlides = () => {
|
|
107
|
+
visibleSlideIndices.current = [...new Set(visibleSlideIndices.current)].sort((a, b) => a - b);
|
|
108
|
+
partiallyVisibleSlideIndices.current = [...new Set(partiallyVisibleSlideIndices.current)].sort((a, b) => a - b);
|
|
109
|
+
};
|
|
110
|
+
const getLeftPositionToScrollTo = (direction, slideOffsetLeft, wrapperOffsetLeft, wrapperWidth, slideWidth) => {
|
|
111
|
+
let scrollLeft = 0;
|
|
112
|
+
if (direction === NavigationDirection.PREV) {
|
|
113
|
+
scrollLeft = slideOffsetLeft - wrapperOffsetLeft - wrapperWidth + slideWidth;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
scrollLeft = slideOffsetLeft - wrapperOffsetLeft;
|
|
117
|
+
}
|
|
118
|
+
return scrollLeft;
|
|
119
|
+
};
|
|
120
|
+
const getVisibilityByIntersectionRatio = (intersectionRatio) => {
|
|
121
|
+
if (intersectionRatio >= 0.9) {
|
|
122
|
+
return Visibility.FULL;
|
|
123
|
+
}
|
|
124
|
+
if (intersectionRatio >= 0.5) {
|
|
125
|
+
return Visibility.PARTIAL;
|
|
126
|
+
}
|
|
127
|
+
return Visibility.NONE;
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
addVisibleSlide,
|
|
131
|
+
addPartiallyVisibleSlide,
|
|
132
|
+
removePartiallyVisibleSlide,
|
|
133
|
+
removeVisibleSlide,
|
|
134
|
+
sortSlides,
|
|
135
|
+
getFirstVisibleSlideIndex,
|
|
136
|
+
getLastVisibleSlideIndex,
|
|
137
|
+
getLeftPositionToScrollTo,
|
|
138
|
+
getVisibilityByIntersectionRatio,
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
80
142
|
const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
81
143
|
const slides = useRef([]);
|
|
82
144
|
const wrapper = useRef(null);
|
|
83
|
-
const visibleSlideIndices = useRef([]);
|
|
84
|
-
const partiallyVisibleSlideIndices = useRef([]);
|
|
85
145
|
const [nextArrowVisible, setNextArrowVisible] = useState(false);
|
|
86
146
|
const [prevArrowVisible, setPrevArrowVisible] = useState(false);
|
|
87
147
|
const [isScrollable, setIsScrollable] = useState(false);
|
|
@@ -91,8 +151,7 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
91
151
|
clientX: 0,
|
|
92
152
|
scrollX: 0,
|
|
93
153
|
});
|
|
94
|
-
const
|
|
95
|
-
const arrowNextRef = useRef(null);
|
|
154
|
+
const { getLeftPositionToScrollTo, getVisibilityByIntersectionRatio, addVisibleSlide, addPartiallyVisibleSlide, getLastVisibleSlideIndex, sortSlides, getFirstVisibleSlideIndex, removeVisibleSlide, removePartiallyVisibleSlide, } = useSlider();
|
|
96
155
|
useEffect(() => {
|
|
97
156
|
const currentWrapper = wrapper.current;
|
|
98
157
|
if (!currentWrapper) {
|
|
@@ -126,9 +185,7 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
126
185
|
}
|
|
127
186
|
setIsBlockingClicks(false);
|
|
128
187
|
};
|
|
129
|
-
const mouseUpHandler = () =>
|
|
130
|
-
setIsDragging(false);
|
|
131
|
-
};
|
|
188
|
+
const mouseUpHandler = () => setIsDragging(false);
|
|
132
189
|
const mouseDownHandler = (event) => {
|
|
133
190
|
setMousePosition({
|
|
134
191
|
...mousePosition,
|
|
@@ -149,26 +206,14 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
149
206
|
const addSlide = (node, index) => {
|
|
150
207
|
slides.current[index] = {
|
|
151
208
|
element: node,
|
|
152
|
-
visibility:
|
|
209
|
+
visibility: Visibility.NONE,
|
|
153
210
|
};
|
|
154
211
|
};
|
|
155
|
-
const getFirstVisibleSlideIndex = () => visibleSlideIndices.current[0] ?? partiallyVisibleSlideIndices.current[0] ?? -1;
|
|
156
|
-
const getLastVisibleSlideIndex = () => visibleSlideIndices.current[visibleSlideIndices.current.length - 1]
|
|
157
|
-
?? partiallyVisibleSlideIndices.current[partiallyVisibleSlideIndices.current.length - 1] ?? -1;
|
|
158
212
|
const setControlsVisibility = useCallback(() => {
|
|
159
213
|
const lastSlideFullyVisible = getLastVisibleSlideIndex() + 1 === slides.current.length;
|
|
160
214
|
setPrevArrowVisible(getFirstVisibleSlideIndex() > 0 && isScrollable);
|
|
161
215
|
setNextArrowVisible(isScrollable && lastSlideFullyVisible === false);
|
|
162
|
-
}, [isScrollable]);
|
|
163
|
-
const getVisibilityByIntersectionRatio = (intersectionRatio) => {
|
|
164
|
-
if (intersectionRatio >= 0.9) {
|
|
165
|
-
return Visbility.FULL;
|
|
166
|
-
}
|
|
167
|
-
if (intersectionRatio >= 0.5) {
|
|
168
|
-
return Visbility.PARTIAL;
|
|
169
|
-
}
|
|
170
|
-
return Visbility.NONE;
|
|
171
|
-
};
|
|
216
|
+
}, [getFirstVisibleSlideIndex, getLastVisibleSlideIndex, isScrollable]);
|
|
172
217
|
useEffect(() => {
|
|
173
218
|
if (!wrapper.current) {
|
|
174
219
|
return () => { };
|
|
@@ -177,21 +222,11 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
177
222
|
entries.forEach((entry) => {
|
|
178
223
|
const target = entry.target;
|
|
179
224
|
const index = Number(target.dataset.slideIndex);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
else {
|
|
184
|
-
visibleSlideIndices.current = visibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
185
|
-
}
|
|
186
|
-
if (getVisibilityByIntersectionRatio(entry.intersectionRatio) === Visbility.PARTIAL) {
|
|
187
|
-
partiallyVisibleSlideIndices.current.push(index);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
partiallyVisibleSlideIndices.current = partiallyVisibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
191
|
-
}
|
|
225
|
+
const visibility = getVisibilityByIntersectionRatio(entry.intersectionRatio);
|
|
226
|
+
visibility === Visibility.FULL ? addVisibleSlide(index) : removeVisibleSlide(index);
|
|
227
|
+
visibility === Visibility.PARTIAL ? addPartiallyVisibleSlide(index) : removePartiallyVisibleSlide(index);
|
|
192
228
|
});
|
|
193
|
-
|
|
194
|
-
partiallyVisibleSlideIndices.current = [...new Set(partiallyVisibleSlideIndices.current)].sort((a, b) => a - b);
|
|
229
|
+
sortSlides();
|
|
195
230
|
if (hideNavigationButtons === false) {
|
|
196
231
|
setControlsVisibility();
|
|
197
232
|
}
|
|
@@ -202,23 +237,27 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
202
237
|
});
|
|
203
238
|
slides.current.forEach(({ element }) => intersectionObserver.observe(element));
|
|
204
239
|
return () => intersectionObserver.disconnect();
|
|
205
|
-
}, [
|
|
240
|
+
}, [
|
|
241
|
+
wrapper,
|
|
242
|
+
setControlsVisibility,
|
|
243
|
+
hideNavigationButtons,
|
|
244
|
+
sortSlides,
|
|
245
|
+
addVisibleSlide,
|
|
246
|
+
removeVisibleSlide,
|
|
247
|
+
addPartiallyVisibleSlide,
|
|
248
|
+
removePartiallyVisibleSlide,
|
|
249
|
+
getVisibilityByIntersectionRatio,
|
|
250
|
+
]);
|
|
206
251
|
const navigate = (direction) => {
|
|
207
252
|
if (!wrapper.current) {
|
|
208
253
|
return;
|
|
209
254
|
}
|
|
210
255
|
const targetSlideIndex = direction === NavigationDirection.PREV ? getFirstVisibleSlideIndex() - 1 : getLastVisibleSlideIndex() + 1;
|
|
211
256
|
const targetSlide = slides.current[targetSlideIndex];
|
|
212
|
-
let scrollLeft = 0;
|
|
213
257
|
if (!targetSlide) {
|
|
214
258
|
return;
|
|
215
259
|
}
|
|
216
|
-
|
|
217
|
-
scrollLeft = targetSlide.element.offsetLeft - wrapper.current.offsetLeft - wrapper.current.clientWidth + targetSlide.element.clientWidth;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
scrollLeft = targetSlide.element.offsetLeft - wrapper.current.offsetLeft;
|
|
221
|
-
}
|
|
260
|
+
const scrollLeft = getLeftPositionToScrollTo(direction, targetSlide.element.offsetLeft, wrapper.current.offsetLeft, wrapper.current.clientWidth, targetSlide.element.clientWidth);
|
|
222
261
|
wrapper.current.scrollTo({ behavior: 'smooth', left: scrollLeft, top: 0 });
|
|
223
262
|
};
|
|
224
263
|
return (jsxs("div", { className: "slider", children: [jsx("div", { role: "list", ref: wrapper, onMouseDown: mouseDownHandler, onMouseMove: mouseMoveHandler, onMouseUp: mouseUpHandler, onClickCapture: blockChildClickHandler, className: classNames('slider__wrapper', {
|
|
@@ -226,15 +265,7 @@ const Slider = ({ children, hideNavigationButtons = false }) => {
|
|
|
226
265
|
'is-dragging': isDragging,
|
|
227
266
|
}), children: Children.map(children, (child, index) => (jsx("div", { className: "slider__wrapper__slide", role: "listitem", "data-slide-index": index, ref: (node) => { if (node) {
|
|
228
267
|
addSlide(node, index);
|
|
229
|
-
} }, children: child }, index))) }), hideNavigationButtons === false && (
|
|
230
|
-
'slider__button',
|
|
231
|
-
'slider__button--prev',
|
|
232
|
-
{ 'slider__button--hidden': prevArrowVisible === false },
|
|
233
|
-
]), children: jsx("svg", { fill: "#554c44", xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 256 256", children: jsx("path", { d: "M160,216a8.5,8.5,0,0,1-5.7-2.3l-80-80a8.1,8.1,0,0,1,0-11.4l80-80a8.1,8.1,0,0,1,11.4,11.4L91.3,128l74.4,74.3a8.1,8.1,0,0,1,0,11.4A8.5,8.5,0,0,1,160,216Z" }) }) })), hideNavigationButtons === false && (jsx("button", { "aria-label": "Next slide", type: "button", onClick: () => navigate(NavigationDirection.NEXT), ref: arrowNextRef, "aria-hidden": nextArrowVisible === false, className: classNames([
|
|
234
|
-
'slider__button',
|
|
235
|
-
'slider__button--next',
|
|
236
|
-
{ 'slider__button--hidden': nextArrowVisible === false },
|
|
237
|
-
]), children: jsx("svg", { fill: "#554c44", xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 256 256", children: jsx("path", { d: "M96,216a8.5,8.5,0,0,1-5.7-2.3,8.1,8.1,0,0,1,0-11.4L164.7,128,90.3,53.7a8.1,8.1,0,0,1,11.4-11.4l80,80a8.1,8.1,0,0,1,0,11.4l-80,80A8.5,8.5,0,0,1,96,216Z" }) }) }))] }));
|
|
268
|
+
} }, children: child }, index))) }), hideNavigationButtons === false && (jsxs(Fragment, { children: [jsx(PreviousButton, { onClick: () => navigate(NavigationDirection.PREV), isHidden: prevArrowVisible === false }), jsx(NextButton, { onClick: () => navigate(NavigationDirection.NEXT), isHidden: nextArrowVisible === false })] }))] }));
|
|
238
269
|
};
|
|
239
270
|
|
|
240
271
|
export { Slider };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../node_modules/classnames/index.js","../src/Slider.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\tvar nativeCodeString = '[native code]';\n\n\tfunction classNames() {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg)) {\n\t\t\t\tif (arg.length) {\n\t\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\t\tif (inner) {\n\t\t\t\t\t\tclasses.push(inner);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\t\t\tclasses.push(arg.toString());\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n",null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;AAKA;AACA;AACA,CAAA,CAAC,YAAY;AAEb;AACA,EAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAEhC;EACC,SAAS,UAAU,GAAG;AACvB,GAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,GAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,IAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,IAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,IAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;IACG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,EAAE;AACrD,KAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAClC,KAAI,IAAI,GAAG,CAAC,MAAM,EAAE;MACf,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;MACxC,IAAI,KAAK,EAAE;AAChB,OAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;OACpB;MACD;AACL,KAAI,MAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;KAChC,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,eAAe,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,EACC,qBAAqB,KAAK,KAAK,KAC7BA,GAAA,CAAA,QAAA,EAAA,EAAA,YAAA,EACe,YAAY,EACvB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,EACjD,GAAG,EAAE,YAAY,EAAA,aAAA,EACJ,gBAAgB,KAAK,KAAK,EACvC,SAAS,EAAE,UAAU,CAAC;oBAClB,gBAAgB;oBAChB,sBAAsB;AACtB,oBAAA,EAAE,wBAAwB,EAAE,gBAAgB,KAAK,KAAK,EAAE;AAC3D,iBAAA,CAAC,EAEF,QAAA,EAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAC,SAAS,EAAC,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,aAAa,EAAA,QAAA,EAC/FA,cAAM,CAAC,EAAC,wJAAwJ,EAAA,CAAE,EAChK,CAAA,EAAA,CACD,CACZ,CAAA,EAAA,CACC,EACR;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/classnames/index.js","../src/Components/Controls/NextButton.tsx","../src/Components/Controls/PreviousButton.tsx","../src/Hooks/UseSlider.ts","../src/Slider.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\tvar nativeCodeString = '[native code]';\n\n\tfunction classNames() {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg)) {\n\t\t\t\tif (arg.length) {\n\t\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\t\tif (inner) {\n\t\t\t\t\t\tclasses.push(inner);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\t\t\tclasses.push(arg.toString());\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n",null,null,null,null],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;;;AAKA;AACA;AACA,CAAA,CAAC,YAAY;AAEb;AACA,EAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAEhC;EACC,SAAS,UAAU,GAAG;AACvB,GAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,GAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,IAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,IAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,IAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;IACG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,EAAE;AACrD,KAAI,OAAO,C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+
bottom: 0;
|
|
5
|
+
height: 48px;
|
|
6
|
+
width: 48px;
|
|
7
|
+
margin: auto 0;
|
|
8
|
+
border-radius: 50%;
|
|
9
|
+
background-color: white;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
display: none;
|
|
14
|
+
border: none;
|
|
15
|
+
outline: none;
|
|
16
|
+
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, .1);
|
|
17
|
+
transition: box-shadow .2s ease-in-out;
|
|
18
|
+
|
|
19
|
+
&__icon {
|
|
20
|
+
fill: #554c44;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, .2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (hover: hover) {
|
|
28
|
+
display: flex;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--hidden {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&--next {
|
|
36
|
+
right: 5px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&--prev {
|
|
40
|
+
left: 5px;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './Button.scss';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
isHidden: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const NextButton: React.FC<Props> = ({ onClick, isHidden }) => {
|
|
11
|
+
return (
|
|
12
|
+
<button
|
|
13
|
+
aria-label="Next slide"
|
|
14
|
+
type="button"
|
|
15
|
+
onClick={onClick}
|
|
16
|
+
aria-hidden={isHidden}
|
|
17
|
+
className={classNames([
|
|
18
|
+
'slider__button',
|
|
19
|
+
'slider__button--next',
|
|
20
|
+
{ 'slider__button--hidden': isHidden },
|
|
21
|
+
])}
|
|
22
|
+
>
|
|
23
|
+
<svg className="slider__button__icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 256 256">
|
|
24
|
+
<path d="M96,216a8.5,8.5,0,0,1-5.7-2.3,8.1,8.1,0,0,1,0-11.4L164.7,128,90.3,53.7a8.1,8.1,0,0,1,11.4-11.4l80,80a8.1,8.1,0,0,1,0,11.4l-80,80A8.5,8.5,0,0,1,96,216Z"/>
|
|
25
|
+
</svg>
|
|
26
|
+
</button>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './Button.scss';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
isHidden: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const PreviousButton: React.FC<Props> = ({ onClick, isHidden }) => {
|
|
11
|
+
return (
|
|
12
|
+
<button
|
|
13
|
+
aria-label="Previous slide"
|
|
14
|
+
type="button"
|
|
15
|
+
onClick={onClick}
|
|
16
|
+
aria-hidden={isHidden}
|
|
17
|
+
className={classNames([
|
|
18
|
+
'slider__button',
|
|
19
|
+
'slider__button--prev',
|
|
20
|
+
{ 'slider__button--hidden': isHidden },
|
|
21
|
+
])}
|
|
22
|
+
>
|
|
23
|
+
<svg className="slider__button__icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 256 256">
|
|
24
|
+
<path d="M160,216a8.5,8.5,0,0,1-5.7-2.3l-80-80a8.1,8.1,0,0,1,0-11.4l80-80a8.1,8.1,0,0,1,11.4,11.4L91.3,128l74.4,74.3a8.1,8.1,0,0,1,0,11.4A8.5,8.5,0,0,1,160,216Z"/>
|
|
25
|
+
</svg>
|
|
26
|
+
</button>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { NavigationDirection, useSlider, Visibility } from './UseSlider';
|
|
2
|
+
import { renderHook } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
describe('UseSlider', () => {
|
|
5
|
+
describe('keeps track of slides', () => {
|
|
6
|
+
it('gets the first fully visible slide', () => {
|
|
7
|
+
const { result } = renderHook(() => useSlider());
|
|
8
|
+
|
|
9
|
+
result.current.addPartiallyVisibleSlide(1);
|
|
10
|
+
result.current.addVisibleSlide(2);
|
|
11
|
+
result.current.addVisibleSlide(3);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
expect(result.current.getFirstVisibleSlideIndex()).toBe(2);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('gets the last fully visible slide', () => {
|
|
18
|
+
const { result } = renderHook(() => useSlider());
|
|
19
|
+
|
|
20
|
+
result.current.addVisibleSlide(1);
|
|
21
|
+
result.current.addVisibleSlide(2);
|
|
22
|
+
result.current.addPartiallyVisibleSlide(3);
|
|
23
|
+
|
|
24
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(2);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
it('gets the first partially visible slide when no slide is fully visible', () => {
|
|
29
|
+
const { result } = renderHook(() => useSlider());
|
|
30
|
+
|
|
31
|
+
result.current.addPartiallyVisibleSlide(1);
|
|
32
|
+
result.current.addPartiallyVisibleSlide(2);
|
|
33
|
+
|
|
34
|
+
expect(result.current.getFirstVisibleSlideIndex()).toBe(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('gets the last visible slide when no slide is fully visible', () => {
|
|
38
|
+
const { result } = renderHook(() => useSlider());
|
|
39
|
+
|
|
40
|
+
result.current.addPartiallyVisibleSlide(1);
|
|
41
|
+
result.current.addPartiallyVisibleSlide(2);
|
|
42
|
+
|
|
43
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(2);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
it('falls back when first slide is non-existant', () => {
|
|
48
|
+
const { result } = renderHook(() => useSlider());
|
|
49
|
+
expect(result.current.getFirstVisibleSlideIndex()).toBe(-1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
it('falls back when last slide is non-existant', () => {
|
|
54
|
+
const { result } = renderHook(() => useSlider());
|
|
55
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(-1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('sorts the fully visible slides by index', () => {
|
|
59
|
+
const { result } = renderHook(() => useSlider());
|
|
60
|
+
|
|
61
|
+
result.current.addVisibleSlide(3);
|
|
62
|
+
result.current.addVisibleSlide(2);
|
|
63
|
+
result.current.addVisibleSlide(1);
|
|
64
|
+
|
|
65
|
+
expect(result.current.getFirstVisibleSlideIndex()).toBe(3);
|
|
66
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(1);
|
|
67
|
+
|
|
68
|
+
result.current.sortSlides();
|
|
69
|
+
|
|
70
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(3);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('sorts the partially fully visible slides by index', () => {
|
|
74
|
+
const { result } = renderHook(() => useSlider());
|
|
75
|
+
|
|
76
|
+
result.current.addPartiallyVisibleSlide(3);
|
|
77
|
+
result.current.addPartiallyVisibleSlide(2);
|
|
78
|
+
result.current.addPartiallyVisibleSlide(1);
|
|
79
|
+
|
|
80
|
+
expect(result.current.getFirstVisibleSlideIndex()).toBe(3);
|
|
81
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(1);
|
|
82
|
+
|
|
83
|
+
result.current.sortSlides();
|
|
84
|
+
|
|
85
|
+
expect(result.current.getLastVisibleSlideIndex()).toBe(3);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('calculations', () => {
|
|
90
|
+
|
|
91
|
+
it('calculates the scrollLeft position (next)', () => {
|
|
92
|
+
const { result } = renderHook(() => useSlider());
|
|
93
|
+
|
|
94
|
+
expect(result.current.getLeftPositionToScrollTo(NavigationDirection.NEXT, 200, 50, 1250, 325)).toBe(150);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('calculates the scrollLeft position (prev)', () => {
|
|
98
|
+
const { result } = renderHook(() => useSlider());
|
|
99
|
+
|
|
100
|
+
expect(result.current.getLeftPositionToScrollTo(NavigationDirection.PREV, 875, 50, 1250, 325)).toBe(-100);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('calculates the visibility of a slide', () => {
|
|
104
|
+
const { result } = renderHook(() => useSlider());
|
|
105
|
+
|
|
106
|
+
[
|
|
107
|
+
[0.0, Visibility.NONE],
|
|
108
|
+
[0.1, Visibility.NONE],
|
|
109
|
+
[0.2, Visibility.NONE],
|
|
110
|
+
[0.3, Visibility.NONE],
|
|
111
|
+
[0.4, Visibility.NONE],
|
|
112
|
+
[0.5, Visibility.PARTIAL],
|
|
113
|
+
[0.6, Visibility.PARTIAL],
|
|
114
|
+
[0.7, Visibility.PARTIAL],
|
|
115
|
+
[0.8, Visibility.PARTIAL],
|
|
116
|
+
[0.9, Visibility.FULL],
|
|
117
|
+
[1.0, Visibility.FULL],
|
|
118
|
+
].forEach(([ratio, expectation]) => {
|
|
119
|
+
expect(result.current.getVisibilityByIntersectionRatio(ratio)).toBe(expectation);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export enum Visibility {
|
|
4
|
+
FULL,
|
|
5
|
+
PARTIAL,
|
|
6
|
+
NONE,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum NavigationDirection {
|
|
10
|
+
PREV,
|
|
11
|
+
NEXT,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface UseSlider {
|
|
15
|
+
getLeftPositionToScrollTo: (direction: NavigationDirection, slideOffsetLeft: number, wrapperOffsetLeft: number, wrapperWidth: number, slideWidth: number) => number;
|
|
16
|
+
getVisibilityByIntersectionRatio: (intersectionRatio: number) => Visibility;
|
|
17
|
+
getFirstVisibleSlideIndex: () => number;
|
|
18
|
+
getLastVisibleSlideIndex: () => number;
|
|
19
|
+
addVisibleSlide: (index: number) => void;
|
|
20
|
+
addPartiallyVisibleSlide: (index: number) => void;
|
|
21
|
+
sortSlides: () => void;
|
|
22
|
+
removeVisibleSlide: (index: number) => void;
|
|
23
|
+
removePartiallyVisibleSlide: (index: number) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const useSlider = (): UseSlider => {
|
|
27
|
+
const visibleSlideIndices = useRef<number[]>([]);
|
|
28
|
+
const partiallyVisibleSlideIndices = useRef<number[]>([]);
|
|
29
|
+
|
|
30
|
+
const getFirstVisibleSlideIndex = (): number => visibleSlideIndices.current[0] ?? partiallyVisibleSlideIndices.current[0] ?? -1;
|
|
31
|
+
|
|
32
|
+
const getLastVisibleSlideIndex = (): number => visibleSlideIndices.current[visibleSlideIndices.current.length - 1]
|
|
33
|
+
?? partiallyVisibleSlideIndices.current[partiallyVisibleSlideIndices.current.length - 1] ?? -1;
|
|
34
|
+
|
|
35
|
+
const addVisibleSlide = (index: number) => visibleSlideIndices.current.push(index);
|
|
36
|
+
|
|
37
|
+
const addPartiallyVisibleSlide = (index: number) => partiallyVisibleSlideIndices.current.push(index);
|
|
38
|
+
|
|
39
|
+
const removePartiallyVisibleSlide = (index: number) => partiallyVisibleSlideIndices.current = partiallyVisibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
40
|
+
|
|
41
|
+
const removeVisibleSlide = (index: number) => visibleSlideIndices.current = visibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
42
|
+
|
|
43
|
+
const sortSlides = () => {
|
|
44
|
+
// Make sure there are no duplicate visible slides, then sort to retain proper order
|
|
45
|
+
visibleSlideIndices.current = [...new Set(visibleSlideIndices.current)].sort((a, b) => a - b);
|
|
46
|
+
partiallyVisibleSlideIndices.current = [...new Set(partiallyVisibleSlideIndices.current)].sort((a, b) => a - b);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getLeftPositionToScrollTo = (direction: NavigationDirection, slideOffsetLeft: number, wrapperOffsetLeft: number, wrapperWidth: number, slideWidth: number) => {
|
|
50
|
+
let scrollLeft = 0;
|
|
51
|
+
|
|
52
|
+
if (direction === NavigationDirection.PREV) {
|
|
53
|
+
scrollLeft = slideOffsetLeft - wrapperOffsetLeft - wrapperWidth + slideWidth;
|
|
54
|
+
} else {
|
|
55
|
+
scrollLeft = slideOffsetLeft - wrapperOffsetLeft;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return scrollLeft;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getVisibilityByIntersectionRatio = (intersectionRatio: number) => {
|
|
62
|
+
if (intersectionRatio >= 0.9) {
|
|
63
|
+
return Visibility.FULL;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (intersectionRatio >= 0.5) {
|
|
67
|
+
return Visibility.PARTIAL;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Visibility.NONE;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
addVisibleSlide,
|
|
75
|
+
addPartiallyVisibleSlide,
|
|
76
|
+
removePartiallyVisibleSlide,
|
|
77
|
+
removeVisibleSlide,
|
|
78
|
+
sortSlides,
|
|
79
|
+
getFirstVisibleSlideIndex,
|
|
80
|
+
getLastVisibleSlideIndex,
|
|
81
|
+
getLeftPositionToScrollTo,
|
|
82
|
+
getVisibilityByIntersectionRatio,
|
|
83
|
+
};
|
|
84
|
+
};
|
package/src/Slider.scss
CHANGED
|
@@ -1,45 +1,6 @@
|
|
|
1
1
|
.slider {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
|
-
&__button {
|
|
5
|
-
position: absolute;
|
|
6
|
-
top: 0;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
height: 48px;
|
|
9
|
-
width: 48px;
|
|
10
|
-
margin: auto 0;
|
|
11
|
-
border-radius: 50%;
|
|
12
|
-
background-color: white;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
display: none;
|
|
17
|
-
border: none;
|
|
18
|
-
outline: none;
|
|
19
|
-
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, .1);
|
|
20
|
-
transition: box-shadow .2s ease-in-out;
|
|
21
|
-
|
|
22
|
-
&:hover {
|
|
23
|
-
box-shadow: inset 0 0 0 1px rgba(32, 32, 32, .2);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media (hover: hover) {
|
|
27
|
-
display: flex;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&--hidden {
|
|
31
|
-
display: none;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&--next {
|
|
35
|
-
right: 5px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&--prev {
|
|
39
|
-
left: 5px;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
4
|
&__wrapper {
|
|
44
5
|
|
|
45
6
|
// Prevent the browser from going back in history when there is no scroll area left
|
package/src/Slider.tsx
CHANGED
|
@@ -2,22 +2,14 @@ import classNames from 'classnames';
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import type { MouseEvent as ReactMouseEvent, PropsWithChildren } from 'react';
|
|
4
4
|
import { useRef, useEffect, Children, useCallback, useState } from 'react';
|
|
5
|
+
import { NextButton } from './Components/Controls/NextButton';
|
|
6
|
+
import { PreviousButton } from './Components/Controls/PreviousButton';
|
|
7
|
+
import { NavigationDirection, useSlider, Visibility } from './Hooks/UseSlider';
|
|
5
8
|
import './Slider.scss';
|
|
6
9
|
|
|
7
|
-
enum Visbility {
|
|
8
|
-
FULL,
|
|
9
|
-
PARTIAL,
|
|
10
|
-
NONE,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
enum NavigationDirection {
|
|
14
|
-
PREV,
|
|
15
|
-
NEXT,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
interface SlideVisibilityEntry {
|
|
19
11
|
element: HTMLDivElement;
|
|
20
|
-
visibility:
|
|
12
|
+
visibility: Visibility;
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
interface Settings {
|
|
@@ -28,8 +20,6 @@ interface Settings {
|
|
|
28
20
|
export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNavigationButtons = false }) => {
|
|
29
21
|
const slides = useRef<SlideVisibilityEntry[]>([]);
|
|
30
22
|
const wrapper = useRef<HTMLDivElement>(null);
|
|
31
|
-
const visibleSlideIndices = useRef<number[]>([]);
|
|
32
|
-
const partiallyVisibleSlideIndices = useRef<number[]>([]);
|
|
33
23
|
|
|
34
24
|
const [nextArrowVisible, setNextArrowVisible] = useState<boolean>(false);
|
|
35
25
|
const [prevArrowVisible, setPrevArrowVisible] = useState<boolean>(false);
|
|
@@ -42,8 +32,17 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
42
32
|
scrollX: 0,
|
|
43
33
|
});
|
|
44
34
|
|
|
45
|
-
const
|
|
46
|
-
|
|
35
|
+
const {
|
|
36
|
+
getLeftPositionToScrollTo,
|
|
37
|
+
getVisibilityByIntersectionRatio,
|
|
38
|
+
addVisibleSlide,
|
|
39
|
+
addPartiallyVisibleSlide,
|
|
40
|
+
getLastVisibleSlideIndex,
|
|
41
|
+
sortSlides,
|
|
42
|
+
getFirstVisibleSlideIndex,
|
|
43
|
+
removeVisibleSlide,
|
|
44
|
+
removePartiallyVisibleSlide,
|
|
45
|
+
} = useSlider();
|
|
47
46
|
|
|
48
47
|
useEffect(() => {
|
|
49
48
|
const currentWrapper = wrapper.current;
|
|
@@ -90,9 +89,7 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
90
89
|
setIsBlockingClicks(false);
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
const mouseUpHandler = () =>
|
|
94
|
-
setIsDragging(false);
|
|
95
|
-
};
|
|
92
|
+
const mouseUpHandler = () => setIsDragging(false);
|
|
96
93
|
|
|
97
94
|
const mouseDownHandler = (event: ReactMouseEvent<HTMLDivElement>) => {
|
|
98
95
|
setMousePosition({
|
|
@@ -119,33 +116,16 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
119
116
|
const addSlide = (node: HTMLDivElement, index: number) => {
|
|
120
117
|
slides.current[index] = {
|
|
121
118
|
element: node,
|
|
122
|
-
visibility:
|
|
119
|
+
visibility: Visibility.NONE,
|
|
123
120
|
};
|
|
124
121
|
};
|
|
125
122
|
|
|
126
|
-
const getFirstVisibleSlideIndex = (): number => visibleSlideIndices.current[0] ?? partiallyVisibleSlideIndices.current[0] ?? -1;
|
|
127
|
-
|
|
128
|
-
const getLastVisibleSlideIndex = (): number => visibleSlideIndices.current[visibleSlideIndices.current.length - 1]
|
|
129
|
-
?? partiallyVisibleSlideIndices.current[partiallyVisibleSlideIndices.current.length - 1] ?? -1;
|
|
130
|
-
|
|
131
123
|
const setControlsVisibility = useCallback(() => {
|
|
132
124
|
const lastSlideFullyVisible = getLastVisibleSlideIndex() + 1 === slides.current.length;
|
|
133
125
|
|
|
134
126
|
setPrevArrowVisible(getFirstVisibleSlideIndex() > 0 && isScrollable);
|
|
135
127
|
setNextArrowVisible(isScrollable && lastSlideFullyVisible === false);
|
|
136
|
-
}, [isScrollable]);
|
|
137
|
-
|
|
138
|
-
const getVisibilityByIntersectionRatio = (intersectionRatio: number) => {
|
|
139
|
-
if (intersectionRatio >= 0.9) {
|
|
140
|
-
return Visbility.FULL;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (intersectionRatio >= 0.5) {
|
|
144
|
-
return Visbility.PARTIAL;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return Visbility.NONE;
|
|
148
|
-
};
|
|
128
|
+
}, [getFirstVisibleSlideIndex, getLastVisibleSlideIndex, isScrollable]);
|
|
149
129
|
|
|
150
130
|
useEffect(() => {
|
|
151
131
|
if (!wrapper.current) {
|
|
@@ -156,23 +136,13 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
156
136
|
entries.forEach((entry: IntersectionObserverEntry) => {
|
|
157
137
|
const target = entry.target as HTMLDivElement;
|
|
158
138
|
const index = Number(target.dataset.slideIndex);
|
|
139
|
+
const visibility = getVisibilityByIntersectionRatio(entry.intersectionRatio);
|
|
159
140
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
} else {
|
|
163
|
-
visibleSlideIndices.current = visibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (getVisibilityByIntersectionRatio(entry.intersectionRatio) === Visbility.PARTIAL) {
|
|
167
|
-
partiallyVisibleSlideIndices.current.push(index);
|
|
168
|
-
} else {
|
|
169
|
-
partiallyVisibleSlideIndices.current = partiallyVisibleSlideIndices.current.filter((slideIndex) => slideIndex !== index);
|
|
170
|
-
}
|
|
141
|
+
visibility === Visibility.FULL ? addVisibleSlide(index) : removeVisibleSlide(index);
|
|
142
|
+
visibility === Visibility.PARTIAL ? addPartiallyVisibleSlide(index) : removePartiallyVisibleSlide(index);
|
|
171
143
|
});
|
|
172
144
|
|
|
173
|
-
|
|
174
|
-
visibleSlideIndices.current = [...new Set(visibleSlideIndices.current)].sort((a, b) => a - b);
|
|
175
|
-
partiallyVisibleSlideIndices.current = [...new Set(partiallyVisibleSlideIndices.current)].sort((a, b) => a - b);
|
|
145
|
+
sortSlides();
|
|
176
146
|
|
|
177
147
|
if (hideNavigationButtons === false) {
|
|
178
148
|
setControlsVisibility();
|
|
@@ -187,7 +157,17 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
187
157
|
slides.current.forEach(({ element }) => intersectionObserver.observe(element));
|
|
188
158
|
|
|
189
159
|
return () => intersectionObserver.disconnect();
|
|
190
|
-
}, [
|
|
160
|
+
}, [
|
|
161
|
+
wrapper,
|
|
162
|
+
setControlsVisibility,
|
|
163
|
+
hideNavigationButtons,
|
|
164
|
+
sortSlides,
|
|
165
|
+
addVisibleSlide,
|
|
166
|
+
removeVisibleSlide,
|
|
167
|
+
addPartiallyVisibleSlide,
|
|
168
|
+
removePartiallyVisibleSlide,
|
|
169
|
+
getVisibilityByIntersectionRatio,
|
|
170
|
+
]);
|
|
191
171
|
|
|
192
172
|
const navigate = (direction: NavigationDirection) => {
|
|
193
173
|
if (!wrapper.current) {
|
|
@@ -195,19 +175,19 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
195
175
|
}
|
|
196
176
|
|
|
197
177
|
const targetSlideIndex = direction === NavigationDirection.PREV ? getFirstVisibleSlideIndex() - 1 : getLastVisibleSlideIndex() + 1;
|
|
198
|
-
|
|
199
178
|
const targetSlide = slides.current[targetSlideIndex];
|
|
200
|
-
let scrollLeft = 0;
|
|
201
179
|
|
|
202
180
|
if (!targetSlide) {
|
|
203
181
|
return;
|
|
204
182
|
}
|
|
205
183
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
184
|
+
const scrollLeft = getLeftPositionToScrollTo(
|
|
185
|
+
direction,
|
|
186
|
+
targetSlide.element.offsetLeft,
|
|
187
|
+
wrapper.current.offsetLeft,
|
|
188
|
+
wrapper.current.clientWidth,
|
|
189
|
+
targetSlide.element.clientWidth,
|
|
190
|
+
);
|
|
211
191
|
|
|
212
192
|
wrapper.current.scrollTo({ behavior: 'smooth', left: scrollLeft, top: 0 });
|
|
213
193
|
};
|
|
@@ -231,40 +211,10 @@ export const Slider: React.FC<PropsWithChildren<Settings>> = ({ children, hideNa
|
|
|
231
211
|
))}
|
|
232
212
|
</div>
|
|
233
213
|
{ hideNavigationButtons === false && (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
ref={arrowPrevRef}
|
|
239
|
-
aria-hidden={prevArrowVisible === false}
|
|
240
|
-
className={classNames([
|
|
241
|
-
'slider__button',
|
|
242
|
-
'slider__button--prev',
|
|
243
|
-
{ 'slider__button--hidden': prevArrowVisible === false },
|
|
244
|
-
])}
|
|
245
|
-
>
|
|
246
|
-
<svg fill="#554c44" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 256 256">
|
|
247
|
-
<path d="M160,216a8.5,8.5,0,0,1-5.7-2.3l-80-80a8.1,8.1,0,0,1,0-11.4l80-80a8.1,8.1,0,0,1,11.4,11.4L91.3,128l74.4,74.3a8.1,8.1,0,0,1,0,11.4A8.5,8.5,0,0,1,160,216Z"/>
|
|
248
|
-
</svg>
|
|
249
|
-
</button>
|
|
250
|
-
)}
|
|
251
|
-
{ hideNavigationButtons === false && (
|
|
252
|
-
<button
|
|
253
|
-
aria-label="Next slide"
|
|
254
|
-
type="button"
|
|
255
|
-
onClick={() => navigate(NavigationDirection.NEXT)}
|
|
256
|
-
ref={arrowNextRef}
|
|
257
|
-
aria-hidden={nextArrowVisible === false}
|
|
258
|
-
className={classNames([
|
|
259
|
-
'slider__button',
|
|
260
|
-
'slider__button--next',
|
|
261
|
-
{ 'slider__button--hidden': nextArrowVisible === false },
|
|
262
|
-
])}
|
|
263
|
-
>
|
|
264
|
-
<svg fill="#554c44" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 256 256">
|
|
265
|
-
<path d="M96,216a8.5,8.5,0,0,1-5.7-2.3,8.1,8.1,0,0,1,0-11.4L164.7,128,90.3,53.7a8.1,8.1,0,0,1,11.4-11.4l80,80a8.1,8.1,0,0,1,0,11.4l-80,80A8.5,8.5,0,0,1,96,216Z"/>
|
|
266
|
-
</svg>
|
|
267
|
-
</button>
|
|
214
|
+
<>
|
|
215
|
+
<PreviousButton onClick={() => navigate(NavigationDirection.PREV)} isHidden={prevArrowVisible === false}/>
|
|
216
|
+
<NextButton onClick={() => navigate(NavigationDirection.NEXT)} isHidden={nextArrowVisible === false}/>
|
|
217
|
+
</>
|
|
268
218
|
)}
|
|
269
219
|
</div>
|
|
270
220
|
);
|