@creative-web-solution/front-library 7.1.27 → 7.1.29
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/CHANGELOG.md +10 -0
- package/Modules/DragSlider.ts +382 -382
- package/Modules/YouTubePlayer.ts +7 -3
- package/README.md +1 -1
- package/Types/YouTubePlayer.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/Modules/DragSlider.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { wait }
|
|
2
|
-
import { debounce }
|
|
3
|
-
import { offset }
|
|
4
|
-
import { gesture, gestureOff }
|
|
5
|
-
import { prop }
|
|
6
|
-
import { aClass, rClass, tClass }
|
|
7
|
-
import { on, off }
|
|
8
|
-
import { isTouchDevice }
|
|
9
|
-
import { extend }
|
|
1
|
+
import { wait } from "../Helpers/Wait";
|
|
2
|
+
import { debounce } from "../Helpers/Debounce";
|
|
3
|
+
import { offset } from "../DOM/Offset";
|
|
4
|
+
import { gesture, gestureOff } from "../Events/Gesture";
|
|
5
|
+
import { prop } from "../DOM/Styles";
|
|
6
|
+
import { aClass, rClass, tClass } from "../DOM/Class";
|
|
7
|
+
import { on, off } from "../Events/EventsManager";
|
|
8
|
+
import { isTouchDevice } from "../Tools/TouchDeviceSupport";
|
|
9
|
+
import { extend } from "../Helpers/Extend";
|
|
10
10
|
|
|
11
11
|
const defaultOptions = {
|
|
12
12
|
swipeTresholdMin: 40,
|
|
13
13
|
swipeTresholdSize: 0.5,
|
|
14
|
-
lockedClass:
|
|
15
|
-
_animReset: function($list) {
|
|
14
|
+
lockedClass: "is-locked",
|
|
15
|
+
_animReset: function ($list) {
|
|
16
16
|
// gsap.set( $list, {
|
|
17
17
|
// "x": 0,
|
|
18
18
|
// "y": 0,
|
|
19
19
|
// "z": 0
|
|
20
20
|
// } );
|
|
21
21
|
},
|
|
22
|
-
_animClear: function($list) {
|
|
22
|
+
_animClear: function ($list) {
|
|
23
23
|
// gsap.set( $list, {
|
|
24
24
|
// "clearProps": "all"
|
|
25
25
|
// } );
|
|
26
26
|
},
|
|
27
|
-
_animKill: function($list) {
|
|
27
|
+
_animKill: function ($list) {
|
|
28
28
|
// gsap.killTweensOf( $list );
|
|
29
29
|
},
|
|
30
|
-
_animMoveItem: function($list, x, onUpdate) {
|
|
30
|
+
_animMoveItem: function ($list, x, onUpdate) {
|
|
31
31
|
// return gsap.to( $list, {
|
|
32
32
|
// "duration": 0.3,
|
|
33
33
|
// "x": x,
|
|
@@ -38,14 +38,14 @@ const defaultOptions = {
|
|
|
38
38
|
// }
|
|
39
39
|
// } );
|
|
40
40
|
},
|
|
41
|
-
_setCoordinates: function($list, x) {
|
|
41
|
+
_setCoordinates: function ($list, x) {
|
|
42
42
|
// gsap.set( $list, {
|
|
43
43
|
// "x": x,
|
|
44
44
|
// "y": 0,
|
|
45
45
|
// "z": 0
|
|
46
46
|
// } );
|
|
47
|
-
}
|
|
48
|
-
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
49
|
|
|
50
50
|
const MINIMUM_MOVEMENT_TO_START_DRAG = 3; // px
|
|
51
51
|
|
|
@@ -53,34 +53,35 @@ const MINIMUM_MOVEMENT_TO_START_DRAG = 3; // px
|
|
|
53
53
|
* DragSlider
|
|
54
54
|
*/
|
|
55
55
|
export default class DragSlider {
|
|
56
|
-
#isDraggingActive:
|
|
57
|
-
#options:
|
|
58
|
-
#deltaMove:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
#isDraggingActive: boolean;
|
|
57
|
+
#options: FLib.DragSlider.Options;
|
|
58
|
+
#deltaMove: FLib.DragSlider.DeltaMove = {
|
|
59
|
+
x: 0,
|
|
60
|
+
deltaX: 0,
|
|
61
|
+
deltaY: 0,
|
|
62
|
+
newX: 0,
|
|
63
63
|
};
|
|
64
|
-
#itemArray:
|
|
65
|
-
#$slider:
|
|
64
|
+
#itemArray: FLib.DragSlider.Item[];
|
|
65
|
+
#$slider: HTMLElement;
|
|
66
66
|
#viewportInfo;
|
|
67
|
-
#siteOffsetLeft
|
|
68
|
-
#siteOffsetRight
|
|
69
|
-
#listDelta
|
|
70
|
-
#$viewport:
|
|
71
|
-
#$items:
|
|
72
|
-
#$list:
|
|
73
|
-
#isDragging
|
|
74
|
-
#itemMap
|
|
75
|
-
#firstItem:
|
|
76
|
-
#currentSnapItem:
|
|
77
|
-
#hasAlreadyBeenDragged
|
|
78
|
-
#startDragCoords:
|
|
79
|
-
#isInitialized
|
|
80
|
-
#visibleItems:
|
|
81
|
-
#hiddenItems:
|
|
67
|
+
#siteOffsetLeft = 0;
|
|
68
|
+
#siteOffsetRight = 0;
|
|
69
|
+
#listDelta = 0;
|
|
70
|
+
#$viewport: HTMLElement | undefined;
|
|
71
|
+
#$items: NodeList | undefined;
|
|
72
|
+
#$list: HTMLElement | undefined;
|
|
73
|
+
#isDragging = false;
|
|
74
|
+
#itemMap = new Map<HTMLElement, FLib.DragSlider.Item>();
|
|
75
|
+
#firstItem: FLib.DragSlider.Item | undefined;
|
|
76
|
+
#currentSnapItem: FLib.DragSlider.Item | undefined;
|
|
77
|
+
#hasAlreadyBeenDragged = false;
|
|
78
|
+
#startDragCoords: FLib.Events.Gesture.Coords | undefined;
|
|
79
|
+
#isInitialized = false;
|
|
80
|
+
#visibleItems: FLib.DragSlider.Item[] = [];
|
|
81
|
+
#hiddenItems: FLib.DragSlider.Item[] = [];
|
|
82
82
|
#debouncedOnResize;
|
|
83
|
-
|
|
83
|
+
#minXPos: number = 0;
|
|
84
|
+
#maxXPos: number = 0;
|
|
84
85
|
|
|
85
86
|
get count(): number {
|
|
86
87
|
return this.#$items?.length ?? 0;
|
|
@@ -106,83 +107,110 @@ export default class DragSlider {
|
|
|
106
107
|
return this.#hiddenItems;
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
get firstItem(): FLib.DragSlider.Item | undefined {
|
|
111
|
+
return this.#itemArray[0];
|
|
112
|
+
}
|
|
109
113
|
|
|
110
|
-
|
|
114
|
+
get lastItem(): FLib.DragSlider.Item | undefined {
|
|
115
|
+
return this.#itemArray[this.#itemArray.length - 1];
|
|
116
|
+
}
|
|
111
117
|
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
constructor(
|
|
119
|
+
$slider: HTMLElement,
|
|
120
|
+
userOptions: Partial<FLib.DragSlider.Options>
|
|
121
|
+
) {
|
|
122
|
+
if (
|
|
123
|
+
!userOptions.viewportSelector ||
|
|
124
|
+
!userOptions.listSelector ||
|
|
125
|
+
!userOptions.itemSelector ||
|
|
126
|
+
!userOptions.dragClass
|
|
127
|
+
) {
|
|
128
|
+
throw "[Drag Slider]: Missing at least one of viewportSelector, listSelector, itemSelector, dragClass";
|
|
114
129
|
}
|
|
115
130
|
|
|
116
131
|
this.#$slider = $slider;
|
|
117
132
|
|
|
118
133
|
this.#isDraggingActive = false;
|
|
119
134
|
|
|
120
|
-
this.#options = extend(
|
|
135
|
+
this.#options = extend(defaultOptions, userOptions);
|
|
121
136
|
|
|
122
137
|
this.#itemArray = [];
|
|
123
138
|
|
|
124
|
-
wait(
|
|
139
|
+
wait("idle").then(this.init);
|
|
125
140
|
}
|
|
126
141
|
|
|
127
|
-
|
|
128
142
|
#cancelLinkClick = (): void => {
|
|
129
|
-
aClass(
|
|
130
|
-
}
|
|
131
|
-
|
|
143
|
+
aClass(this.#$slider, this.#options.dragClass);
|
|
144
|
+
};
|
|
132
145
|
|
|
133
146
|
#activeLinkClick = (): void => {
|
|
134
|
-
wait().then(
|
|
135
|
-
rClass(
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
147
|
+
wait().then(() => {
|
|
148
|
+
rClass(this.#$slider, this.#options.dragClass);
|
|
149
|
+
});
|
|
150
|
+
};
|
|
139
151
|
|
|
140
152
|
#onResize = (): void => {
|
|
141
|
-
if (
|
|
153
|
+
if (!this.#$items || !this.#$list) {
|
|
142
154
|
return;
|
|
143
155
|
}
|
|
144
156
|
|
|
145
|
-
this.#viewportInfo
|
|
146
|
-
this.#siteOffsetLeft
|
|
147
|
-
|
|
157
|
+
this.#viewportInfo = offset(this.#$viewport as HTMLElement);
|
|
158
|
+
this.#siteOffsetLeft = parseInt(
|
|
159
|
+
prop(this.#$items[0] as HTMLElement, "marginLeft"),
|
|
160
|
+
10
|
|
161
|
+
);
|
|
162
|
+
this.#siteOffsetRight = parseInt(
|
|
163
|
+
prop(
|
|
164
|
+
this.#$items[this.#$items.length - 1] as HTMLElement,
|
|
165
|
+
"marginRight"
|
|
166
|
+
),
|
|
167
|
+
10
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
this.#listDelta = this.#getMaxMoveSize();
|
|
148
171
|
|
|
149
|
-
this.#
|
|
172
|
+
this.#minXPos = 0;
|
|
173
|
+
this.#maxXPos = this.#listDelta;
|
|
150
174
|
|
|
151
175
|
const prevIsDraggingActive = this.#isDraggingActive;
|
|
152
|
-
this.#isDraggingActive
|
|
176
|
+
this.#isDraggingActive = this.#listDelta < 0;
|
|
153
177
|
|
|
154
|
-
if (
|
|
178
|
+
if (!this.#isDraggingActive) {
|
|
155
179
|
this.#isDragging = false;
|
|
156
|
-
this.#options._animKill(
|
|
157
|
-
this.#options._animReset(
|
|
180
|
+
this.#options._animKill(this.#$list);
|
|
181
|
+
this.#options._animReset(this.#$list);
|
|
158
182
|
}
|
|
159
183
|
|
|
160
|
-
tClass(
|
|
184
|
+
tClass(
|
|
185
|
+
this.#$slider,
|
|
186
|
+
this.#options.lockedClass,
|
|
187
|
+
!this.#isDraggingActive
|
|
188
|
+
);
|
|
161
189
|
|
|
162
|
-
if (
|
|
163
|
-
this.#options.onChangeState?.(
|
|
190
|
+
if (prevIsDraggingActive !== this.#isDraggingActive) {
|
|
191
|
+
this.#options.onChangeState?.(this.#isDraggingActive);
|
|
164
192
|
}
|
|
165
193
|
|
|
166
194
|
this.#itemArray.length = 0;
|
|
167
|
-
const ABS_LIST_DELTA = Math.abs(
|
|
195
|
+
const ABS_LIST_DELTA = Math.abs(this.#listDelta);
|
|
168
196
|
|
|
169
197
|
let flag = false;
|
|
170
198
|
|
|
171
199
|
for (let index = 0; index < this.#$items.length; ++index) {
|
|
172
|
-
const $ITEM
|
|
173
|
-
const ITEM_OFFSET = offset(
|
|
200
|
+
const $ITEM = this.#$items[index] as HTMLElement;
|
|
201
|
+
const ITEM_OFFSET = offset($ITEM, false, this.#$list);
|
|
174
202
|
const DATA = {
|
|
175
203
|
index,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
204
|
+
isFirst: index === 0,
|
|
205
|
+
isLast: false,
|
|
206
|
+
$item: $ITEM,
|
|
207
|
+
info: ITEM_OFFSET,
|
|
180
208
|
};
|
|
181
209
|
|
|
182
210
|
if (ITEM_OFFSET.left - this.#siteOffsetLeft <= ABS_LIST_DELTA) {
|
|
183
211
|
this.#itemArray.push(DATA);
|
|
184
212
|
|
|
185
|
-
this.#itemMap.set(
|
|
213
|
+
this.#itemMap.set($ITEM, DATA);
|
|
186
214
|
continue;
|
|
187
215
|
}
|
|
188
216
|
|
|
@@ -201,84 +229,84 @@ export default class DragSlider {
|
|
|
201
229
|
}
|
|
202
230
|
flag = true;
|
|
203
231
|
|
|
204
|
-
this.#itemMap.set(
|
|
232
|
+
this.#itemMap.set($ITEM, DATA);
|
|
205
233
|
}
|
|
206
234
|
|
|
207
|
-
this.#firstItem = this.#itemMap.get(
|
|
235
|
+
this.#firstItem = this.#itemMap.get(
|
|
236
|
+
this.#$items[0] as HTMLElement
|
|
237
|
+
) as FLib.DragSlider.Item;
|
|
208
238
|
|
|
209
|
-
if (
|
|
239
|
+
if (!this.#currentSnapItem) {
|
|
210
240
|
this.#currentSnapItem = this.#firstItem;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
241
|
+
} else {
|
|
242
|
+
this.#currentSnapItem =
|
|
243
|
+
this.#itemArray[this.#currentSnapItem.index];
|
|
214
244
|
}
|
|
215
245
|
|
|
216
246
|
this.#updateAccessibilityFeature();
|
|
217
|
-
}
|
|
218
|
-
|
|
247
|
+
};
|
|
219
248
|
|
|
220
|
-
#snapToItemAnimation =
|
|
249
|
+
#snapToItemAnimation = (snapItem: FLib.DragSlider.Item): Promise<any> => {
|
|
221
250
|
if (!snapItem) {
|
|
222
251
|
return Promise.resolve();
|
|
223
252
|
}
|
|
224
253
|
|
|
225
|
-
|
|
254
|
+
const finalX = Math.max(
|
|
255
|
+
Math.min(
|
|
256
|
+
this.#minXPos,
|
|
257
|
+
-1 * snapItem.info.left + this.#siteOffsetLeft
|
|
258
|
+
),
|
|
259
|
+
this.#maxXPos
|
|
260
|
+
);
|
|
226
261
|
|
|
227
|
-
finalX
|
|
262
|
+
this.#options.onSnap?.(this.#getCallbackOptions(finalX, snapItem));
|
|
228
263
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// If close to the end, then snap to it
|
|
232
|
-
if ( Math.abs( finalX - this.#listDelta ) <= 3 ) {
|
|
233
|
-
finalX = this.#listDelta;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// If close to the start, then snap to it
|
|
237
|
-
if ( Math.abs( finalX ) <= 3 ) {
|
|
238
|
-
finalX = 0;
|
|
239
|
-
}
|
|
264
|
+
this.#currentSnapItem = snapItem;
|
|
240
265
|
|
|
241
|
-
|
|
242
|
-
|
|
266
|
+
return this.#options
|
|
267
|
+
._animMoveItem(this.#$list, finalX, (newX) => {
|
|
268
|
+
this.#deltaMove.x = newX;
|
|
243
269
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
270
|
+
this.#options.onSnapUpdate?.(
|
|
271
|
+
this.#getCallbackOptions(newX, snapItem)
|
|
272
|
+
);
|
|
273
|
+
})
|
|
274
|
+
.then(() => {
|
|
275
|
+
return this.#updateAccessibilityFeature();
|
|
276
|
+
})
|
|
277
|
+
.then(() => {
|
|
278
|
+
this.#deltaMove.x = finalX;
|
|
279
|
+
this.#options.onSnapEnd?.(
|
|
280
|
+
this.#getCallbackOptions(this.#deltaMove.x)
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
};
|
|
253
284
|
|
|
254
|
-
|
|
285
|
+
#getCallbackOptions(xPos: number, snapItem?: FLib.DragSlider.Item) {
|
|
286
|
+
const IS_SNAP_TO_END = xPos === this.#listDelta;
|
|
287
|
+
const IS_SNAP_TO_START = xPos === 0;
|
|
255
288
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this.#
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"isAtStart": IS_SNAP_TO_START,
|
|
266
|
-
"isAtEnd": IS_SNAP_TO_END,
|
|
267
|
-
"visibleItems": this.#visibleItems,
|
|
268
|
-
"hiddenItems": this.#hiddenItems
|
|
269
|
-
} );
|
|
270
|
-
} ).then(() => this.#updateAccessibilityFeature());
|
|
289
|
+
return {
|
|
290
|
+
item: snapItem ?? this.#currentSnapItem,
|
|
291
|
+
xPos: this.#deltaMove.x,
|
|
292
|
+
moveMaxSize: this.#listDelta,
|
|
293
|
+
isAtStart: IS_SNAP_TO_START,
|
|
294
|
+
isAtEnd: IS_SNAP_TO_END,
|
|
295
|
+
visibleItems: this.#visibleItems,
|
|
296
|
+
hiddenItems: this.#hiddenItems,
|
|
297
|
+
};
|
|
271
298
|
}
|
|
272
299
|
|
|
273
|
-
|
|
274
|
-
|
|
300
|
+
#getFirstPreviousItem = (
|
|
301
|
+
xPos: number
|
|
302
|
+
): { snapItem: FLib.DragSlider.Item; snapToEnd: boolean } => {
|
|
275
303
|
let snapItem;
|
|
276
304
|
|
|
277
|
-
const absXPos = Math.abs(
|
|
305
|
+
const absXPos = Math.abs(xPos);
|
|
278
306
|
|
|
279
|
-
for (
|
|
280
|
-
if (
|
|
281
|
-
snapItem
|
|
307
|
+
for (const item of this.#itemArray) {
|
|
308
|
+
if (item.info.left <= absXPos) {
|
|
309
|
+
snapItem = item;
|
|
282
310
|
continue;
|
|
283
311
|
}
|
|
284
312
|
break;
|
|
@@ -286,168 +314,173 @@ export default class DragSlider {
|
|
|
286
314
|
|
|
287
315
|
return {
|
|
288
316
|
snapItem,
|
|
289
|
-
|
|
317
|
+
snapToEnd: false,
|
|
290
318
|
};
|
|
291
|
-
}
|
|
292
|
-
|
|
319
|
+
};
|
|
293
320
|
|
|
294
|
-
#getFirstNextItem = (
|
|
321
|
+
#getFirstNextItem = (
|
|
322
|
+
xPos: number
|
|
323
|
+
): { snapItem: FLib.DragSlider.Item; snapToEnd: boolean } => {
|
|
295
324
|
let snapItem;
|
|
296
325
|
|
|
297
|
-
const absXPos = Math.abs(
|
|
326
|
+
const absXPos = Math.abs(xPos);
|
|
298
327
|
|
|
299
|
-
for (
|
|
300
|
-
if (
|
|
328
|
+
for (const item of this.#itemArray) {
|
|
329
|
+
if (item.info.left < absXPos) {
|
|
301
330
|
continue;
|
|
302
331
|
}
|
|
303
332
|
|
|
304
|
-
snapItem
|
|
333
|
+
snapItem = item;
|
|
305
334
|
break;
|
|
306
335
|
}
|
|
307
336
|
|
|
308
337
|
return {
|
|
309
|
-
|
|
310
|
-
|
|
338
|
+
snapItem: snapItem
|
|
339
|
+
? snapItem
|
|
340
|
+
: this.#itemArray[this.#itemArray.length - 1],
|
|
341
|
+
snapToEnd: !snapItem,
|
|
311
342
|
};
|
|
312
|
-
}
|
|
313
|
-
|
|
343
|
+
};
|
|
314
344
|
|
|
315
|
-
#getClosestItem = (
|
|
345
|
+
#getClosestItem = (
|
|
346
|
+
xPos: number
|
|
347
|
+
): { snapItem: FLib.DragSlider.Item; snapToEnd: boolean } => {
|
|
316
348
|
let lastDelta, snapItem;
|
|
317
349
|
|
|
318
|
-
const absXPos = Math.abs(
|
|
350
|
+
const absXPos = Math.abs(xPos);
|
|
319
351
|
|
|
320
|
-
for (
|
|
321
|
-
const IS_LAST_DELTA = typeof lastDelta !==
|
|
322
|
-
const newDelta = Math.abs(
|
|
352
|
+
for (const item of this.#itemArray) {
|
|
353
|
+
const IS_LAST_DELTA = typeof lastDelta !== "undefined";
|
|
354
|
+
const newDelta = Math.abs(
|
|
355
|
+
absXPos - item.info.left + this.#siteOffsetLeft
|
|
356
|
+
);
|
|
323
357
|
|
|
324
|
-
if (
|
|
358
|
+
if (!IS_LAST_DELTA || newDelta <= lastDelta) {
|
|
325
359
|
lastDelta = newDelta;
|
|
326
|
-
snapItem
|
|
360
|
+
snapItem = item;
|
|
327
361
|
}
|
|
328
362
|
}
|
|
329
363
|
|
|
330
364
|
return {
|
|
331
365
|
snapItem,
|
|
332
|
-
snapToEnd: false
|
|
366
|
+
snapToEnd: false,
|
|
333
367
|
};
|
|
334
|
-
}
|
|
335
|
-
|
|
368
|
+
};
|
|
336
369
|
|
|
337
370
|
#snapToItem = (): void => {
|
|
338
371
|
let snapItem;
|
|
339
372
|
|
|
340
|
-
const ABS_DELTA_X = Math.abs(
|
|
373
|
+
const ABS_DELTA_X = Math.abs(this.#deltaMove.deltaX);
|
|
341
374
|
|
|
342
375
|
// If move a bit on right or left, juste move by one item only
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
376
|
+
if (
|
|
377
|
+
ABS_DELTA_X >= this.#options.swipeTresholdMin &&
|
|
378
|
+
ABS_DELTA_X <
|
|
379
|
+
Math.min(
|
|
380
|
+
(this.#firstItem as FLib.DragSlider.Item).info.width *
|
|
381
|
+
this.#options.swipeTresholdSize,
|
|
382
|
+
this.#options.swipeTresholdMin * 3
|
|
383
|
+
)
|
|
384
|
+
) {
|
|
385
|
+
if (this.#deltaMove.deltaX < 0) {
|
|
386
|
+
snapItem = this.#getFirstNextItem(this.#deltaMove.x);
|
|
387
|
+
} else {
|
|
388
|
+
snapItem = this.#getFirstPreviousItem(this.#deltaMove.x);
|
|
346
389
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
snapItem = this.#getClosestItem( this.#deltaMove.x );
|
|
390
|
+
} else {
|
|
391
|
+
snapItem = this.#getClosestItem(this.#deltaMove.x);
|
|
353
392
|
}
|
|
354
393
|
|
|
355
|
-
if (
|
|
394
|
+
if (!snapItem) {
|
|
356
395
|
return;
|
|
357
396
|
}
|
|
358
397
|
|
|
359
|
-
this.#snapToItemAnimation(
|
|
360
|
-
|
|
361
|
-
"item": this.#currentSnapItem,
|
|
362
|
-
"xPos": this.#deltaMove.x,
|
|
363
|
-
"moveMaxSize": this.#listDelta,
|
|
364
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
365
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
366
|
-
"visibleItems": this.#visibleItems,
|
|
367
|
-
"hiddenItems": this.#hiddenItems
|
|
368
|
-
})
|
|
369
|
-
});
|
|
370
|
-
}
|
|
398
|
+
this.#snapToItemAnimation(snapItem.snapItem);
|
|
399
|
+
};
|
|
371
400
|
|
|
401
|
+
#getMaxMoveSize(): number {
|
|
402
|
+
return (
|
|
403
|
+
this.#viewportInfo.width -
|
|
404
|
+
this.#$list!.scrollWidth -
|
|
405
|
+
this.#siteOffsetLeft
|
|
406
|
+
);
|
|
407
|
+
}
|
|
372
408
|
|
|
373
|
-
#onStartDrag = (
|
|
374
|
-
|
|
409
|
+
#onStartDrag = (
|
|
410
|
+
e: Event,
|
|
411
|
+
$target: HTMLElement,
|
|
412
|
+
coords: FLib.Events.Gesture.Coords
|
|
413
|
+
): void => {
|
|
414
|
+
if (!this.#hasAlreadyBeenDragged) {
|
|
375
415
|
this.#onResize();
|
|
376
416
|
this.#hasAlreadyBeenDragged = true;
|
|
377
417
|
}
|
|
378
418
|
|
|
379
|
-
if (
|
|
419
|
+
if (!this.#isDraggingActive || !this.#$list) {
|
|
380
420
|
return;
|
|
381
421
|
}
|
|
382
422
|
|
|
383
423
|
this.#isDragging = true;
|
|
384
424
|
|
|
385
|
-
this.#options._animKill(
|
|
425
|
+
this.#options._animKill(this.#$list);
|
|
386
426
|
|
|
387
427
|
this.#startDragCoords = coords;
|
|
388
|
-
this.#listDelta
|
|
389
|
-
this.#deltaMove.newX
|
|
390
|
-
|
|
391
|
-
gesture(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (
|
|
428
|
+
this.#listDelta = this.#getMaxMoveSize();
|
|
429
|
+
this.#deltaMove.newX = this.#deltaMove.x;
|
|
430
|
+
|
|
431
|
+
gesture(document.body, "dragSlider", {
|
|
432
|
+
move: this.#onMove,
|
|
433
|
+
end: this.#onStopDrag,
|
|
434
|
+
preventMove: (e) => {
|
|
435
|
+
if (!e.cancelable) {
|
|
396
436
|
return false;
|
|
397
437
|
}
|
|
398
438
|
|
|
399
|
-
return
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"moveMaxSize": this.#listDelta,
|
|
408
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
409
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
410
|
-
"visibleItems": this.#visibleItems,
|
|
411
|
-
"hiddenItems": this.#hiddenItems
|
|
412
|
-
} );
|
|
413
|
-
}
|
|
439
|
+
return (
|
|
440
|
+
!isTouchDevice ||
|
|
441
|
+
(isTouchDevice &&
|
|
442
|
+
Math.abs(this.#deltaMove.deltaY) <
|
|
443
|
+
Math.abs(this.#deltaMove.deltaX))
|
|
444
|
+
);
|
|
445
|
+
},
|
|
446
|
+
});
|
|
414
447
|
|
|
448
|
+
this.#options.onStartDrag?.(
|
|
449
|
+
this.#getCallbackOptions(this.#deltaMove.x)
|
|
450
|
+
);
|
|
451
|
+
};
|
|
415
452
|
|
|
416
|
-
#onMove = (
|
|
453
|
+
#onMove = (
|
|
454
|
+
e: Event,
|
|
455
|
+
$target: HTMLElement,
|
|
456
|
+
coords: FLib.Events.Gesture.Coords
|
|
457
|
+
): void => {
|
|
417
458
|
this.#cancelLinkClick();
|
|
418
459
|
|
|
419
|
-
this.#deltaMove.deltaX =
|
|
420
|
-
|
|
460
|
+
this.#deltaMove.deltaX =
|
|
461
|
+
coords.pageX -
|
|
462
|
+
(this.#startDragCoords as FLib.Events.Gesture.Coords).pageX;
|
|
463
|
+
this.#deltaMove.deltaY =
|
|
464
|
+
coords.pageY -
|
|
465
|
+
(this.#startDragCoords as FLib.Events.Gesture.Coords).pageY;
|
|
421
466
|
|
|
422
467
|
if (Math.abs(this.#deltaMove.deltaX) < MINIMUM_MOVEMENT_TO_START_DRAG) {
|
|
423
468
|
return;
|
|
424
469
|
}
|
|
425
470
|
|
|
426
|
-
this.#deltaMove.newX
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
this.#
|
|
430
|
-
|
|
431
|
-
else if ( this.#deltaMove.newX < this.#listDelta + this.#siteOffsetRight ) {
|
|
432
|
-
this.#deltaMove.newX = this.#listDelta + this.#siteOffsetRight;
|
|
433
|
-
}
|
|
471
|
+
this.#deltaMove.newX = this.#deltaMove.deltaX + this.#deltaMove.x;
|
|
472
|
+
this.#deltaMove.newX = Math.max(
|
|
473
|
+
Math.min(this.#minXPos, this.#deltaMove.newX),
|
|
474
|
+
this.#maxXPos
|
|
475
|
+
);
|
|
434
476
|
|
|
435
477
|
this.#options._setCoordinates(this.#$list, this.#deltaMove.newX);
|
|
436
478
|
|
|
437
|
-
this.#options.onDrag?.(
|
|
438
|
-
|
|
439
|
-
"xPos": this.#deltaMove.newX,
|
|
440
|
-
"moveMaxSize": this.#listDelta,
|
|
441
|
-
"isAtStart": this.#deltaMove.newX === 0,
|
|
442
|
-
"isAtEnd": this.#deltaMove.newX === this.#listDelta,
|
|
443
|
-
"visibleItems": this.#visibleItems,
|
|
444
|
-
"hiddenItems": this.#hiddenItems
|
|
445
|
-
} );
|
|
446
|
-
}
|
|
447
|
-
|
|
479
|
+
this.#options.onDrag?.(this.#getCallbackOptions(this.#deltaMove.newX));
|
|
480
|
+
};
|
|
448
481
|
|
|
449
482
|
#onStopDrag = (): void => {
|
|
450
|
-
gestureOff(
|
|
483
|
+
gestureOff(document.body, "dragSlider");
|
|
451
484
|
this.#isDragging = false;
|
|
452
485
|
|
|
453
486
|
this.#activeLinkClick();
|
|
@@ -460,138 +493,109 @@ export default class DragSlider {
|
|
|
460
493
|
|
|
461
494
|
this.#snapToItem();
|
|
462
495
|
|
|
463
|
-
this.#options.onStopDrag?.(
|
|
464
|
-
|
|
465
|
-
"xPos": this.#deltaMove.x,
|
|
466
|
-
"moveMaxSize": this.#listDelta,
|
|
467
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
468
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
469
|
-
"visibleItems": this.#visibleItems,
|
|
470
|
-
"hiddenItems": this.#hiddenItems
|
|
471
|
-
} );
|
|
472
|
-
}
|
|
473
|
-
|
|
496
|
+
this.#options.onStopDrag?.(this.#getCallbackOptions(this.#deltaMove.x));
|
|
497
|
+
};
|
|
474
498
|
|
|
475
499
|
#onMouseenter = (): void => {
|
|
476
|
-
if (
|
|
500
|
+
if (this.#isDragging || !this.#isDraggingActive) {
|
|
477
501
|
return;
|
|
478
502
|
}
|
|
479
503
|
|
|
480
|
-
this.#options.onMouseEnter?.(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
485
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
486
|
-
"visibleItems": this.#visibleItems,
|
|
487
|
-
"hiddenItems": this.#hiddenItems
|
|
488
|
-
} );
|
|
489
|
-
}
|
|
490
|
-
|
|
504
|
+
this.#options.onMouseEnter?.(
|
|
505
|
+
this.#getCallbackOptions(this.#deltaMove.x)
|
|
506
|
+
);
|
|
507
|
+
};
|
|
491
508
|
|
|
492
509
|
#onMouseleave = (): void => {
|
|
493
|
-
if (
|
|
510
|
+
if (this.#isDragging || !this.#isDraggingActive) {
|
|
494
511
|
return;
|
|
495
512
|
}
|
|
496
513
|
|
|
497
|
-
this.#options.onMouseLeave?.(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
502
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
503
|
-
"visibleItems": this.#visibleItems,
|
|
504
|
-
"hiddenItems": this.#hiddenItems
|
|
505
|
-
} );
|
|
506
|
-
}
|
|
507
|
-
|
|
514
|
+
this.#options.onMouseLeave?.(
|
|
515
|
+
this.#getCallbackOptions(this.#deltaMove.x)
|
|
516
|
+
);
|
|
517
|
+
};
|
|
508
518
|
|
|
509
|
-
#cancelDrag = (
|
|
519
|
+
#cancelDrag = (e: Event): void => {
|
|
510
520
|
e.preventDefault();
|
|
511
|
-
}
|
|
512
|
-
|
|
521
|
+
};
|
|
513
522
|
|
|
514
523
|
next(): Promise<any> {
|
|
515
524
|
const CURRENT_ITEM = this.#currentSnapItem as FLib.DragSlider.Item;
|
|
516
525
|
|
|
517
|
-
if (
|
|
526
|
+
if (
|
|
527
|
+
!this.#isDraggingActive ||
|
|
528
|
+
!this.#itemArray[CURRENT_ITEM.index + 1]
|
|
529
|
+
) {
|
|
518
530
|
return Promise.resolve();
|
|
519
531
|
}
|
|
520
532
|
|
|
521
|
-
return this.#snapToItemAnimation(
|
|
533
|
+
return this.#snapToItemAnimation(
|
|
534
|
+
this.#itemArray[CURRENT_ITEM.index + 1]
|
|
535
|
+
);
|
|
522
536
|
}
|
|
523
537
|
|
|
524
|
-
|
|
525
538
|
previous(): Promise<any> {
|
|
526
539
|
const CURRENT_ITEM = this.#currentSnapItem as FLib.DragSlider.Item;
|
|
527
540
|
|
|
528
|
-
if (
|
|
541
|
+
if (!this.#isDraggingActive || CURRENT_ITEM.isFirst) {
|
|
529
542
|
return Promise.resolve();
|
|
530
543
|
}
|
|
531
544
|
|
|
532
|
-
return this.#snapToItemAnimation(
|
|
545
|
+
return this.#snapToItemAnimation(
|
|
546
|
+
this.#itemArray[CURRENT_ITEM.index - 1]
|
|
547
|
+
);
|
|
533
548
|
}
|
|
534
549
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if ( !this.#isDraggingActive ) {
|
|
550
|
+
goToItem(blockOrIndex: HTMLElement | number): Promise<any> {
|
|
551
|
+
if (!this.#isDraggingActive) {
|
|
539
552
|
return Promise.resolve();
|
|
540
553
|
}
|
|
541
554
|
|
|
542
555
|
let $block;
|
|
543
556
|
|
|
544
|
-
if (typeof blockOrIndex ===
|
|
557
|
+
if (typeof blockOrIndex === "number") {
|
|
545
558
|
$block = this.#$items?.[blockOrIndex] as HTMLElement;
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
559
|
+
} else {
|
|
548
560
|
$block = blockOrIndex;
|
|
549
561
|
}
|
|
550
562
|
|
|
551
|
-
if (
|
|
563
|
+
if (!$block) {
|
|
552
564
|
return Promise.resolve();
|
|
553
565
|
}
|
|
554
566
|
|
|
555
|
-
const ITEM = this.#itemMap.get(
|
|
567
|
+
const ITEM = this.#itemMap.get($block);
|
|
556
568
|
|
|
557
|
-
if (
|
|
569
|
+
if (!ITEM) {
|
|
558
570
|
return Promise.resolve();
|
|
559
571
|
}
|
|
560
572
|
|
|
561
573
|
this.#currentSnapItem = ITEM;
|
|
562
574
|
|
|
563
|
-
this.#
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
this.#options.onSnapUpdate?.( {
|
|
577
|
-
"item": ITEM,
|
|
578
|
-
"xPos": this.#deltaMove.x,
|
|
579
|
-
"moveMaxSize": this.#listDelta,
|
|
580
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
581
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
582
|
-
"visibleItems": this.#visibleItems,
|
|
583
|
-
"hiddenItems": this.#hiddenItems
|
|
584
|
-
} );
|
|
585
|
-
}).then(() => this.#updateAccessibilityFeature());
|
|
575
|
+
const xPos = -1 * ITEM.info.left + this.#siteOffsetLeft;
|
|
576
|
+
|
|
577
|
+
this.#options.onSnap?.(this.#getCallbackOptions(xPos, ITEM));
|
|
578
|
+
|
|
579
|
+
return this.#options
|
|
580
|
+
._animMoveItem(this.#$list, xPos, (x) => {
|
|
581
|
+
this.#deltaMove.x = x;
|
|
582
|
+
|
|
583
|
+
this.#options.onSnapUpdate?.(
|
|
584
|
+
this.#getCallbackOptions(this.#deltaMove.x, ITEM)
|
|
585
|
+
);
|
|
586
|
+
})
|
|
587
|
+
.then(() => this.#updateAccessibilityFeature());
|
|
586
588
|
}
|
|
587
589
|
|
|
588
590
|
#updateAccessibilityFeature = (): void => {
|
|
589
591
|
this.#visibleItems.length = 0;
|
|
590
592
|
this.#hiddenItems.length = 0;
|
|
591
593
|
|
|
592
|
-
this.#itemMap.forEach(item => {
|
|
594
|
+
this.#itemMap.forEach((item) => {
|
|
593
595
|
const hideElement1 = item.info.left + this.#deltaMove.x < 0;
|
|
594
|
-
const hideElement2 =
|
|
596
|
+
const hideElement2 =
|
|
597
|
+
item.info.left + item.info.width + this.#deltaMove.x >
|
|
598
|
+
this.#viewportInfo.width;
|
|
595
599
|
|
|
596
600
|
if (hideElement1 || hideElement2) {
|
|
597
601
|
item.$item.setAttribute("tabindex", "-1");
|
|
@@ -606,132 +610,128 @@ export default class DragSlider {
|
|
|
606
610
|
item.$item.setAttribute("aria-hidden", "false");
|
|
607
611
|
this.#visibleItems.push(item);
|
|
608
612
|
});
|
|
609
|
-
}
|
|
613
|
+
};
|
|
610
614
|
|
|
611
615
|
refresh = (): this => {
|
|
612
616
|
this.#onResize();
|
|
613
617
|
|
|
614
618
|
return this;
|
|
615
|
-
}
|
|
619
|
+
};
|
|
616
620
|
|
|
617
621
|
init = (): this => {
|
|
618
|
-
if (
|
|
622
|
+
if (this.#isInitialized) {
|
|
619
623
|
return this;
|
|
620
624
|
}
|
|
621
625
|
|
|
622
626
|
this.#isInitialized = true;
|
|
623
627
|
|
|
624
|
-
if (
|
|
625
|
-
const $VP = this.#$slider.querySelector(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
+
if (!this.#$viewport) {
|
|
629
|
+
const $VP = this.#$slider.querySelector(
|
|
630
|
+
this.#options.viewportSelector
|
|
631
|
+
);
|
|
632
|
+
if (!$VP) {
|
|
633
|
+
throw `"${this.#options.viewportSelector}" not found`;
|
|
628
634
|
}
|
|
629
|
-
this.#$viewport
|
|
635
|
+
this.#$viewport = $VP as HTMLElement;
|
|
630
636
|
|
|
631
|
-
const $LST = this.#$viewport.querySelector(
|
|
632
|
-
|
|
633
|
-
|
|
637
|
+
const $LST = this.#$viewport.querySelector(
|
|
638
|
+
this.#options.listSelector
|
|
639
|
+
);
|
|
640
|
+
if (!$LST) {
|
|
641
|
+
throw `"${this.#options.listSelector}" not found`;
|
|
634
642
|
}
|
|
635
|
-
this.#$list
|
|
643
|
+
this.#$list = $LST as HTMLElement;
|
|
636
644
|
|
|
637
|
-
const $ITEMS = this.#$list.querySelectorAll(
|
|
638
|
-
|
|
639
|
-
|
|
645
|
+
const $ITEMS = this.#$list.querySelectorAll(
|
|
646
|
+
this.#options.itemSelector
|
|
647
|
+
);
|
|
648
|
+
if (!$ITEMS) {
|
|
649
|
+
throw `"${this.#options.itemSelector}" not found`;
|
|
640
650
|
}
|
|
641
|
-
this.#$items
|
|
651
|
+
this.#$items = $ITEMS as NodeList;
|
|
642
652
|
|
|
643
|
-
this.#debouncedOnResize = debounce(
|
|
653
|
+
this.#debouncedOnResize = debounce(this.#onResize);
|
|
644
654
|
}
|
|
645
655
|
|
|
646
|
-
if (
|
|
656
|
+
if (!this.#$items?.length) {
|
|
647
657
|
return this;
|
|
648
658
|
}
|
|
649
659
|
|
|
650
|
-
aClass(
|
|
660
|
+
aClass(this.#$slider, "is-active");
|
|
651
661
|
|
|
652
662
|
this.#onResize();
|
|
653
663
|
|
|
654
|
-
on(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
664
|
+
on(window, {
|
|
665
|
+
eventsName: "resize",
|
|
666
|
+
callback: this.#debouncedOnResize,
|
|
667
|
+
});
|
|
658
668
|
|
|
659
|
-
gesture(
|
|
660
|
-
|
|
661
|
-
}
|
|
669
|
+
gesture(this.#$viewport, "dragSlider", {
|
|
670
|
+
start: this.#onStartDrag,
|
|
671
|
+
});
|
|
662
672
|
|
|
663
673
|
// Avoid image or content drag on Firefox
|
|
664
|
-
on(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
on( this.#$viewport, {
|
|
670
|
-
"eventsName": "mouseenter",
|
|
671
|
-
"callback": this.#onMouseenter
|
|
672
|
-
} );
|
|
673
|
-
|
|
674
|
-
on( this.#$viewport, {
|
|
675
|
-
"eventsName": "mouseleave",
|
|
676
|
-
"callback": this.#onMouseleave
|
|
677
|
-
} );
|
|
678
|
-
|
|
679
|
-
this.#options.onInit?.( {
|
|
680
|
-
"item": this.#currentSnapItem,
|
|
681
|
-
"xPos": this.#deltaMove.x,
|
|
682
|
-
"moveMaxSize": this.#listDelta,
|
|
683
|
-
"isAtStart": this.#deltaMove.x === 0,
|
|
684
|
-
"isAtEnd": this.#deltaMove.x === this.#listDelta,
|
|
685
|
-
"visibleItems": this.#visibleItems,
|
|
686
|
-
"hiddenItems": this.#hiddenItems
|
|
687
|
-
} );
|
|
674
|
+
on(this.#$items, {
|
|
675
|
+
eventsName: "dragstart",
|
|
676
|
+
callback: this.#cancelDrag,
|
|
677
|
+
});
|
|
688
678
|
|
|
689
|
-
|
|
690
|
-
|
|
679
|
+
on(this.#$viewport, {
|
|
680
|
+
eventsName: "mouseenter",
|
|
681
|
+
callback: this.#onMouseenter,
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
on(this.#$viewport, {
|
|
685
|
+
eventsName: "mouseleave",
|
|
686
|
+
callback: this.#onMouseleave,
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
this.#options.onInit?.(this.#getCallbackOptions(this.#deltaMove.x));
|
|
691
690
|
|
|
691
|
+
return this;
|
|
692
|
+
};
|
|
692
693
|
|
|
693
694
|
destroy(): this {
|
|
694
|
-
this.#isInitialized
|
|
695
|
+
this.#isInitialized = false;
|
|
695
696
|
this.#hasAlreadyBeenDragged = false;
|
|
696
697
|
|
|
697
|
-
if (
|
|
698
|
+
if (!this.#$items?.length) {
|
|
698
699
|
return this;
|
|
699
700
|
}
|
|
700
701
|
|
|
701
|
-
off(
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
702
|
+
off(window, {
|
|
703
|
+
eventsName: "resize",
|
|
704
|
+
callback: this.#debouncedOnResize,
|
|
705
|
+
});
|
|
705
706
|
|
|
706
|
-
this.#$viewport && gestureOff(
|
|
707
|
+
this.#$viewport && gestureOff(this.#$viewport, "dragSlider");
|
|
707
708
|
|
|
708
|
-
gestureOff(
|
|
709
|
+
gestureOff(document.body, "dragSlider");
|
|
709
710
|
|
|
710
|
-
off(
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
711
|
+
off(this.#$items, {
|
|
712
|
+
eventsName: "dragstart",
|
|
713
|
+
callback: this.#cancelDrag,
|
|
714
|
+
});
|
|
714
715
|
|
|
715
|
-
off(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
716
|
+
off(this.#$viewport, {
|
|
717
|
+
eventsName: "mouseenter",
|
|
718
|
+
callback: this.#onMouseenter,
|
|
719
|
+
});
|
|
719
720
|
|
|
720
|
-
off(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}
|
|
721
|
+
off(this.#$viewport, {
|
|
722
|
+
eventsName: "mouseleave",
|
|
723
|
+
callback: this.#onMouseleave,
|
|
724
|
+
});
|
|
724
725
|
|
|
725
|
-
if (
|
|
726
|
-
this.#options._animKill(
|
|
727
|
-
this.#options._animClear(
|
|
726
|
+
if (this.#$list) {
|
|
727
|
+
this.#options._animKill(this.#$list);
|
|
728
|
+
this.#options._animClear(this.#$list);
|
|
728
729
|
}
|
|
729
730
|
|
|
730
|
-
this.#$viewport && rClass(
|
|
731
|
+
this.#$viewport && rClass(this.#$viewport, this.#options.dragClass);
|
|
731
732
|
|
|
732
|
-
rClass(
|
|
733
|
+
rClass(this.#$slider, "is-active");
|
|
733
734
|
|
|
734
735
|
return this;
|
|
735
736
|
}
|
|
736
|
-
|
|
737
737
|
}
|
package/Modules/YouTubePlayer.ts
CHANGED
|
@@ -106,7 +106,13 @@ export default class YouTubePlayer {
|
|
|
106
106
|
"width": this.#options.width,
|
|
107
107
|
"videoId": this.#options.videoId,
|
|
108
108
|
|
|
109
|
-
"playerVars": this.#options.playerVars
|
|
109
|
+
"playerVars": this.#options.playerVars,
|
|
110
|
+
|
|
111
|
+
"events": {
|
|
112
|
+
"onReady": () => {
|
|
113
|
+
_resolve( player );
|
|
114
|
+
}
|
|
115
|
+
}
|
|
110
116
|
} );
|
|
111
117
|
|
|
112
118
|
if ( this.#options.onPlayerStateChange ) {
|
|
@@ -118,8 +124,6 @@ export default class YouTubePlayer {
|
|
|
118
124
|
|
|
119
125
|
$wrapper.YTPlayer = player;
|
|
120
126
|
|
|
121
|
-
window.requestAnimationFrame( () => _resolve( player ) );
|
|
122
|
-
|
|
123
127
|
return promise;
|
|
124
128
|
}
|
|
125
129
|
|
package/README.md
CHANGED
package/Types/YouTubePlayer.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare namespace FLib {
|
|
|
9
9
|
* @defaultValue //www.youtube.com/iframe_api
|
|
10
10
|
*/
|
|
11
11
|
apiUrl: string;
|
|
12
|
-
onPlayerStateChange?:
|
|
12
|
+
onPlayerStateChange?: YT.PlayerEventHandler<YT.OnStateChangeEvent>;
|
|
13
13
|
/**
|
|
14
14
|
* @defaultValue `{ "autoplay": 0, "controls": 2, "autohide": 1, "modestbranding": 1, "showinfo": 0 }`
|
|
15
15
|
*/
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@creative-web-solution/front-library",
|
|
3
3
|
"title": "Frontend library",
|
|
4
4
|
"description": "Frontend functions and modules",
|
|
5
|
-
"version": "7.1.
|
|
5
|
+
"version": "7.1.29",
|
|
6
6
|
"homepage": "https://github.com/creative-web-solution/front-library",
|
|
7
7
|
"author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
|
|
8
8
|
"keywords": [],
|