@creative-web-solution/front-library 7.1.19 → 7.1.20
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 -362
- package/Helpers/TransitionHelpers.ts +8 -8
- package/Modules/DragSlider.ts +76 -73
- package/README.md +1 -1
- package/Types/DOM.d.ts +45 -21
- package/Types/DragSlider.d.ts +5 -0
- package/package.json +1 -1
- package/DOM/Matrix.ts +0 -142
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## 7.1.20
|
|
5
|
+
|
|
6
|
+
* Remove legacy Modernizr addons
|
|
7
|
+
* Add CSSTween feature
|
|
8
|
+
* [DragSlider] Refacto GSAP
|
|
9
|
+
|
|
10
|
+
|
|
4
11
|
## 7.1.19
|
|
5
12
|
|
|
6
13
|
* [DragSlider] Fix variable init in goToItem
|
|
7
14
|
|
|
15
|
+
|
|
8
16
|
## 7.1.18
|
|
9
17
|
|
|
10
18
|
* [DragSlider] Expose some properties + allow item index in goToItem function
|
|
11
19
|
|
|
20
|
+
|
|
12
21
|
## 7.1.17
|
|
13
22
|
|
|
14
23
|
* [DragSlider] Rework + add refresh function
|
|
15
24
|
|
|
25
|
+
|
|
16
26
|
## 7.1.16
|
|
17
27
|
|
|
18
28
|
* Fix doc
|
|
@@ -146,365 +156,3 @@
|
|
|
146
156
|
|
|
147
157
|
Move to TypeScript
|
|
148
158
|
|
|
149
|
-
|
|
150
|
-
## 6.2.5
|
|
151
|
-
|
|
152
|
-
* Slider: expose list of slide objects + expose page number for each slide
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
## 6.2.4
|
|
156
|
-
|
|
157
|
-
* Accordion: add an option to avoid closing all tabs
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
## 6.2.3
|
|
161
|
-
|
|
162
|
-
* Update DragSlider module
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
## 6.2.2
|
|
166
|
-
|
|
167
|
-
* Add DragSlider module
|
|
168
|
-
* Update touchdevice detection method
|
|
169
|
-
* Slider:
|
|
170
|
-
* Add function to start and stop auto slide
|
|
171
|
-
* Fix display when no loop and several slides per page
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
## 6.2.1
|
|
175
|
-
|
|
176
|
-
* Add a scope to the package name for NPM publish
|
|
177
|
-
* Update doc
|
|
178
|
-
* Add CSS custom variable Modernizr test
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
## 6.1.3
|
|
182
|
-
|
|
183
|
-
* Add CSS property setter/getter function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
## 6.1.2
|
|
187
|
-
|
|
188
|
-
* Fix event propagation on select skin button
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
## 6.1.1
|
|
192
|
-
|
|
193
|
-
* Handle idle state in "wait" function: `wait('idle').then(...)`
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
## 6.1.0
|
|
197
|
-
|
|
198
|
-
* General:
|
|
199
|
-
* Refactor
|
|
200
|
-
* Minor updates
|
|
201
|
-
* Cleanup
|
|
202
|
-
* Update Tweenlite 2.x to GSAP 3.x
|
|
203
|
-
|
|
204
|
-
* MediaQueriesEvents:
|
|
205
|
-
* Add `getValue` function
|
|
206
|
-
|
|
207
|
-
* ScrollSnap:
|
|
208
|
-
* Update Tweenlite 2.x to GSAP 3.x
|
|
209
|
-
* Move GSAP functions in options to override them and be able to use another library
|
|
210
|
-
|
|
211
|
-
* Slider:
|
|
212
|
-
* Update Tweenlite 2.x to GSAP 3.x
|
|
213
|
-
* Move GSAP functions in options to override them and be able to use another library
|
|
214
|
-
|
|
215
|
-
* Add new WegGL category
|
|
216
|
-
* Add GLImageTransition
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
## 6.0.16
|
|
220
|
-
|
|
221
|
-
* Autocomplete:
|
|
222
|
-
* Add resetField, resetResults and reset functions
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
## 6.0.15
|
|
226
|
-
|
|
227
|
-
* Helpers:
|
|
228
|
-
* Update debounce function
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
## 6.0.14
|
|
232
|
-
|
|
233
|
-
* SkinSelect:
|
|
234
|
-
* Fix item focus and scroll
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
## 6.0.13
|
|
238
|
-
|
|
239
|
-
* Autocomplete:
|
|
240
|
-
* Fix repeated query parameter
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
## 6.0.12
|
|
244
|
-
|
|
245
|
-
* Select skin
|
|
246
|
-
* Fix focus on load
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
## 6.0.11
|
|
250
|
-
|
|
251
|
-
* Autocomplete:
|
|
252
|
-
* Add `enable` and `disable` functions
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
## 6.0.10
|
|
256
|
-
|
|
257
|
-
* Validator:
|
|
258
|
-
* Change the default live validation event name on input text from 'change' to 'input'
|
|
259
|
-
* DOM:
|
|
260
|
-
* Minor updates
|
|
261
|
-
* The `wrap` function now can handle an HTMLElement as second parameters
|
|
262
|
-
* Autocomplete:
|
|
263
|
-
* Add a `showAll` function to display all items of the list in source mode.
|
|
264
|
-
* SkinSelect:
|
|
265
|
-
* Add keyboard feature
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
## 6.0.9
|
|
269
|
-
|
|
270
|
-
* Validator:
|
|
271
|
-
* Update email validation Regular Expression
|
|
272
|
-
* Add a loose one: Add data-loose on the input to use it
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
## 6.0.8
|
|
276
|
-
|
|
277
|
-
* DOM/Class:
|
|
278
|
-
* Handle array of css classes
|
|
279
|
-
* Add sClass function to replace a class by another
|
|
280
|
-
* Update extend and copy functions
|
|
281
|
-
* Update UrlParser
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
## 6.0.7
|
|
285
|
-
|
|
286
|
-
* Slider: Fix init options bug on `moveByPage` property
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
## 6.0.6
|
|
290
|
-
|
|
291
|
-
* Validator: Fix live validation on input hidden
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
## 6.0.5
|
|
295
|
-
|
|
296
|
-
* Add new Accordion module
|
|
297
|
-
* Add new Tabs module
|
|
298
|
-
* Select element skin
|
|
299
|
-
* Update the updateOptions function
|
|
300
|
-
* Add setValid/setInvalid function
|
|
301
|
-
* Add function to compute the distance between 2 coordinates
|
|
302
|
-
* Rename history to HistoryController
|
|
303
|
-
* Update input file skin
|
|
304
|
-
* Add quick template module
|
|
305
|
-
* ScrollSnap: Fix bug which occurs when you just tap into the element without moving
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
## 6.0.4
|
|
309
|
-
|
|
310
|
-
* Select element skin
|
|
311
|
-
* Improve init when skin elements already exist in the DOM
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
## 6.0.3
|
|
315
|
-
|
|
316
|
-
* Popin
|
|
317
|
-
* Add function to programmatically open and close the loading layer
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
## 6.0.2
|
|
321
|
-
|
|
322
|
-
* Validator
|
|
323
|
-
* Add live validation system
|
|
324
|
-
* Add getQueryFromForm function
|
|
325
|
-
* Update validator scaffolding. Split everything that was in `import { validatorTools } from '@creative-web-solution/front-library/Modules/Validator';` in the `@creative-web-solution/front-library/Modules/Validator/Tools` folder.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
## 6.0.1
|
|
329
|
-
|
|
330
|
-
* Add notification module
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
## 6.0.0
|
|
334
|
-
|
|
335
|
-
**Not compatible with 5.x.x version**
|
|
336
|
-
|
|
337
|
-
* Remove builder
|
|
338
|
-
* Remove dependencies system to use classic JS `import` instead
|
|
339
|
-
* Add function to export in `front-library` project hosted on GitHub
|
|
340
|
-
* General files and folders renaming
|
|
341
|
-
|
|
342
|
-
### ScrollSnap
|
|
343
|
-
|
|
344
|
-
* Add new refresh options
|
|
345
|
-
|
|
346
|
-
### Mediaqueries events
|
|
347
|
-
|
|
348
|
-
* Add `on` and `off` function to bind specific breakpoint
|
|
349
|
-
|
|
350
|
-
### EventsManager
|
|
351
|
-
|
|
352
|
-
* Fix the auto unbind of the `one` function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
## 5.2.14
|
|
356
|
-
|
|
357
|
-
* Fix SnapScroll bug
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
## 5.2.13
|
|
361
|
-
|
|
362
|
-
* Add IntersectObserver
|
|
363
|
-
|
|
364
|
-
### Validator
|
|
365
|
-
|
|
366
|
-
* Change `getRadioList` second paramater to an object with 2 properties: `selector` and `othersOnly`
|
|
367
|
-
* Add the property `$otherRadioOfGroup` to Input object
|
|
368
|
-
|
|
369
|
-
### Mediaqueries events
|
|
370
|
-
|
|
371
|
-
* Remove parameter `callbackOnQuit`
|
|
372
|
-
* Add the possibility to call function when entering, leaving a mediaquery or on both
|
|
373
|
-
* Add 3 static properties: `MediaQueriesEvents.TYPE_ON_ENTER` , `MediaQueriesEvents.TYPE_ON_LEAVE` and `MediaQueriesEvents.TYPE_ON_BOTH`
|
|
374
|
-
* Add a new optional parameter `type` on `register` function wich accept on of the 3 static properties. By default, it's set to `MediaQueriesEvents.TYPE_ON_ENTER`
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
## 5.2.12
|
|
378
|
-
|
|
379
|
-
* Add dependencies
|
|
380
|
-
* Update documentation
|
|
381
|
-
|
|
382
|
-
### Validator
|
|
383
|
-
|
|
384
|
-
* Rename validator tools function: `getAllGroup` ==> `getRadioList`, `isRadioGroupChecked` ==> `isRadioListChecked`
|
|
385
|
-
* `getLabel` function now return a string or an array of string
|
|
386
|
-
* Add new function `getLabelElement` to return label HTMLElement or an array of HTMLElement
|
|
387
|
-
|
|
388
|
-
### Window events
|
|
389
|
-
|
|
390
|
-
* Add new `viewportInfo` property
|
|
391
|
-
* Rename property: `scrollPosition` ==> `scrollInfo`, `windowSize` ==> `windowInfo`, `documentSize` ==> `documentInfo`
|
|
392
|
-
* Change callback function signature: `(windowSize, documentSize, scrollPosition, eventName) => {}` ==> `({windowInfo, documentInfo, scrollInfo, viewportInfo}, eventName, originalEvent) => {}`
|
|
393
|
-
|
|
394
|
-
### History controller
|
|
395
|
-
|
|
396
|
-
* Remove `getState` function and replace it by `state` property.
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
## 5.2.11
|
|
400
|
-
|
|
401
|
-
* Fix gesture callback target
|
|
402
|
-
|
|
403
|
-
### Mediaqueries events
|
|
404
|
-
|
|
405
|
-
* Add new properties (`currentBreakpoint`, `list`) and deprecate some functions
|
|
406
|
-
* Add a new way of initialize breakpoint objects (`min` and `max` instead of `query`)
|
|
407
|
-
* Add new `unit` options
|
|
408
|
-
|
|
409
|
-
### Window events
|
|
410
|
-
|
|
411
|
-
* Add new properties (scroll, windowSize, documentSize) and deprecate some functions
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
## 5.2.10
|
|
415
|
-
|
|
416
|
-
* Custom events: Fix DOM elements handling
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
## 5.2.9
|
|
420
|
-
|
|
421
|
-
* Popin: Allow manual handle of http error
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
## 5.2.8
|
|
425
|
-
|
|
426
|
-
* fetch: Add X-Requested-With header to fetch calls
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
## 5.2.7
|
|
430
|
-
|
|
431
|
-
* Gesture: Fix preventDefault and stopPropagation functions
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
## 5.2.6
|
|
435
|
-
|
|
436
|
-
* Update UrlParser: Convert non string value, add `getParam` function.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
## 5.2.5
|
|
440
|
-
|
|
441
|
-
* Add `cssPositionning` option
|
|
442
|
-
* Fix Autocomplete variable name in the select function
|
|
443
|
-
* Fix click on items
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
## 5.2.4
|
|
447
|
-
|
|
448
|
-
* Fix AbortController support test
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
## 5.2.3
|
|
452
|
-
|
|
453
|
-
* Improve Scroll Snap
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
## 5.2.2
|
|
457
|
-
|
|
458
|
-
* Update Scroll Snap
|
|
459
|
-
* Add color helper
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
## 5.2.1
|
|
463
|
-
|
|
464
|
-
* Remove native polyfill. Use Symfony polyfill package instead.
|
|
465
|
-
* Allow to define gesture options on slider controls
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
## 5.2.0
|
|
469
|
-
|
|
470
|
-
* Replace Reqwest dependency with window.fetch
|
|
471
|
-
* Replace Bean dependency with custom event manager
|
|
472
|
-
* Remove mousewheel event manager. Use the on('wheel', ...) function from the event manager
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
## 5.1.5
|
|
476
|
-
|
|
477
|
-
* Fix extend function
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
## 5.1.4
|
|
481
|
-
|
|
482
|
-
* Fix options in gesture module
|
|
483
|
-
* Fix scroll snap module
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
## 5.1.2
|
|
487
|
-
|
|
488
|
-
* Update gesture callbacks name
|
|
489
|
-
* touchstart => start
|
|
490
|
-
* touchmove => move
|
|
491
|
-
* touchend => end
|
|
492
|
-
* Update gesture prevent default and stop propagation functions name
|
|
493
|
-
* preventTouchstart => preventStart
|
|
494
|
-
* stopPropagationTouchstart => stopPropagationStart
|
|
495
|
-
* preventTouchmove => preventMove
|
|
496
|
-
* stopPropagationTouchmove => stopPropagationMove
|
|
497
|
-
* preventTouchend => preventEnd
|
|
498
|
-
* stopPropagationTouchend => stopPropagationEnd
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
## 5.1.1
|
|
502
|
-
|
|
503
|
-
* Fix google map multiple call + typo
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
## 5.1.0
|
|
507
|
-
|
|
508
|
-
* Add new polyfill (Element.append, ...)
|
|
509
|
-
* Add JSDoc
|
|
510
|
-
* Add has-localstorage helper
|
|
@@ -6,13 +6,13 @@ import { wait } from './Wait';
|
|
|
6
6
|
const KEY = Symbol( 'TransitionHelper' );
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
function addWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement ) => (Promise<void> | any ), isAnimation: boolean, options: { delay?: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both',
|
|
9
|
+
function addWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement ) => (Promise<void> | any ), isAnimation: boolean, options: { delay?: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both', properties?: string[], animationName?: string[] } = {} ): Promise<HTMLElement> {
|
|
10
10
|
if ( $element[ KEY ] ) {
|
|
11
11
|
$element[ KEY ].off();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
if ( typeof options.delay !==
|
|
15
|
-
options.delay = 'idle'
|
|
14
|
+
if ( typeof options.delay !== 'number' && options.delay !== 'idle') {
|
|
15
|
+
options.delay = 'idle';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
$element[ KEY ] = isAnimation ?
|
|
@@ -21,17 +21,17 @@ function addWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement
|
|
|
21
21
|
"pseudoElement": options.pseudoElement
|
|
22
22
|
} ) :
|
|
23
23
|
onTransitionEnd( $element, {
|
|
24
|
-
"property": options.
|
|
24
|
+
"property": options.properties,
|
|
25
25
|
"pseudoElement": options.pseudoElement
|
|
26
26
|
} );
|
|
27
27
|
|
|
28
|
-
wait( options.delay ).then( () => styleChange( $element ) );
|
|
29
|
-
|
|
30
28
|
$element[ KEY ].then( () => {
|
|
31
29
|
$element[ KEY ] = null;
|
|
32
30
|
return $element;
|
|
33
31
|
} );
|
|
34
32
|
|
|
33
|
+
wait( options.delay ).then( () => styleChange( $element ) );
|
|
34
|
+
|
|
35
35
|
return $element[ KEY ];
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -54,7 +54,7 @@ function addWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement
|
|
|
54
54
|
* } );
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
export function transitionWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement ) => (Promise<void> | any ), options?: { delay
|
|
57
|
+
export function transitionWatcher( $element: HTMLElement, styleChange: ( $element: HTMLElement ) => (Promise<void> | any ), options?: { delay?: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both', properties?: string[], animationName?: string[] } ): Promise<HTMLElement> {
|
|
58
58
|
return addWatcher( $element, styleChange, false, options );
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -77,7 +77,7 @@ export function transitionWatcher( $element: HTMLElement, styleChange: ( $elemen
|
|
|
77
77
|
* } );
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
export function animationWatcher( $element: HTMLElement, animationStart: ( $element: HTMLElement ) => (Promise<void> | any ), options?: { delay
|
|
80
|
+
export function animationWatcher( $element: HTMLElement, animationStart: ( $element: HTMLElement ) => (Promise<void> | any ), options?: { delay?: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both', animationName?: string[] } ): Promise<HTMLElement> {
|
|
81
81
|
return addWatcher( $element, animationStart, true, options );
|
|
82
82
|
}
|
|
83
83
|
|
package/Modules/DragSlider.ts
CHANGED
|
@@ -6,8 +6,46 @@ import { prop } from '../DOM/Styles';
|
|
|
6
6
|
import { aClass, rClass, tClass } from '../DOM/Class';
|
|
7
7
|
import { on, off } from '../Events/EventsManager';
|
|
8
8
|
import { isTouchDevice } from '../Tools/TouchDeviceSupport';
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import { extend } from '../Helpers/Extend';
|
|
10
|
+
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
swipeTresholdMin: 40,
|
|
13
|
+
swipeTresholdSize: 0.5,
|
|
14
|
+
lockedClass: 'is-locked',
|
|
15
|
+
_animReset: function($list) {
|
|
16
|
+
gsap.set( $list, {
|
|
17
|
+
"x": 0,
|
|
18
|
+
"y": 0,
|
|
19
|
+
"z": 0
|
|
20
|
+
} );
|
|
21
|
+
},
|
|
22
|
+
_animClear: function($list) {
|
|
23
|
+
gsap.set( $list, {
|
|
24
|
+
"clearProps": "all"
|
|
25
|
+
} );
|
|
26
|
+
},
|
|
27
|
+
_animKill: function($list) {
|
|
28
|
+
gsap.killTweensOf( $list );
|
|
29
|
+
},
|
|
30
|
+
_animMoveItem: function($list, x, onUpdate) {
|
|
31
|
+
return gsap.to( $list, {
|
|
32
|
+
"duration": 0.3,
|
|
33
|
+
"x": x,
|
|
34
|
+
"y": 0,
|
|
35
|
+
"z": 0,
|
|
36
|
+
"onUpdate": function() {
|
|
37
|
+
onUpdate(gsap.getProperty( this.targets()[ 0 ], 'x' ));
|
|
38
|
+
}
|
|
39
|
+
} );
|
|
40
|
+
},
|
|
41
|
+
_setCoordinates: function($list, x) {
|
|
42
|
+
gsap.set( $list, {
|
|
43
|
+
"x": x,
|
|
44
|
+
"y": 0,
|
|
45
|
+
"z": 0
|
|
46
|
+
} );
|
|
47
|
+
}
|
|
48
|
+
}
|
|
11
49
|
|
|
12
50
|
/**
|
|
13
51
|
* DragSlider
|
|
@@ -56,9 +94,9 @@ export default class DragSlider {
|
|
|
56
94
|
}
|
|
57
95
|
|
|
58
96
|
|
|
59
|
-
constructor( $slider: HTMLElement,
|
|
97
|
+
constructor( $slider: HTMLElement, userOptions: Partial<FLib.DragSlider.Options> ) {
|
|
60
98
|
|
|
61
|
-
if ( !
|
|
99
|
+
if ( !userOptions.viewportSelector || !userOptions.listSelector || !userOptions.itemSelector || !userOptions.dragClass ) {
|
|
62
100
|
throw '[Drag Slider]: Missing at least one of viewportSelector, listSelector, itemSelector, dragClass';
|
|
63
101
|
}
|
|
64
102
|
|
|
@@ -66,11 +104,7 @@ export default class DragSlider {
|
|
|
66
104
|
|
|
67
105
|
this.#isDraggingActive = false;
|
|
68
106
|
|
|
69
|
-
this.#options =
|
|
70
|
-
|
|
71
|
-
this.#options.swipeTresholdMin = options.swipeTresholdMin || 40;
|
|
72
|
-
this.#options.swipeTresholdSize = options.swipeTresholdSize || 0.5;
|
|
73
|
-
this.#options.lockedClass = options.lockedClass || 'is-locked';
|
|
107
|
+
this.#options = extend( defaultOptions, userOptions );
|
|
74
108
|
|
|
75
109
|
this.#itemArray = [];
|
|
76
110
|
|
|
@@ -95,8 +129,6 @@ export default class DragSlider {
|
|
|
95
129
|
return;
|
|
96
130
|
}
|
|
97
131
|
|
|
98
|
-
const LAST_INDEX = this.#$items.length - 1;
|
|
99
|
-
|
|
100
132
|
this.#viewportInfo = offset( this.#$viewport as HTMLElement );
|
|
101
133
|
this.#siteOffsetLeft = parseInt( prop( (this.#$items[ 0 ] as HTMLElement), 'marginLeft' ), 10 );
|
|
102
134
|
|
|
@@ -107,12 +139,8 @@ export default class DragSlider {
|
|
|
107
139
|
|
|
108
140
|
if ( !this.#isDraggingActive ) {
|
|
109
141
|
this.#isDragging = false;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"x": 0,
|
|
113
|
-
"y": 0,
|
|
114
|
-
"z": 0
|
|
115
|
-
} );
|
|
142
|
+
this.#options._animKill( this.#$list );
|
|
143
|
+
this.#options._animReset( this.#$list );
|
|
116
144
|
}
|
|
117
145
|
|
|
118
146
|
tClass( this.#$slider, this.#options.lockedClass, !this.#isDraggingActive );
|
|
@@ -168,8 +196,7 @@ export default class DragSlider {
|
|
|
168
196
|
}
|
|
169
197
|
|
|
170
198
|
|
|
171
|
-
#snapToItemAnimation = ( snapItem: FLib.DragSlider.Item ):
|
|
172
|
-
|
|
199
|
+
#snapToItemAnimation = ( snapItem: FLib.DragSlider.Item ): Promise<any> | void => {
|
|
173
200
|
if (!snapItem) {
|
|
174
201
|
return;
|
|
175
202
|
}
|
|
@@ -203,26 +230,17 @@ export default class DragSlider {
|
|
|
203
230
|
|
|
204
231
|
this.#currentSnapItem = snapItem;
|
|
205
232
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"x": finalX,
|
|
209
|
-
"y": 0,
|
|
210
|
-
"z": 0,
|
|
211
|
-
"onUpdateParams": [ this ],
|
|
212
|
-
"onUpdate": function( ctx ) {
|
|
213
|
-
ctx.#deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' ) as number;
|
|
214
|
-
|
|
215
|
-
ctx.#options.onSnapUpdate?.( {
|
|
216
|
-
"item": snapItem,
|
|
217
|
-
"xPos": ctx.#deltaMove.x,
|
|
218
|
-
"moveMaxSize": ctx.#listDelta,
|
|
219
|
-
"isAtStart": IS_SNAP_TO_START,
|
|
220
|
-
"isAtEnd": IS_SNAP_TO_END
|
|
221
|
-
} );
|
|
222
|
-
}
|
|
223
|
-
} );
|
|
233
|
+
return this.#options._animMoveItem( this.#$list, finalX, (newX) => {
|
|
234
|
+
this.#deltaMove.x = newX;
|
|
224
235
|
|
|
225
|
-
|
|
236
|
+
this.#options.onSnapUpdate?.( {
|
|
237
|
+
"item": snapItem,
|
|
238
|
+
"xPos": this.#deltaMove.x,
|
|
239
|
+
"moveMaxSize": this.#listDelta,
|
|
240
|
+
"isAtStart": IS_SNAP_TO_START,
|
|
241
|
+
"isAtEnd": IS_SNAP_TO_END
|
|
242
|
+
} );
|
|
243
|
+
} );
|
|
226
244
|
}
|
|
227
245
|
|
|
228
246
|
|
|
@@ -247,7 +265,7 @@ export default class DragSlider {
|
|
|
247
265
|
|
|
248
266
|
|
|
249
267
|
#getFirstNextItem = ( xPos: number ): { snapItem: FLib.DragSlider.Item, snapToEnd: boolean } => {
|
|
250
|
-
let
|
|
268
|
+
let snapItem;
|
|
251
269
|
|
|
252
270
|
const absXPos = Math.abs( xPos );
|
|
253
271
|
|
|
@@ -256,7 +274,6 @@ export default class DragSlider {
|
|
|
256
274
|
continue;
|
|
257
275
|
}
|
|
258
276
|
|
|
259
|
-
lastDelta = Math.abs( absXPos - item.info.left );
|
|
260
277
|
snapItem = item;
|
|
261
278
|
break;
|
|
262
279
|
}
|
|
@@ -328,10 +345,11 @@ export default class DragSlider {
|
|
|
328
345
|
|
|
329
346
|
this.#isDragging = true;
|
|
330
347
|
|
|
331
|
-
|
|
348
|
+
this.#options._animKill( this.#$list );
|
|
332
349
|
|
|
333
350
|
this.#startDragCoords = coords;
|
|
334
351
|
this.#listDelta = this.#viewportInfo.width - this.#$list.scrollWidth;
|
|
352
|
+
this.#deltaMove.newX = this.#deltaMove.x;
|
|
335
353
|
|
|
336
354
|
gesture( document.body, 'dragSlider', {
|
|
337
355
|
"move": this.#onMove,
|
|
@@ -371,11 +389,7 @@ export default class DragSlider {
|
|
|
371
389
|
this.#deltaMove.newX = this.#listDelta;
|
|
372
390
|
}
|
|
373
391
|
|
|
374
|
-
|
|
375
|
-
"x": this.#deltaMove.newX,
|
|
376
|
-
"y": 0,
|
|
377
|
-
"z": 0
|
|
378
|
-
} );
|
|
392
|
+
this.#options._setCoordinates(this.#$list, this.#deltaMove.newX);
|
|
379
393
|
|
|
380
394
|
this.#options.onDrag?.( {
|
|
381
395
|
"item": this.#currentSnapItem,
|
|
@@ -443,7 +457,7 @@ export default class DragSlider {
|
|
|
443
457
|
}
|
|
444
458
|
|
|
445
459
|
|
|
446
|
-
next():
|
|
460
|
+
next(): Promise<any> | void {
|
|
447
461
|
const CURRENT_ITEM = this.#currentSnapItem as FLib.DragSlider.Item;
|
|
448
462
|
|
|
449
463
|
if ( !this.#isDraggingActive || !this.#itemArray[ CURRENT_ITEM.index + 1 ] ) {
|
|
@@ -454,7 +468,7 @@ export default class DragSlider {
|
|
|
454
468
|
}
|
|
455
469
|
|
|
456
470
|
|
|
457
|
-
previous():
|
|
471
|
+
previous(): Promise<any> | void {
|
|
458
472
|
const CURRENT_ITEM = this.#currentSnapItem as FLib.DragSlider.Item;
|
|
459
473
|
|
|
460
474
|
if ( !this.#isDraggingActive || CURRENT_ITEM.isFirst ) {
|
|
@@ -465,7 +479,7 @@ export default class DragSlider {
|
|
|
465
479
|
}
|
|
466
480
|
|
|
467
481
|
|
|
468
|
-
goToItem( blockOrIndex: HTMLElement | number ):
|
|
482
|
+
goToItem( blockOrIndex: HTMLElement | number ): Promise<any> | void {
|
|
469
483
|
|
|
470
484
|
if ( !this.#isDraggingActive ) {
|
|
471
485
|
return;
|
|
@@ -500,25 +514,17 @@ export default class DragSlider {
|
|
|
500
514
|
"isAtEnd": this.#deltaMove.x === this.#listDelta
|
|
501
515
|
} );
|
|
502
516
|
|
|
503
|
-
return
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
"item": ITEM,
|
|
515
|
-
"xPos": ctx.#deltaMove.x,
|
|
516
|
-
"moveMaxSize": ctx.#listDelta,
|
|
517
|
-
"isAtStart": ctx.#deltaMove.x === 0,
|
|
518
|
-
"isAtEnd": ctx.#deltaMove.x === ctx.#listDelta
|
|
519
|
-
} );
|
|
520
|
-
}
|
|
521
|
-
} );
|
|
517
|
+
return this.#options._animMoveItem(this.#$list, -1 * ITEM.info.left + this.#siteOffsetLeft, (x) => {
|
|
518
|
+
this.#deltaMove.x = x;
|
|
519
|
+
|
|
520
|
+
this.#options.onSnapUpdate?.( {
|
|
521
|
+
"item": ITEM,
|
|
522
|
+
"xPos": this.#deltaMove.x,
|
|
523
|
+
"moveMaxSize": this.#listDelta,
|
|
524
|
+
"isAtStart": this.#deltaMove.x === 0,
|
|
525
|
+
"isAtEnd": this.#deltaMove.x === this.#listDelta
|
|
526
|
+
} );
|
|
527
|
+
});
|
|
522
528
|
}
|
|
523
529
|
|
|
524
530
|
refresh = (): this => {
|
|
@@ -634,11 +640,8 @@ export default class DragSlider {
|
|
|
634
640
|
} );
|
|
635
641
|
|
|
636
642
|
if ( this.#$list ) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
gsap.set( this.#$list, {
|
|
640
|
-
"clearProps": "all"
|
|
641
|
-
} );
|
|
643
|
+
this.#options._animKill( this.#$list );
|
|
644
|
+
this.#options._animClear( this.#$list );
|
|
642
645
|
}
|
|
643
646
|
|
|
644
647
|
this.#$viewport && rClass( this.#$viewport, this.#options.dragClass );
|
package/README.md
CHANGED
package/Types/DOM.d.ts
CHANGED
|
@@ -29,13 +29,54 @@ declare namespace FLib {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
namespace Matrix {
|
|
32
|
+
type Matrix3D = {
|
|
33
|
+
a1: number;
|
|
34
|
+
b1: number;
|
|
35
|
+
c1: number;
|
|
36
|
+
d1: number;
|
|
37
|
+
a2: number;
|
|
38
|
+
b2: number;
|
|
39
|
+
c2: number;
|
|
40
|
+
d2: number;
|
|
41
|
+
a3: number;
|
|
42
|
+
b3: number;
|
|
43
|
+
c3: number;
|
|
44
|
+
d3: number;
|
|
45
|
+
a4: number;
|
|
46
|
+
b4: number;
|
|
47
|
+
c4: number;
|
|
48
|
+
d4: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type Matrix2D = {
|
|
52
|
+
a1: number;
|
|
53
|
+
b1: number;
|
|
54
|
+
c1: number;
|
|
55
|
+
a2: number;
|
|
56
|
+
b2: number;
|
|
57
|
+
c2: number;
|
|
58
|
+
a3: number;
|
|
59
|
+
b3: number;
|
|
60
|
+
c3: number;
|
|
61
|
+
}
|
|
32
62
|
|
|
33
|
-
type
|
|
63
|
+
type Translation = {
|
|
34
64
|
tx: number;
|
|
35
65
|
ty: number;
|
|
36
66
|
tz: number;
|
|
37
67
|
}
|
|
38
68
|
|
|
69
|
+
type Rotation = {
|
|
70
|
+
rx: number;
|
|
71
|
+
ry: number;
|
|
72
|
+
rz: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type Scale = {
|
|
76
|
+
sx: number;
|
|
77
|
+
sy: number;
|
|
78
|
+
sz: number;
|
|
79
|
+
}
|
|
39
80
|
|
|
40
81
|
type Transform = {
|
|
41
82
|
tx: number;
|
|
@@ -44,26 +85,9 @@ declare namespace FLib {
|
|
|
44
85
|
rx: number;
|
|
45
86
|
ry: number;
|
|
46
87
|
rz: number;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
type Matrix = {
|
|
51
|
-
m11: number;
|
|
52
|
-
m21: number;
|
|
53
|
-
m31: number;
|
|
54
|
-
m41: number;
|
|
55
|
-
m12: number;
|
|
56
|
-
m22: number;
|
|
57
|
-
m32: number;
|
|
58
|
-
m42: number;
|
|
59
|
-
m13: number;
|
|
60
|
-
m23: number;
|
|
61
|
-
m33: number;
|
|
62
|
-
m43: number;
|
|
63
|
-
m14: number;
|
|
64
|
-
m24: number;
|
|
65
|
-
m34: number;
|
|
66
|
-
m44: number;
|
|
88
|
+
sx: number;
|
|
89
|
+
sy: number;
|
|
90
|
+
sz: number;
|
|
67
91
|
}
|
|
68
92
|
}
|
|
69
93
|
}
|
package/Types/DragSlider.d.ts
CHANGED
|
@@ -51,6 +51,11 @@ declare namespace FLib {
|
|
|
51
51
|
* @defaultValue 0.5
|
|
52
52
|
*/
|
|
53
53
|
swipeTresholdSize:number;
|
|
54
|
+
_animReset: ($list) => void;
|
|
55
|
+
_animClear: ($list) => void;
|
|
56
|
+
_animKill: ($list) => void;
|
|
57
|
+
_animMoveItem: ($list, x, onUpdate) => Promise<any> | void;
|
|
58
|
+
_setCoordinates: ($list, x) => void;
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
}
|
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.20",
|
|
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": [],
|
package/DOM/Matrix.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { prop } from './Styles';
|
|
2
|
-
import { transformPropertyName } from '../Tools/PrefixedProperties';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the matrix of a DOM element
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* { m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44 } = getMatrix ( $elem )
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @returns the translate properties
|
|
13
|
-
*/
|
|
14
|
-
export function getMatrix( $elem: Element ): FLib.Matrix.Matrix {
|
|
15
|
-
let matrix: FLib.Matrix.Matrix;
|
|
16
|
-
|
|
17
|
-
const matrixString = prop( $elem, transformPropertyName );
|
|
18
|
-
const c = matrixString.split( /\s*[(),]\s*/ ).slice( 1, -1 );
|
|
19
|
-
|
|
20
|
-
if ( c.length === 6 ) {
|
|
21
|
-
// 'matrix()' (3x2)
|
|
22
|
-
matrix = {
|
|
23
|
-
"m11": +c[ 0 ],
|
|
24
|
-
"m21": +c[ 2 ],
|
|
25
|
-
"m31": 0,
|
|
26
|
-
"m41": +c[ 4 ],
|
|
27
|
-
"m12": +c[ 1 ],
|
|
28
|
-
"m22": +c[ 3 ],
|
|
29
|
-
"m32": 0,
|
|
30
|
-
"m42": +c[ 5 ],
|
|
31
|
-
"m13": 0,
|
|
32
|
-
"m23": 0,
|
|
33
|
-
"m33": 1,
|
|
34
|
-
"m43": 0,
|
|
35
|
-
"m14": 0,
|
|
36
|
-
"m24": 0,
|
|
37
|
-
"m34": 0,
|
|
38
|
-
"m44": 1
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
else if ( c.length === 16 ) {
|
|
42
|
-
// matrix3d() (4x4)
|
|
43
|
-
matrix = {
|
|
44
|
-
"m11": +c[ 0 ],
|
|
45
|
-
"m21": +c[ 4 ],
|
|
46
|
-
"m31": +c[ 8 ],
|
|
47
|
-
"m41": +c[ 12 ],
|
|
48
|
-
"m12": +c[ 1 ],
|
|
49
|
-
"m22": +c[ 5 ],
|
|
50
|
-
"m32": +c[ 9 ],
|
|
51
|
-
"m42": +c[ 13 ],
|
|
52
|
-
"m13": +c[ 2 ],
|
|
53
|
-
"m23": +c[ 6 ],
|
|
54
|
-
"m33": +c[ 10 ],
|
|
55
|
-
"m43": +c[ 14 ],
|
|
56
|
-
"m14": +c[ 3 ],
|
|
57
|
-
"m24": +c[ 7 ],
|
|
58
|
-
"m34": +c[ 11 ],
|
|
59
|
-
"m44": +c[ 15 ]
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// handle 'none' or invalid values.
|
|
64
|
-
matrix = {
|
|
65
|
-
"m11": 1,
|
|
66
|
-
"m21": 0,
|
|
67
|
-
"m31": 0,
|
|
68
|
-
"m41": 0,
|
|
69
|
-
"m12": 0,
|
|
70
|
-
"m22": 1,
|
|
71
|
-
"m32": 0,
|
|
72
|
-
"m42": 0,
|
|
73
|
-
"m13": 0,
|
|
74
|
-
"m23": 0,
|
|
75
|
-
"m33": 1,
|
|
76
|
-
"m43": 0,
|
|
77
|
-
"m14": 0,
|
|
78
|
-
"m24": 0,
|
|
79
|
-
"m34": 0,
|
|
80
|
-
"m44": 1
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return matrix;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get the translation values of a DOM element
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* { tx, ty, tz } = getTranslate ( $elem )
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
* @returns the translate properties
|
|
97
|
-
*/
|
|
98
|
-
export function getTranslate( $elem: Element ): FLib.Matrix.Translate {
|
|
99
|
-
const matrix: FLib.Matrix.Matrix = getMatrix( $elem );
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
"tx": matrix.m41,
|
|
103
|
-
"ty": matrix.m42,
|
|
104
|
-
"tz": matrix.m43
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get the transform values of a DOM element
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* { tx, ty, tz, rx, ry, rz } = getTransform ( $elem )
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @returns the transform properties
|
|
118
|
-
*/
|
|
119
|
-
export function getTransform( $elem: Element ): FLib.Matrix.Transform {
|
|
120
|
-
let rotateX: number, rotateZ: number;
|
|
121
|
-
|
|
122
|
-
const matrix: FLib.Matrix.Matrix = getMatrix( $elem );
|
|
123
|
-
const rotateY: number = Math.asin( -matrix.m13 );
|
|
124
|
-
|
|
125
|
-
if ( Math.cos(rotateY) !== 0 ) {
|
|
126
|
-
rotateX = Math.atan2( matrix.m23, matrix.m33 );
|
|
127
|
-
rotateZ = Math.atan2( matrix.m12, matrix.m11 );
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
rotateX = Math.atan2( -matrix.m31, matrix.m22 );
|
|
131
|
-
rotateZ = 0
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
"rx": rotateX,
|
|
136
|
-
"ry": rotateY,
|
|
137
|
-
"rz": rotateZ,
|
|
138
|
-
"tx": matrix.m41,
|
|
139
|
-
"ty": matrix.m42,
|
|
140
|
-
"tz": matrix.m43
|
|
141
|
-
};
|
|
142
|
-
}
|