@v-c/slick 1.0.0 → 1.0.2
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/InnerSlider.js +12 -9
- package/package.json +3 -3
- package/dist/Arrows.cjs +0 -186
- package/dist/Dots.cjs +0 -124
- package/dist/InnerSlider.cjs +0 -917
- package/dist/Slider.cjs +0 -452
- package/dist/Track.cjs +0 -314
- package/dist/default-props.cjs +0 -62
- package/dist/index.cjs +0 -7
- package/dist/initial-state.cjs +0 -36
- package/dist/interface.cjs +0 -1
- package/dist/utils/innerSliderUtils.cjs +0 -602
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_default_props = require("../default-props.cjs");
|
|
3
|
-
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
4
|
-
function getTrackNode(trackRef) {
|
|
5
|
-
if (!trackRef) return null;
|
|
6
|
-
return trackRef.node ?? trackRef;
|
|
7
|
-
}
|
|
8
|
-
function clamp(number, lowerBound, upperBound) {
|
|
9
|
-
return Math.max(lowerBound, Math.min(number, upperBound));
|
|
10
|
-
}
|
|
11
|
-
function safePreventDefault(event) {
|
|
12
|
-
if (!event || typeof event.preventDefault !== "function") return;
|
|
13
|
-
if ("cancelable" in event && event.cancelable === false) return;
|
|
14
|
-
event.preventDefault();
|
|
15
|
-
}
|
|
16
|
-
function getOnDemandLazySlides(spec) {
|
|
17
|
-
const onDemandSlides = [];
|
|
18
|
-
const startIndex = lazyStartIndex(spec);
|
|
19
|
-
const endIndex = lazyEndIndex(spec);
|
|
20
|
-
for (let slideIndex = startIndex; slideIndex < endIndex; slideIndex++) if (!spec.lazyLoadedList.includes(slideIndex)) onDemandSlides.push(slideIndex);
|
|
21
|
-
return onDemandSlides;
|
|
22
|
-
}
|
|
23
|
-
function getRequiredLazySlides(spec) {
|
|
24
|
-
const requiredSlides = [];
|
|
25
|
-
const startIndex = lazyStartIndex(spec);
|
|
26
|
-
const endIndex = lazyEndIndex(spec);
|
|
27
|
-
for (let slideIndex = startIndex; slideIndex < endIndex; slideIndex++) requiredSlides.push(slideIndex);
|
|
28
|
-
return requiredSlides;
|
|
29
|
-
}
|
|
30
|
-
function lazyStartIndex(spec) {
|
|
31
|
-
return spec.currentSlide - lazySlidesOnLeft(spec);
|
|
32
|
-
}
|
|
33
|
-
function lazyEndIndex(spec) {
|
|
34
|
-
return spec.currentSlide + lazySlidesOnRight(spec);
|
|
35
|
-
}
|
|
36
|
-
function lazySlidesOnLeft(spec) {
|
|
37
|
-
return spec.centerMode ? Math.floor(spec.slidesToShow / 2) + (parseInt(spec.centerPadding) > 0 ? 1 : 0) : 0;
|
|
38
|
-
}
|
|
39
|
-
function lazySlidesOnRight(spec) {
|
|
40
|
-
return spec.centerMode ? Math.floor((spec.slidesToShow - 1) / 2) + 1 + (parseInt(spec.centerPadding) > 0 ? 1 : 0) : spec.slidesToShow;
|
|
41
|
-
}
|
|
42
|
-
const getWidth = (elem) => elem && elem.offsetWidth || 0;
|
|
43
|
-
const getHeight = (elem) => elem && elem.offsetHeight || 0;
|
|
44
|
-
function getSwipeDirection(touchObject, verticalSwiping = false) {
|
|
45
|
-
let xDist = 0;
|
|
46
|
-
let yDist = 0;
|
|
47
|
-
let r = 0;
|
|
48
|
-
let swipeAngle = 0;
|
|
49
|
-
xDist = touchObject.startX - touchObject.curX;
|
|
50
|
-
yDist = touchObject.startY - touchObject.curY;
|
|
51
|
-
r = Math.atan2(yDist, xDist);
|
|
52
|
-
swipeAngle = Math.round(r * 180 / Math.PI);
|
|
53
|
-
if (swipeAngle < 0) swipeAngle = 360 - Math.abs(swipeAngle);
|
|
54
|
-
if (swipeAngle <= 45 && swipeAngle >= 0 || swipeAngle <= 360 && swipeAngle >= 315) return "left";
|
|
55
|
-
if (swipeAngle >= 135 && swipeAngle <= 225) return "right";
|
|
56
|
-
if (verticalSwiping === true) if (swipeAngle >= 35 && swipeAngle <= 135) return "up";
|
|
57
|
-
else return "down";
|
|
58
|
-
return "vertical";
|
|
59
|
-
}
|
|
60
|
-
function canGoNext(spec) {
|
|
61
|
-
let canGo = true;
|
|
62
|
-
if (!spec.infinite) {
|
|
63
|
-
if (spec.centerMode && spec.currentSlide >= spec.slideCount - 1) canGo = false;
|
|
64
|
-
else if (spec.slideCount <= spec.slidesToShow || spec.currentSlide >= spec.slideCount - spec.slidesToShow) canGo = false;
|
|
65
|
-
}
|
|
66
|
-
return canGo;
|
|
67
|
-
}
|
|
68
|
-
function extractObject(spec, keys) {
|
|
69
|
-
const newObject = {};
|
|
70
|
-
keys.forEach((key) => newObject[key] = spec[key]);
|
|
71
|
-
return newObject;
|
|
72
|
-
}
|
|
73
|
-
function initializedState(spec) {
|
|
74
|
-
const slideCount = Array.isArray(spec.children) ? spec.children.length : 0;
|
|
75
|
-
const listNode = spec.listRef;
|
|
76
|
-
const listWidth = Math.ceil(getWidth(listNode));
|
|
77
|
-
const trackNode = getTrackNode(spec.trackRef);
|
|
78
|
-
const trackWidth = Math.ceil(getWidth(trackNode));
|
|
79
|
-
let slideWidth = 0;
|
|
80
|
-
if (!spec.vertical) {
|
|
81
|
-
let centerPaddingAdj = spec.centerMode ? parseInt(spec.centerPadding) * 2 : 0;
|
|
82
|
-
if (typeof spec.centerPadding === "string" && spec.centerPadding.slice(-1) === "%") centerPaddingAdj *= listWidth / 100;
|
|
83
|
-
slideWidth = Math.ceil((listWidth - centerPaddingAdj) / spec.slidesToShow);
|
|
84
|
-
} else slideWidth = listWidth;
|
|
85
|
-
const slideHeight = listNode ? getHeight(listNode.querySelector("[data-index=\"0\"]")) : 0;
|
|
86
|
-
const listHeight = slideHeight * spec.slidesToShow;
|
|
87
|
-
let currentSlide = spec.currentSlide === void 0 ? spec.initialSlide : spec.currentSlide;
|
|
88
|
-
if (spec.rtl && spec.currentSlide === void 0) currentSlide = slideCount - 1 - spec.initialSlide;
|
|
89
|
-
let lazyLoadedList = spec.lazyLoadedList || [];
|
|
90
|
-
const slidesToLoad = getOnDemandLazySlides({
|
|
91
|
-
...spec,
|
|
92
|
-
currentSlide,
|
|
93
|
-
lazyLoadedList
|
|
94
|
-
});
|
|
95
|
-
lazyLoadedList = lazyLoadedList.concat(slidesToLoad);
|
|
96
|
-
const state = {
|
|
97
|
-
slideCount,
|
|
98
|
-
slideWidth,
|
|
99
|
-
listWidth,
|
|
100
|
-
trackWidth,
|
|
101
|
-
currentSlide,
|
|
102
|
-
slideHeight,
|
|
103
|
-
listHeight,
|
|
104
|
-
lazyLoadedList
|
|
105
|
-
};
|
|
106
|
-
if (spec.autoplaying === null && spec.autoplay) state.autoplaying = "playing";
|
|
107
|
-
return state;
|
|
108
|
-
}
|
|
109
|
-
function slideHandler(spec) {
|
|
110
|
-
const { waitForAnimate, animating, fade, infinite, index, slideCount, lazyLoad, currentSlide, centerMode, slidesToScroll, slidesToShow, useCSS } = spec;
|
|
111
|
-
let { lazyLoadedList } = spec;
|
|
112
|
-
if (waitForAnimate && animating) return {};
|
|
113
|
-
let animationSlide = index;
|
|
114
|
-
let finalSlide = 0;
|
|
115
|
-
let animationLeft = 0;
|
|
116
|
-
let finalLeft = 0;
|
|
117
|
-
let state = {};
|
|
118
|
-
let nextState = {};
|
|
119
|
-
const targetSlide = infinite ? index : clamp(index, 0, slideCount - 1);
|
|
120
|
-
if (fade) {
|
|
121
|
-
if (!infinite && (index < 0 || index >= slideCount)) return {};
|
|
122
|
-
if (index < 0) animationSlide = index + slideCount;
|
|
123
|
-
else if (index >= slideCount) animationSlide = index - slideCount;
|
|
124
|
-
if (lazyLoad && !lazyLoadedList.includes(animationSlide)) lazyLoadedList = lazyLoadedList.concat(animationSlide);
|
|
125
|
-
state = {
|
|
126
|
-
animating: true,
|
|
127
|
-
currentSlide: animationSlide,
|
|
128
|
-
lazyLoadedList,
|
|
129
|
-
targetSlide: animationSlide
|
|
130
|
-
};
|
|
131
|
-
nextState = {
|
|
132
|
-
animating: false,
|
|
133
|
-
targetSlide: animationSlide
|
|
134
|
-
};
|
|
135
|
-
} else {
|
|
136
|
-
finalSlide = animationSlide;
|
|
137
|
-
if (animationSlide < 0) {
|
|
138
|
-
finalSlide = animationSlide + slideCount;
|
|
139
|
-
if (!infinite) finalSlide = 0;
|
|
140
|
-
else if (slideCount % slidesToScroll !== 0) finalSlide = slideCount - slideCount % slidesToScroll;
|
|
141
|
-
} else if (!canGoNext(spec) && animationSlide > currentSlide) animationSlide = finalSlide = currentSlide;
|
|
142
|
-
else if (centerMode && animationSlide >= slideCount) {
|
|
143
|
-
animationSlide = infinite ? slideCount : slideCount - 1;
|
|
144
|
-
finalSlide = infinite ? 0 : slideCount - 1;
|
|
145
|
-
} else if (animationSlide >= slideCount) {
|
|
146
|
-
finalSlide = animationSlide - slideCount;
|
|
147
|
-
if (!infinite) finalSlide = slideCount - slidesToShow;
|
|
148
|
-
else if (slideCount % slidesToScroll !== 0) finalSlide = 0;
|
|
149
|
-
}
|
|
150
|
-
if (!infinite && animationSlide + slidesToShow >= slideCount) finalSlide = slideCount - slidesToShow;
|
|
151
|
-
animationLeft = getTrackLeft({
|
|
152
|
-
...spec,
|
|
153
|
-
slideIndex: animationSlide
|
|
154
|
-
});
|
|
155
|
-
finalLeft = getTrackLeft({
|
|
156
|
-
...spec,
|
|
157
|
-
slideIndex: finalSlide
|
|
158
|
-
});
|
|
159
|
-
if (!infinite) {
|
|
160
|
-
if (animationLeft === finalLeft) animationSlide = finalSlide;
|
|
161
|
-
animationLeft = finalLeft;
|
|
162
|
-
}
|
|
163
|
-
if (lazyLoad) lazyLoadedList = lazyLoadedList.concat(getOnDemandLazySlides({
|
|
164
|
-
...spec,
|
|
165
|
-
currentSlide: animationSlide
|
|
166
|
-
}));
|
|
167
|
-
if (!useCSS) state = {
|
|
168
|
-
currentSlide: finalSlide,
|
|
169
|
-
trackStyle: getTrackCSS({
|
|
170
|
-
...spec,
|
|
171
|
-
left: finalLeft
|
|
172
|
-
}),
|
|
173
|
-
lazyLoadedList,
|
|
174
|
-
targetSlide
|
|
175
|
-
};
|
|
176
|
-
else {
|
|
177
|
-
state = {
|
|
178
|
-
animating: true,
|
|
179
|
-
currentSlide: finalSlide,
|
|
180
|
-
trackStyle: getTrackAnimateCSS({
|
|
181
|
-
...spec,
|
|
182
|
-
left: animationLeft
|
|
183
|
-
}),
|
|
184
|
-
lazyLoadedList,
|
|
185
|
-
targetSlide
|
|
186
|
-
};
|
|
187
|
-
nextState = {
|
|
188
|
-
animating: false,
|
|
189
|
-
currentSlide: finalSlide,
|
|
190
|
-
trackStyle: getTrackCSS({
|
|
191
|
-
...spec,
|
|
192
|
-
left: finalLeft
|
|
193
|
-
}),
|
|
194
|
-
swipeLeft: null,
|
|
195
|
-
targetSlide
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
state,
|
|
201
|
-
nextState
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function changeSlide(spec, options) {
|
|
205
|
-
let indexOffset = 0;
|
|
206
|
-
let previousInt = 0;
|
|
207
|
-
let slideOffset = 0;
|
|
208
|
-
let unevenOffset = false;
|
|
209
|
-
let targetSlide = 0;
|
|
210
|
-
const { slidesToScroll, slidesToShow, slideCount, currentSlide, targetSlide: previousTargetSlide, lazyLoad, infinite } = spec;
|
|
211
|
-
unevenOffset = slideCount % slidesToScroll !== 0;
|
|
212
|
-
indexOffset = unevenOffset ? 0 : (slideCount - currentSlide) % slidesToScroll;
|
|
213
|
-
if (options.message === "previous") {
|
|
214
|
-
slideOffset = indexOffset === 0 ? slidesToScroll : slidesToShow - indexOffset;
|
|
215
|
-
targetSlide = currentSlide - slideOffset;
|
|
216
|
-
if (lazyLoad && !infinite) {
|
|
217
|
-
previousInt = currentSlide - slideOffset;
|
|
218
|
-
targetSlide = previousInt === -1 ? slideCount - 1 : previousInt;
|
|
219
|
-
}
|
|
220
|
-
if (!infinite) targetSlide = previousTargetSlide - slidesToScroll;
|
|
221
|
-
} else if (options.message === "next") {
|
|
222
|
-
slideOffset = indexOffset === 0 ? slidesToScroll : indexOffset;
|
|
223
|
-
targetSlide = currentSlide + slideOffset;
|
|
224
|
-
if (lazyLoad && !infinite) targetSlide = (currentSlide + slidesToScroll) % slideCount + indexOffset;
|
|
225
|
-
if (!infinite) targetSlide = previousTargetSlide + slidesToScroll;
|
|
226
|
-
} else if (options.message === "dots") targetSlide = options.index * options.slidesToScroll;
|
|
227
|
-
else if (options.message === "children") {
|
|
228
|
-
targetSlide = options.index;
|
|
229
|
-
if (infinite) {
|
|
230
|
-
const direction = siblingDirection({
|
|
231
|
-
...spec,
|
|
232
|
-
targetSlide
|
|
233
|
-
});
|
|
234
|
-
if (targetSlide > options.currentSlide && direction === "left") targetSlide = targetSlide - slideCount;
|
|
235
|
-
else if (targetSlide < options.currentSlide && direction === "right") targetSlide = targetSlide + slideCount;
|
|
236
|
-
}
|
|
237
|
-
} else if (options.message === "index") targetSlide = Number(options.index);
|
|
238
|
-
return targetSlide;
|
|
239
|
-
}
|
|
240
|
-
function keyHandler(e, accessibility, rtl) {
|
|
241
|
-
if (e.target.tagName.match("TEXTAREA|INPUT|SELECT") || !accessibility) return "";
|
|
242
|
-
if (e.keyCode === 37) return rtl ? "next" : "previous";
|
|
243
|
-
if (e.keyCode === 39) return rtl ? "previous" : "next";
|
|
244
|
-
return "";
|
|
245
|
-
}
|
|
246
|
-
function swipeStart(e, swipe, draggable) {
|
|
247
|
-
e.target.tagName === "IMG" && safePreventDefault(e);
|
|
248
|
-
if (!swipe || !draggable && e.type.includes("mouse")) return "";
|
|
249
|
-
return {
|
|
250
|
-
dragging: true,
|
|
251
|
-
touchObject: {
|
|
252
|
-
startX: e.touches ? e.touches[0].pageX : e.clientX,
|
|
253
|
-
startY: e.touches ? e.touches[0].pageY : e.clientY,
|
|
254
|
-
curX: e.touches ? e.touches[0].pageX : e.clientX,
|
|
255
|
-
curY: e.touches ? e.touches[0].pageY : e.clientY
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function swipeMove(e, spec) {
|
|
260
|
-
const { scrolling, animating, vertical, swipeToSlide, verticalSwiping, rtl, currentSlide, edgeFriction, edgeDragged, onEdge, swiped, swiping, slideCount, slidesToScroll, infinite, touchObject, swipeEvent, listHeight, listWidth } = spec;
|
|
261
|
-
if (scrolling) return;
|
|
262
|
-
if (animating) return safePreventDefault(e);
|
|
263
|
-
if (vertical && swipeToSlide && verticalSwiping) safePreventDefault(e);
|
|
264
|
-
let swipeLeft = 0;
|
|
265
|
-
let state = {};
|
|
266
|
-
const curLeft = getTrackLeft(spec);
|
|
267
|
-
touchObject.curX = e.touches ? e.touches[0].pageX : e.clientX;
|
|
268
|
-
touchObject.curY = e.touches ? e.touches[0].pageY : e.clientY;
|
|
269
|
-
touchObject.swipeLength = Math.round(Math.sqrt((touchObject.curX - touchObject.startX) ** 2));
|
|
270
|
-
const verticalSwipeLength = Math.round(Math.sqrt((touchObject.curY - touchObject.startY) ** 2));
|
|
271
|
-
if (!verticalSwiping && !swiping && verticalSwipeLength > 10) return { scrolling: true };
|
|
272
|
-
if (verticalSwiping) touchObject.swipeLength = verticalSwipeLength;
|
|
273
|
-
let positionOffset = (!rtl ? 1 : -1) * (touchObject.curX > touchObject.startX ? 1 : -1);
|
|
274
|
-
if (verticalSwiping) positionOffset = touchObject.curY > touchObject.startY ? 1 : -1;
|
|
275
|
-
const dotCount = Math.ceil(slideCount / slidesToScroll);
|
|
276
|
-
const swipeDirection = getSwipeDirection(spec.touchObject, verticalSwiping);
|
|
277
|
-
let touchSwipeLength = touchObject.swipeLength;
|
|
278
|
-
if (!infinite) {
|
|
279
|
-
if (currentSlide === 0 && (swipeDirection === "right" || swipeDirection === "down") || currentSlide + 1 >= dotCount && (swipeDirection === "left" || swipeDirection === "up") || !canGoNext(spec) && (swipeDirection === "left" || swipeDirection === "up")) {
|
|
280
|
-
touchSwipeLength = touchObject.swipeLength * edgeFriction;
|
|
281
|
-
if (edgeDragged === false && onEdge) {
|
|
282
|
-
onEdge(swipeDirection);
|
|
283
|
-
state.edgeDragged = true;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (!swiped && swipeEvent) {
|
|
288
|
-
swipeEvent(swipeDirection);
|
|
289
|
-
state.swiped = true;
|
|
290
|
-
}
|
|
291
|
-
if (!vertical) if (!rtl) swipeLeft = curLeft + touchSwipeLength * positionOffset;
|
|
292
|
-
else swipeLeft = curLeft - touchSwipeLength * positionOffset;
|
|
293
|
-
else swipeLeft = curLeft + touchSwipeLength * (listHeight / listWidth) * positionOffset;
|
|
294
|
-
if (verticalSwiping) swipeLeft = curLeft + touchSwipeLength * positionOffset;
|
|
295
|
-
state = {
|
|
296
|
-
...state,
|
|
297
|
-
touchObject,
|
|
298
|
-
swipeLeft,
|
|
299
|
-
trackStyle: getTrackCSS({
|
|
300
|
-
...spec,
|
|
301
|
-
left: swipeLeft
|
|
302
|
-
})
|
|
303
|
-
};
|
|
304
|
-
if (Math.abs(touchObject.curX - touchObject.startX) < Math.abs(touchObject.curY - touchObject.startY) * .8) return state;
|
|
305
|
-
if (touchObject.swipeLength > 10) {
|
|
306
|
-
state.swiping = true;
|
|
307
|
-
safePreventDefault(e);
|
|
308
|
-
}
|
|
309
|
-
return state;
|
|
310
|
-
}
|
|
311
|
-
function swipeEnd(e, spec) {
|
|
312
|
-
const { dragging, swipe, touchObject, listWidth, touchThreshold, verticalSwiping, listHeight, swipeToSlide, scrolling, onSwipe, targetSlide, currentSlide, infinite } = spec;
|
|
313
|
-
if (!dragging) {
|
|
314
|
-
if (swipe) safePreventDefault(e);
|
|
315
|
-
return {};
|
|
316
|
-
}
|
|
317
|
-
const minSwipe = verticalSwiping ? listHeight / touchThreshold : listWidth / touchThreshold;
|
|
318
|
-
const swipeDirection = getSwipeDirection(touchObject, verticalSwiping);
|
|
319
|
-
const state = {
|
|
320
|
-
dragging: false,
|
|
321
|
-
edgeDragged: false,
|
|
322
|
-
scrolling: false,
|
|
323
|
-
swiping: false,
|
|
324
|
-
swiped: false,
|
|
325
|
-
swipeLeft: null,
|
|
326
|
-
touchObject: {}
|
|
327
|
-
};
|
|
328
|
-
if (scrolling) return state;
|
|
329
|
-
if (!touchObject.swipeLength) return state;
|
|
330
|
-
if (touchObject.swipeLength > minSwipe) {
|
|
331
|
-
safePreventDefault(e);
|
|
332
|
-
if (onSwipe) onSwipe(swipeDirection);
|
|
333
|
-
let slideCount = 0;
|
|
334
|
-
let newSlide = 0;
|
|
335
|
-
const activeSlide = infinite ? currentSlide : targetSlide;
|
|
336
|
-
switch (swipeDirection) {
|
|
337
|
-
case "left":
|
|
338
|
-
case "up":
|
|
339
|
-
newSlide = activeSlide + getSlideCount(spec);
|
|
340
|
-
slideCount = swipeToSlide ? checkNavigable(spec, newSlide) : newSlide;
|
|
341
|
-
state.currentDirection = 0;
|
|
342
|
-
break;
|
|
343
|
-
case "right":
|
|
344
|
-
case "down":
|
|
345
|
-
newSlide = activeSlide - getSlideCount(spec);
|
|
346
|
-
slideCount = swipeToSlide ? checkNavigable(spec, newSlide) : newSlide;
|
|
347
|
-
state.currentDirection = 1;
|
|
348
|
-
break;
|
|
349
|
-
default: slideCount = activeSlide;
|
|
350
|
-
}
|
|
351
|
-
state.triggerSlideHandler = slideCount;
|
|
352
|
-
} else {
|
|
353
|
-
const currentLeft = getTrackLeft(spec);
|
|
354
|
-
state.trackStyle = getTrackAnimateCSS({
|
|
355
|
-
...spec,
|
|
356
|
-
left: currentLeft
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return state;
|
|
360
|
-
}
|
|
361
|
-
function getNavigableIndexes(spec) {
|
|
362
|
-
const max = spec.infinite ? spec.slideCount * 2 : spec.slideCount;
|
|
363
|
-
let breakpoint = spec.infinite ? spec.slidesToShow * -1 : 0;
|
|
364
|
-
let counter = spec.infinite ? spec.slidesToShow * -1 : 0;
|
|
365
|
-
const indexes = [];
|
|
366
|
-
while (breakpoint < max) {
|
|
367
|
-
indexes.push(breakpoint);
|
|
368
|
-
breakpoint = counter + spec.slidesToScroll;
|
|
369
|
-
counter += Math.min(spec.slidesToScroll, spec.slidesToShow);
|
|
370
|
-
}
|
|
371
|
-
return indexes;
|
|
372
|
-
}
|
|
373
|
-
function checkNavigable(spec, index) {
|
|
374
|
-
const navigables = getNavigableIndexes(spec);
|
|
375
|
-
let prevNavigable = 0;
|
|
376
|
-
if (index > navigables[navigables.length - 1]) index = navigables[navigables.length - 1];
|
|
377
|
-
else for (const n in navigables) {
|
|
378
|
-
if (index < navigables[n]) {
|
|
379
|
-
index = prevNavigable;
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
382
|
-
prevNavigable = navigables[n];
|
|
383
|
-
}
|
|
384
|
-
return index;
|
|
385
|
-
}
|
|
386
|
-
function getSlideCount(spec) {
|
|
387
|
-
const centerOffset = spec.centerMode ? spec.slideWidth * Math.floor(spec.slidesToShow / 2) : 0;
|
|
388
|
-
if (spec.swipeToSlide) {
|
|
389
|
-
let swipedSlide = null;
|
|
390
|
-
const slickList = spec.listRef;
|
|
391
|
-
const slides = slickList.querySelectorAll && slickList.querySelectorAll(".slick-slide") || [];
|
|
392
|
-
Array.from(slides).every((slide) => {
|
|
393
|
-
if (!spec.vertical) {
|
|
394
|
-
if (slide.offsetLeft - centerOffset + getWidth(slide) / 2 > spec.swipeLeft * -1) {
|
|
395
|
-
swipedSlide = slide;
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
} else if (slide.offsetTop + getHeight(slide) / 2 > spec.swipeLeft * -1) {
|
|
399
|
-
swipedSlide = slide;
|
|
400
|
-
return false;
|
|
401
|
-
}
|
|
402
|
-
return true;
|
|
403
|
-
});
|
|
404
|
-
if (!swipedSlide) return 0;
|
|
405
|
-
const currentIndex = spec.rtl === true ? spec.slideCount - spec.currentSlide : spec.currentSlide;
|
|
406
|
-
return Math.abs(swipedSlide.dataset.index - currentIndex) || 1;
|
|
407
|
-
} else return spec.slidesToScroll;
|
|
408
|
-
}
|
|
409
|
-
function checkSpecKeys(spec, keysArray) {
|
|
410
|
-
return keysArray.reduce((value, key) => value && Object.prototype.hasOwnProperty.call(spec, key), true) ? null : console.error("Keys Missing:", spec);
|
|
411
|
-
}
|
|
412
|
-
function getTrackCSS(spec) {
|
|
413
|
-
checkSpecKeys(spec, [
|
|
414
|
-
"left",
|
|
415
|
-
"variableWidth",
|
|
416
|
-
"slideCount",
|
|
417
|
-
"slidesToShow",
|
|
418
|
-
"slideWidth"
|
|
419
|
-
]);
|
|
420
|
-
let trackWidth = 0;
|
|
421
|
-
let trackHeight = 0;
|
|
422
|
-
if (!spec.vertical) trackWidth = getTotalSlides(spec) * spec.slideWidth;
|
|
423
|
-
else trackHeight = (spec.unslick ? spec.slideCount : spec.slideCount + 2 * spec.slidesToShow) * spec.slideHeight;
|
|
424
|
-
let style = {
|
|
425
|
-
opacity: 1,
|
|
426
|
-
transition: "",
|
|
427
|
-
WebkitTransition: ""
|
|
428
|
-
};
|
|
429
|
-
if (spec.useTransform) {
|
|
430
|
-
const WebkitTransform = !spec.vertical ? `translate3d(${spec.left}px, 0px, 0px)` : `translate3d(0px, ${spec.left}px, 0px)`;
|
|
431
|
-
const transform = !spec.vertical ? `translate3d(${spec.left}px, 0px, 0px)` : `translate3d(0px, ${spec.left}px, 0px)`;
|
|
432
|
-
const msTransform = !spec.vertical ? `translateX(${spec.left}px)` : `translateY(${spec.left}px)`;
|
|
433
|
-
style = {
|
|
434
|
-
...style,
|
|
435
|
-
WebkitTransform,
|
|
436
|
-
transform,
|
|
437
|
-
msTransform
|
|
438
|
-
};
|
|
439
|
-
} else if (spec.vertical) style.top = spec.left;
|
|
440
|
-
else style.left = spec.left;
|
|
441
|
-
if (spec.fade) style = { opacity: 1 };
|
|
442
|
-
if (trackWidth) style.width = (0, _v_c_util_dist_props_util.getStylePxValue)(trackWidth);
|
|
443
|
-
if (trackHeight) style.height = (0, _v_c_util_dist_props_util.getStylePxValue)(trackHeight);
|
|
444
|
-
return style;
|
|
445
|
-
}
|
|
446
|
-
function getTrackAnimateCSS(spec) {
|
|
447
|
-
checkSpecKeys(spec, [
|
|
448
|
-
"left",
|
|
449
|
-
"variableWidth",
|
|
450
|
-
"slideCount",
|
|
451
|
-
"slidesToShow",
|
|
452
|
-
"slideWidth",
|
|
453
|
-
"speed",
|
|
454
|
-
"cssEase"
|
|
455
|
-
]);
|
|
456
|
-
const style = getTrackCSS(spec);
|
|
457
|
-
if (spec.useTransform) {
|
|
458
|
-
style.WebkitTransition = `-webkit-transform ${spec.speed}ms ${spec.cssEase}`;
|
|
459
|
-
style.transition = `transform ${spec.speed}ms ${spec.cssEase}`;
|
|
460
|
-
} else if (spec.vertical) style.transition = `top ${spec.speed}ms ${spec.cssEase}`;
|
|
461
|
-
else style.transition = `left ${spec.speed}ms ${spec.cssEase}`;
|
|
462
|
-
return style;
|
|
463
|
-
}
|
|
464
|
-
function getTrackLeft(spec) {
|
|
465
|
-
if (spec.unslick) return 0;
|
|
466
|
-
checkSpecKeys(spec, [
|
|
467
|
-
"slideIndex",
|
|
468
|
-
"trackRef",
|
|
469
|
-
"infinite",
|
|
470
|
-
"centerMode",
|
|
471
|
-
"slideCount",
|
|
472
|
-
"slidesToShow",
|
|
473
|
-
"slidesToScroll",
|
|
474
|
-
"slideWidth",
|
|
475
|
-
"listWidth",
|
|
476
|
-
"variableWidth",
|
|
477
|
-
"slideHeight"
|
|
478
|
-
]);
|
|
479
|
-
const { slideIndex, trackRef, infinite, centerMode, slideCount, slidesToShow, slidesToScroll, slideWidth, listWidth, variableWidth, slideHeight, fade, vertical } = spec;
|
|
480
|
-
let slideOffset = 0;
|
|
481
|
-
let targetLeft = 0;
|
|
482
|
-
let targetSlide = null;
|
|
483
|
-
let verticalOffset = 0;
|
|
484
|
-
if (fade || spec.slideCount === 1) return 0;
|
|
485
|
-
let slidesToOffset = 0;
|
|
486
|
-
if (infinite) {
|
|
487
|
-
slidesToOffset = -getPreClones(spec);
|
|
488
|
-
if (slideCount % slidesToScroll !== 0 && slideIndex + slidesToScroll > slideCount) slidesToOffset = -(slideIndex > slideCount ? slidesToShow - (slideIndex - slideCount) : slideCount % slidesToScroll);
|
|
489
|
-
if (centerMode) slidesToOffset += parseInt(String(slidesToShow / 2));
|
|
490
|
-
} else {
|
|
491
|
-
if (slideCount % slidesToScroll !== 0 && slideIndex + slidesToScroll > slideCount) slidesToOffset = slidesToShow - slideCount % slidesToScroll;
|
|
492
|
-
if (centerMode) slidesToOffset = parseInt(String(slidesToShow / 2));
|
|
493
|
-
}
|
|
494
|
-
slideOffset = slidesToOffset * slideWidth;
|
|
495
|
-
verticalOffset = slidesToOffset * slideHeight;
|
|
496
|
-
if (!vertical) targetLeft = slideIndex * slideWidth * -1 + slideOffset;
|
|
497
|
-
else targetLeft = slideIndex * slideHeight * -1 + verticalOffset;
|
|
498
|
-
if (variableWidth === true) {
|
|
499
|
-
let targetSlideIndex = 0;
|
|
500
|
-
const trackElem = getTrackNode(trackRef);
|
|
501
|
-
targetSlideIndex = slideIndex + getPreClones(spec);
|
|
502
|
-
targetSlide = trackElem && trackElem.childNodes[targetSlideIndex];
|
|
503
|
-
targetLeft = targetSlide ? targetSlide.offsetLeft * -1 : 0;
|
|
504
|
-
if (centerMode === true) {
|
|
505
|
-
targetSlideIndex = infinite ? slideIndex + getPreClones(spec) : slideIndex;
|
|
506
|
-
targetSlide = trackElem && trackElem.children[targetSlideIndex];
|
|
507
|
-
targetLeft = 0;
|
|
508
|
-
for (let slide = 0; slide < targetSlideIndex; slide++) targetLeft -= trackElem && trackElem.children[slide] && trackElem.children[slide].offsetWidth;
|
|
509
|
-
targetLeft -= parseInt(spec.centerPadding);
|
|
510
|
-
targetLeft += targetSlide && (listWidth - targetSlide.offsetWidth) / 2;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return targetLeft;
|
|
514
|
-
}
|
|
515
|
-
function getPreClones(spec) {
|
|
516
|
-
if (spec.unslick || !spec.infinite) return 0;
|
|
517
|
-
if (spec.variableWidth) return spec.slideCount;
|
|
518
|
-
return spec.slidesToShow + (spec.centerMode ? 1 : 0);
|
|
519
|
-
}
|
|
520
|
-
function getPostClones(spec) {
|
|
521
|
-
if (spec.unslick || !spec.infinite) return 0;
|
|
522
|
-
if (spec.variableWidth) return spec.slideCount;
|
|
523
|
-
return spec.slidesToShow + (spec.centerMode ? 1 : 0);
|
|
524
|
-
}
|
|
525
|
-
function getTotalSlides(spec) {
|
|
526
|
-
return spec.slideCount === 1 ? 1 : getPreClones(spec) + spec.slideCount + getPostClones(spec);
|
|
527
|
-
}
|
|
528
|
-
function siblingDirection(spec) {
|
|
529
|
-
if (spec.targetSlide > spec.currentSlide) {
|
|
530
|
-
if (spec.targetSlide > spec.currentSlide + slidesOnRight(spec)) return "left";
|
|
531
|
-
return "right";
|
|
532
|
-
} else {
|
|
533
|
-
if (spec.targetSlide < spec.currentSlide - slidesOnLeft(spec)) return "right";
|
|
534
|
-
return "left";
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
function slidesOnRight({ slidesToShow, centerMode, rtl, centerPadding }) {
|
|
538
|
-
if (centerMode) {
|
|
539
|
-
let right = (slidesToShow - 1) / 2 + 1;
|
|
540
|
-
if (parseInt(centerPadding || "0") > 0) right += 1;
|
|
541
|
-
if (rtl && slidesToShow % 2 === 0) right += 1;
|
|
542
|
-
return right;
|
|
543
|
-
}
|
|
544
|
-
if (rtl) return 0;
|
|
545
|
-
return slidesToShow - 1;
|
|
546
|
-
}
|
|
547
|
-
function slidesOnLeft({ slidesToShow, centerMode, rtl, centerPadding }) {
|
|
548
|
-
if (centerMode) {
|
|
549
|
-
let left = (slidesToShow - 1) / 2 + 1;
|
|
550
|
-
if (parseInt(centerPadding || "0") > 0) left += 1;
|
|
551
|
-
if (!rtl && slidesToShow % 2 === 0) left += 1;
|
|
552
|
-
return left;
|
|
553
|
-
}
|
|
554
|
-
if (rtl) return slidesToShow - 1;
|
|
555
|
-
return 0;
|
|
556
|
-
}
|
|
557
|
-
function canUseDOM() {
|
|
558
|
-
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
559
|
-
}
|
|
560
|
-
const validSettings = Object.keys(require_default_props.default);
|
|
561
|
-
function filterSettings(settings) {
|
|
562
|
-
return validSettings.reduce((acc, settingName) => {
|
|
563
|
-
if (settings.hasOwnProperty(settingName)) acc[settingName] = settings[settingName];
|
|
564
|
-
return acc;
|
|
565
|
-
}, {});
|
|
566
|
-
}
|
|
567
|
-
exports.canGoNext = canGoNext;
|
|
568
|
-
exports.canUseDOM = canUseDOM;
|
|
569
|
-
exports.changeSlide = changeSlide;
|
|
570
|
-
exports.checkNavigable = checkNavigable;
|
|
571
|
-
exports.checkSpecKeys = checkSpecKeys;
|
|
572
|
-
exports.clamp = clamp;
|
|
573
|
-
exports.extractObject = extractObject;
|
|
574
|
-
exports.filterSettings = filterSettings;
|
|
575
|
-
exports.getHeight = getHeight;
|
|
576
|
-
exports.getNavigableIndexes = getNavigableIndexes;
|
|
577
|
-
exports.getOnDemandLazySlides = getOnDemandLazySlides;
|
|
578
|
-
exports.getPostClones = getPostClones;
|
|
579
|
-
exports.getPreClones = getPreClones;
|
|
580
|
-
exports.getRequiredLazySlides = getRequiredLazySlides;
|
|
581
|
-
exports.getSlideCount = getSlideCount;
|
|
582
|
-
exports.getSwipeDirection = getSwipeDirection;
|
|
583
|
-
exports.getTotalSlides = getTotalSlides;
|
|
584
|
-
exports.getTrackAnimateCSS = getTrackAnimateCSS;
|
|
585
|
-
exports.getTrackCSS = getTrackCSS;
|
|
586
|
-
exports.getTrackLeft = getTrackLeft;
|
|
587
|
-
exports.getWidth = getWidth;
|
|
588
|
-
exports.initializedState = initializedState;
|
|
589
|
-
exports.keyHandler = keyHandler;
|
|
590
|
-
exports.lazyEndIndex = lazyEndIndex;
|
|
591
|
-
exports.lazySlidesOnLeft = lazySlidesOnLeft;
|
|
592
|
-
exports.lazySlidesOnRight = lazySlidesOnRight;
|
|
593
|
-
exports.lazyStartIndex = lazyStartIndex;
|
|
594
|
-
exports.safePreventDefault = safePreventDefault;
|
|
595
|
-
exports.siblingDirection = siblingDirection;
|
|
596
|
-
exports.slideHandler = slideHandler;
|
|
597
|
-
exports.slidesOnLeft = slidesOnLeft;
|
|
598
|
-
exports.slidesOnRight = slidesOnRight;
|
|
599
|
-
exports.swipeEnd = swipeEnd;
|
|
600
|
-
exports.swipeMove = swipeMove;
|
|
601
|
-
exports.swipeStart = swipeStart;
|
|
602
|
-
exports.validSettings = validSettings;
|