@creative-web-solution/front-library 6.2.13 → 6.2.15

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,9 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+
4
+ ## 6.2.15
5
+
6
+ * DragSlider: Make GSAP optional
7
+
8
+
9
+ ## 6.2.14
10
+
11
+ * Remove Modernizr
12
+
13
+
3
14
  ## 6.2.13
4
15
 
5
16
  * Autocomplete: Add method ajax call option
6
17
 
18
+
7
19
  ## 6.2.12
8
20
 
9
21
  * Fix import name
package/DOM/matrix.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { prop } from '@creative-web-solution/front-library/DOM/Styles';
2
+ import { transformPropertyName } from '../Tools/PrefixedProperties';
2
3
 
3
4
  /**
4
5
  * @typedef {Object} matrix_Object
@@ -47,11 +48,7 @@ import { prop } from '@creative-web-solution/front-library/DOM/Styles';
47
48
  export function getMatrix( $elem ) {
48
49
  let matrixString, c, matrix;
49
50
 
50
- if ( !Modernizr || Modernizr.prefixed ) {
51
- throw 'Missing dependency: Modernizr.prefixed';
52
- }
53
-
54
- matrixString = prop( $elem, Modernizr.prefixed( 'transform' ) );
51
+ matrixString = prop( $elem, transformPropertyName );
55
52
  c = matrixString.split( /\s*[(),]\s*/ ).slice( 1, -1 );
56
53
 
57
54
  if ( c.length === 6 ) {
@@ -5,7 +5,48 @@ import { gesture, gestureOff } from '@creative-web-solution/front-library/Eve
5
5
  import { prop } from '@creative-web-solution/front-library/DOM/Styles';
6
6
  import { aClass, rClass, tClass } from '@creative-web-solution/front-library/DOM/Class';
7
7
  import { on, off } from '@creative-web-solution/front-library/Events/EventsManager';
8
+ import { extend } from '@creative-web-solution/front-library/Helpers/extend';
8
9
 
10
+ const IS_TOUCH_DEVICE = !window.matchMedia('(hover:hover)').matches;
11
+
12
+ const defaultOptions = {
13
+ swipeTresholdMin: 40,
14
+ swipeTresholdSize: 0.5,
15
+ lockedClass: 'is-locked',
16
+ _animReset: function($list) {
17
+ gsap.set( $list, {
18
+ "x": 0,
19
+ "y": 0,
20
+ "z": 0
21
+ } );
22
+ },
23
+ _animClear: function($list) {
24
+ gsap.set( $list, {
25
+ "clearProps": "all"
26
+ } );
27
+ },
28
+ _animKill: function($list) {
29
+ gsap.killTweensOf( $list );
30
+ },
31
+ _animMoveItem: function($list, x, onUpdate) {
32
+ gsap.to( $list, {
33
+ "duration": 0.3,
34
+ "x": x,
35
+ "y": 0,
36
+ "z": 0,
37
+ "onUpdate": function() {
38
+ onUpdate(gsap.getProperty( this.targets()[ 0 ], 'x' ));
39
+ }
40
+ } );
41
+ },
42
+ _setCoordinates: function($list, x) {
43
+ gsap.set( $list, {
44
+ "x": x,
45
+ "y": 0,
46
+ "z": 0
47
+ } );
48
+ }
49
+ }
9
50
 
10
51
  /**
11
52
  * DragSlider
@@ -30,7 +71,7 @@ import { on, off } from '@creative-web-solution/front-library/Eve
30
71
  * @param {Number} [options.swipeTresholdMin=40] - in px
31
72
  * @param {Number} [options.swipeTresholdSize=0.5] - in % (0.5 = 50% of the size of one item)
32
73
  */
33
- export function DragSlider( $slider, options ) {
74
+ export function DragSlider( $slider, userOptions ) {
34
75
  let itemMap, itemArray, listDelta, viewportInfo,
35
76
  $items, $list, $viewport, startDragCoords, deltaMove,
36
77
  currentSnapItem, firstItem,
@@ -44,9 +85,7 @@ export function DragSlider( $slider, options ) {
44
85
 
45
86
  isDraggingActive = false;
46
87
 
47
- options.swipeTresholdMin = options.swipeTresholdMin || 40;
48
- options.swipeTresholdSize = options.swipeTresholdSize || 0.5;
49
- options.lockedClass = options.lockedClass || 'is-locked';
88
+ const options = extend( defaultOptions, userOptions );
50
89
 
51
90
  itemArray = [];
52
91
 
@@ -78,12 +117,9 @@ export function DragSlider( $slider, options ) {
78
117
 
79
118
  if ( !isDraggingActive ) {
80
119
  isDragging = false;
81
- gsap.killTweensOf( $list );
82
- gsap.set( $list, {
83
- "x": 0,
84
- "y": 0,
85
- "z": 0
86
- } );
120
+
121
+ options._animKill( $list );
122
+ options._animReset( $list );
87
123
  }
88
124
 
89
125
  tClass( $slider, options.lockedClass, !isDraggingActive );
@@ -147,22 +183,16 @@ export function DragSlider( $slider, options ) {
147
183
  "isAtEnd": IS_SNAP_TO_END
148
184
  } );
149
185
 
150
- gsap.to( $list, {
151
- "duration": 0.3,
152
- "x": finalX,
153
- "y": 0,
154
- "z": 0,
155
- "onUpdate": function() {
156
- deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' );
157
-
158
- options.onSnapUpdate?.( {
159
- "item": snapItem,
160
- "xPos": deltaMove.x,
161
- "moveMaxSize": listDelta,
162
- "isAtStart": IS_SNAP_TO_START,
163
- "isAtEnd": IS_SNAP_TO_END
164
- } );
165
- }
186
+ options._animMoveItem( $list, finalX, (newX) => {
187
+ deltaMove.x = newX;
188
+
189
+ options.onSnapUpdate?.( {
190
+ "item": snapItem,
191
+ "xPos": deltaMove.x,
192
+ "moveMaxSize": listDelta,
193
+ "isAtStart": IS_SNAP_TO_START,
194
+ "isAtEnd": IS_SNAP_TO_END
195
+ } );
166
196
  } );
167
197
 
168
198
  currentSnapItem = snapItem;
@@ -293,7 +323,7 @@ export function DragSlider( $slider, options ) {
293
323
 
294
324
  isDragging = true;
295
325
 
296
- gsap.killTweensOf( $list );
326
+ options._animKill( $list );
297
327
 
298
328
  startDragCoords = coords;
299
329
  listDelta = viewportInfo.width - $list.scrollWidth;
@@ -306,8 +336,8 @@ export function DragSlider( $slider, options ) {
306
336
  return false;
307
337
  }
308
338
 
309
- return !Modernizr.touchdevice ||
310
- Modernizr.touchdevice && Math.abs( deltaMove.deltaY ) < Math.abs( deltaMove.deltaX );
339
+ return !IS_TOUCH_DEVICE ||
340
+ IS_TOUCH_DEVICE && Math.abs( deltaMove.deltaY ) < Math.abs( deltaMove.deltaX );
311
341
  }
312
342
  } );
313
343
 
@@ -336,11 +366,7 @@ export function DragSlider( $slider, options ) {
336
366
  deltaMove.newX = listDelta;
337
367
  }
338
368
 
339
- gsap.set( $list, {
340
- "x": deltaMove.newX,
341
- "y": 0,
342
- "z": 0
343
- } );
369
+ options._setCoordinates($list, deltaMove.newX);
344
370
 
345
371
  options.onDrag?.( {
346
372
  "item": currentSnapItem,
@@ -449,23 +475,17 @@ export function DragSlider( $slider, options ) {
449
475
  "isAtEnd": deltaMove.x === listDelta
450
476
  } );
451
477
 
452
- gsap.to( $list, {
453
- "duration": 0.3,
454
- "x": -1 * ITEM.info.left + siteOffset,
455
- "y": 0,
456
- "z": 0,
457
- "onUpdate": function() {
458
- deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' );
459
-
460
- options.onSnapUpdate?.( {
461
- "item": ITEM,
462
- "xPos": deltaMove.x,
463
- "moveMaxSize": listDelta,
464
- "isAtStart": deltaMove.x === 0,
465
- "isAtEnd": deltaMove.x === listDelta
466
- } );
467
- }
468
- } );
478
+ options._animMoveItem($list, -1 * ITEM.info.left + siteOffset, (x) => {
479
+ deltaMove.x = x;
480
+
481
+ options.onSnapUpdate?.( {
482
+ "item": ITEM,
483
+ "xPos": deltaMove.x,
484
+ "moveMaxSize": listDelta,
485
+ "isAtStart": deltaMove.x === 0,
486
+ "isAtEnd": deltaMove.x === listDelta
487
+ } );
488
+ })
469
489
  };
470
490
 
471
491
 
@@ -566,12 +586,8 @@ export function DragSlider( $slider, options ) {
566
586
  "callback": onMouseleave
567
587
  } );
568
588
 
569
-
570
- gsap.killTweensOf( $list );
571
-
572
- gsap.set( $list, {
573
- "clearProps": "all"
574
- } );
589
+ options._animKill( $list );
590
+ options._animClear( $list );
575
591
 
576
592
  rClass( $viewport, options.dragClass );
577
593
 
package/Modules/Popin.js CHANGED
@@ -9,8 +9,7 @@ import { template } from '@creative-web-solution/front-library/Modules/template'
9
9
 
10
10
  let $body = document.body;
11
11
 
12
- const CLICK_EVENT_NAME =
13
- window.Modernizr && window.Modernizr.touchdevice ? 'touchend' : 'click';
12
+ const CLICK_EVENT_NAME = window.matchMedia('(hover:hover)').matches ? 'click' : 'touchend';
14
13
 
15
14
  const FOCUSABLE_ELEMENTS = 'a, button, input, select, textarea';
16
15
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Front Library
2
2
 
3
- @version: 6.2.13
3
+ @version: 6.2.15
4
4
 
5
5
 
6
6
  ## Use
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": "6.2.13",
5
+ "version": "6.2.15",
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": [],