@creative-web-solution/front-library 7.1.18 → 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 CHANGED
@@ -1,13 +1,28 @@
1
1
  # CHANGELOG
2
2
 
3
+
4
+ ## 7.1.20
5
+
6
+ * Remove legacy Modernizr addons
7
+ * Add CSSTween feature
8
+ * [DragSlider] Refacto GSAP
9
+
10
+
11
+ ## 7.1.19
12
+
13
+ * [DragSlider] Fix variable init in goToItem
14
+
15
+
3
16
  ## 7.1.18
4
17
 
5
18
  * [DragSlider] Expose some properties + allow item index in goToItem function
6
19
 
20
+
7
21
  ## 7.1.17
8
22
 
9
23
  * [DragSlider] Rework + add refresh function
10
24
 
25
+
11
26
  ## 7.1.16
12
27
 
13
28
  * Fix doc
@@ -141,365 +156,3 @@
141
156
 
142
157
  Move to TypeScript
143
158
 
144
-
145
- ## 6.2.5
146
-
147
- * Slider: expose list of slide objects + expose page number for each slide
148
-
149
-
150
- ## 6.2.4
151
-
152
- * Accordion: add an option to avoid closing all tabs
153
-
154
-
155
- ## 6.2.3
156
-
157
- * Update DragSlider module
158
-
159
-
160
- ## 6.2.2
161
-
162
- * Add DragSlider module
163
- * Update touchdevice detection method
164
- * Slider:
165
- * Add function to start and stop auto slide
166
- * Fix display when no loop and several slides per page
167
-
168
-
169
- ## 6.2.1
170
-
171
- * Add a scope to the package name for NPM publish
172
- * Update doc
173
- * Add CSS custom variable Modernizr test
174
-
175
-
176
- ## 6.1.3
177
-
178
- * Add CSS property setter/getter function
179
-
180
-
181
- ## 6.1.2
182
-
183
- * Fix event propagation on select skin button
184
-
185
-
186
- ## 6.1.1
187
-
188
- * Handle idle state in "wait" function: `wait('idle').then(...)`
189
-
190
-
191
- ## 6.1.0
192
-
193
- * General:
194
- * Refactor
195
- * Minor updates
196
- * Cleanup
197
- * Update Tweenlite 2.x to GSAP 3.x
198
-
199
- * MediaQueriesEvents:
200
- * Add `getValue` function
201
-
202
- * ScrollSnap:
203
- * Update Tweenlite 2.x to GSAP 3.x
204
- * Move GSAP functions in options to override them and be able to use another library
205
-
206
- * Slider:
207
- * Update Tweenlite 2.x to GSAP 3.x
208
- * Move GSAP functions in options to override them and be able to use another library
209
-
210
- * Add new WegGL category
211
- * Add GLImageTransition
212
-
213
-
214
- ## 6.0.16
215
-
216
- * Autocomplete:
217
- * Add resetField, resetResults and reset functions
218
-
219
-
220
- ## 6.0.15
221
-
222
- * Helpers:
223
- * Update debounce function
224
-
225
-
226
- ## 6.0.14
227
-
228
- * SkinSelect:
229
- * Fix item focus and scroll
230
-
231
-
232
- ## 6.0.13
233
-
234
- * Autocomplete:
235
- * Fix repeated query parameter
236
-
237
-
238
- ## 6.0.12
239
-
240
- * Select skin
241
- * Fix focus on load
242
-
243
-
244
- ## 6.0.11
245
-
246
- * Autocomplete:
247
- * Add `enable` and `disable` functions
248
-
249
-
250
- ## 6.0.10
251
-
252
- * Validator:
253
- * Change the default live validation event name on input text from 'change' to 'input'
254
- * DOM:
255
- * Minor updates
256
- * The `wrap` function now can handle an HTMLElement as second parameters
257
- * Autocomplete:
258
- * Add a `showAll` function to display all items of the list in source mode.
259
- * SkinSelect:
260
- * Add keyboard feature
261
-
262
-
263
- ## 6.0.9
264
-
265
- * Validator:
266
- * Update email validation Regular Expression
267
- * Add a loose one: Add data-loose on the input to use it
268
-
269
-
270
- ## 6.0.8
271
-
272
- * DOM/Class:
273
- * Handle array of css classes
274
- * Add sClass function to replace a class by another
275
- * Update extend and copy functions
276
- * Update UrlParser
277
-
278
-
279
- ## 6.0.7
280
-
281
- * Slider: Fix init options bug on `moveByPage` property
282
-
283
-
284
- ## 6.0.6
285
-
286
- * Validator: Fix live validation on input hidden
287
-
288
-
289
- ## 6.0.5
290
-
291
- * Add new Accordion module
292
- * Add new Tabs module
293
- * Select element skin
294
- * Update the updateOptions function
295
- * Add setValid/setInvalid function
296
- * Add function to compute the distance between 2 coordinates
297
- * Rename history to HistoryController
298
- * Update input file skin
299
- * Add quick template module
300
- * ScrollSnap: Fix bug which occurs when you just tap into the element without moving
301
-
302
-
303
- ## 6.0.4
304
-
305
- * Select element skin
306
- * Improve init when skin elements already exist in the DOM
307
-
308
-
309
- ## 6.0.3
310
-
311
- * Popin
312
- * Add function to programmatically open and close the loading layer
313
-
314
-
315
- ## 6.0.2
316
-
317
- * Validator
318
- * Add live validation system
319
- * Add getQueryFromForm function
320
- * 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.
321
-
322
-
323
- ## 6.0.1
324
-
325
- * Add notification module
326
-
327
-
328
- ## 6.0.0
329
-
330
- **Not compatible with 5.x.x version**
331
-
332
- * Remove builder
333
- * Remove dependencies system to use classic JS `import` instead
334
- * Add function to export in `front-library` project hosted on GitHub
335
- * General files and folders renaming
336
-
337
- ### ScrollSnap
338
-
339
- * Add new refresh options
340
-
341
- ### Mediaqueries events
342
-
343
- * Add `on` and `off` function to bind specific breakpoint
344
-
345
- ### EventsManager
346
-
347
- * Fix the auto unbind of the `one` function
348
-
349
-
350
- ## 5.2.14
351
-
352
- * Fix SnapScroll bug
353
-
354
-
355
- ## 5.2.13
356
-
357
- * Add IntersectObserver
358
-
359
- ### Validator
360
-
361
- * Change `getRadioList` second paramater to an object with 2 properties: `selector` and `othersOnly`
362
- * Add the property `$otherRadioOfGroup` to Input object
363
-
364
- ### Mediaqueries events
365
-
366
- * Remove parameter `callbackOnQuit`
367
- * Add the possibility to call function when entering, leaving a mediaquery or on both
368
- * Add 3 static properties: `MediaQueriesEvents.TYPE_ON_ENTER` , `MediaQueriesEvents.TYPE_ON_LEAVE` and `MediaQueriesEvents.TYPE_ON_BOTH`
369
- * 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`
370
-
371
-
372
- ## 5.2.12
373
-
374
- * Add dependencies
375
- * Update documentation
376
-
377
- ### Validator
378
-
379
- * Rename validator tools function: `getAllGroup` ==> `getRadioList`, `isRadioGroupChecked` ==> `isRadioListChecked`
380
- * `getLabel` function now return a string or an array of string
381
- * Add new function `getLabelElement` to return label HTMLElement or an array of HTMLElement
382
-
383
- ### Window events
384
-
385
- * Add new `viewportInfo` property
386
- * Rename property: `scrollPosition` ==> `scrollInfo`, `windowSize` ==> `windowInfo`, `documentSize` ==> `documentInfo`
387
- * Change callback function signature: `(windowSize, documentSize, scrollPosition, eventName) => {}` ==> `({windowInfo, documentInfo, scrollInfo, viewportInfo}, eventName, originalEvent) => {}`
388
-
389
- ### History controller
390
-
391
- * Remove `getState` function and replace it by `state` property.
392
-
393
-
394
- ## 5.2.11
395
-
396
- * Fix gesture callback target
397
-
398
- ### Mediaqueries events
399
-
400
- * Add new properties (`currentBreakpoint`, `list`) and deprecate some functions
401
- * Add a new way of initialize breakpoint objects (`min` and `max` instead of `query`)
402
- * Add new `unit` options
403
-
404
- ### Window events
405
-
406
- * Add new properties (scroll, windowSize, documentSize) and deprecate some functions
407
-
408
-
409
- ## 5.2.10
410
-
411
- * Custom events: Fix DOM elements handling
412
-
413
-
414
- ## 5.2.9
415
-
416
- * Popin: Allow manual handle of http error
417
-
418
-
419
- ## 5.2.8
420
-
421
- * fetch: Add X-Requested-With header to fetch calls
422
-
423
-
424
- ## 5.2.7
425
-
426
- * Gesture: Fix preventDefault and stopPropagation functions
427
-
428
-
429
- ## 5.2.6
430
-
431
- * Update UrlParser: Convert non string value, add `getParam` function.
432
-
433
-
434
- ## 5.2.5
435
-
436
- * Add `cssPositionning` option
437
- * Fix Autocomplete variable name in the select function
438
- * Fix click on items
439
-
440
-
441
- ## 5.2.4
442
-
443
- * Fix AbortController support test
444
-
445
-
446
- ## 5.2.3
447
-
448
- * Improve Scroll Snap
449
-
450
-
451
- ## 5.2.2
452
-
453
- * Update Scroll Snap
454
- * Add color helper
455
-
456
-
457
- ## 5.2.1
458
-
459
- * Remove native polyfill. Use Symfony polyfill package instead.
460
- * Allow to define gesture options on slider controls
461
-
462
-
463
- ## 5.2.0
464
-
465
- * Replace Reqwest dependency with window.fetch
466
- * Replace Bean dependency with custom event manager
467
- * Remove mousewheel event manager. Use the on('wheel', ...) function from the event manager
468
-
469
-
470
- ## 5.1.5
471
-
472
- * Fix extend function
473
-
474
-
475
- ## 5.1.4
476
-
477
- * Fix options in gesture module
478
- * Fix scroll snap module
479
-
480
-
481
- ## 5.1.2
482
-
483
- * Update gesture callbacks name
484
- * touchstart => start
485
- * touchmove => move
486
- * touchend => end
487
- * Update gesture prevent default and stop propagation functions name
488
- * preventTouchstart => preventStart
489
- * stopPropagationTouchstart => stopPropagationStart
490
- * preventTouchmove => preventMove
491
- * stopPropagationTouchmove => stopPropagationMove
492
- * preventTouchend => preventEnd
493
- * stopPropagationTouchend => stopPropagationEnd
494
-
495
-
496
- ## 5.1.1
497
-
498
- * Fix google map multiple call + typo
499
-
500
-
501
- ## 5.1.0
502
-
503
- * Add new polyfill (Element.append, ...)
504
- * Add JSDoc
505
- * 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', property?: string[], animationName?: string[] } = {} ): Promise<HTMLElement> {
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 !== undefined ) {
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.property,
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: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both', animationName?: string[] } ): Promise<HTMLElement> {
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: 'idle' | number, pseudoElement?: 'after' | 'before' | 'both', animationName?: string[] } ): Promise<HTMLElement> {
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
 
@@ -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 { copy } from '../Helpers/Extend';
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, options: Partial<FLib.DragSlider.Options> ) {
97
+ constructor( $slider: HTMLElement, userOptions: Partial<FLib.DragSlider.Options> ) {
60
98
 
61
- if ( !options.viewportSelector || !options.listSelector || !options.itemSelector || !options.dragClass ) {
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 = copy( 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
- gsap.killTweensOf( this.#$list );
111
- gsap.set( this.#$list, {
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 ): gsap.core.Tween | void => {
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
- const TWEEN = gsap.to( this.#$list as HTMLElement, {
207
- "duration": 0.3,
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
- return TWEEN
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 lastDelta, snapItem;
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
- gsap.killTweensOf( this.#$list );
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
- gsap.set( this.#$list as HTMLElement, {
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(): gsap.core.Tween | void {
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(): gsap.core.Tween | void {
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 ): gsap.core.Tween | void {
482
+ goToItem( blockOrIndex: HTMLElement | number ): Promise<any> | void {
469
483
 
470
484
  if ( !this.#isDraggingActive ) {
471
485
  return;
@@ -490,6 +504,8 @@ export default class DragSlider {
490
504
  return;
491
505
  }
492
506
 
507
+ this.#currentSnapItem = ITEM;
508
+
493
509
  this.#options.onSnap?.( {
494
510
  "item": ITEM,
495
511
  "xPos": this.#deltaMove.x,
@@ -498,25 +514,17 @@ export default class DragSlider {
498
514
  "isAtEnd": this.#deltaMove.x === this.#listDelta
499
515
  } );
500
516
 
501
- return gsap.to( this.#$list as HTMLElement, {
502
- "duration": 0.3,
503
- "x": -1 * ITEM.info.left + this.#siteOffsetLeft,
504
- "y": 0,
505
- "z": 0,
506
- "onUpdateParams": [ this ],
507
- "onUpdate": function( ctx ) {
508
-
509
- ctx.#deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' ) as number;
510
-
511
- ctx.#options.onSnapUpdate?.( {
512
- "item": ITEM,
513
- "xPos": ctx.#deltaMove.x,
514
- "moveMaxSize": ctx.#listDelta,
515
- "isAtStart": ctx.#deltaMove.x === 0,
516
- "isAtEnd": ctx.#deltaMove.x === ctx.#listDelta
517
- } );
518
- }
519
- } );
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
+ });
520
528
  }
521
529
 
522
530
  refresh = (): this => {
@@ -632,11 +640,8 @@ export default class DragSlider {
632
640
  } );
633
641
 
634
642
  if ( this.#$list ) {
635
- gsap.killTweensOf( this.#$list );
636
-
637
- gsap.set( this.#$list, {
638
- "clearProps": "all"
639
- } );
643
+ this.#options._animKill( this.#$list );
644
+ this.#options._animClear( this.#$list );
640
645
  }
641
646
 
642
647
  this.#$viewport && rClass( this.#$viewport, this.#options.dragClass );
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Front Library
2
2
 
3
- @version: 7.1.18
3
+ @version: 7.1.20
4
4
 
5
5
 
6
6
  ## Use
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 Translate = {
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
  }
@@ -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.18",
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
- }