@creative-web-solution/front-library 7.0.7 → 7.1.3
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 +29 -0
- package/DOM/Class.ts +10 -12
- package/DOM/DocumentSize.ts +3 -1
- package/DOM/Filter.ts +0 -2
- package/DOM/Index.ts +1 -3
- package/DOM/Manipulation.ts +0 -3
- package/DOM/Matrix.ts +12 -12
- package/DOM/Offset.ts +4 -5
- package/DOM/OuterSize.ts +12 -12
- package/DOM/PageToDOM.ts +2 -2
- package/DOM/Position.ts +3 -3
- package/DOM/Size.ts +3 -7
- package/DOM/StrToDOM.ts +0 -1
- package/DOM/Styles.ts +3 -12
- package/DOM/Traversing.ts +0 -6
- package/DOM/WindowScroll.ts +3 -1
- package/DOM/WindowSize.ts +3 -1
- package/DOM/Wrap.ts +0 -1
- package/Events/DeviceOrientation.ts +27 -31
- package/Events/EventsManager.ts +10 -25
- package/Events/Gesture.ts +36 -37
- package/Events/HistoryController.ts +12 -18
- package/Events/ImageLoad.ts +35 -19
- package/Events/IntersectObserver.ts +15 -19
- package/Events/KeyboardHandler.ts +10 -8
- package/Events/MediaQueriesEvents.ts +53 -51
- package/Events/OnAnimationEnd.ts +2 -3
- package/Events/OnTransitionEnd.ts +3 -3
- package/Events/PubSub.ts +5 -8
- package/Events/TouchHover.ts +18 -21
- package/Events/WindowEvents.ts +26 -30
- package/Helpers/Colors.ts +7 -23
- package/Helpers/Cookie.ts +5 -12
- package/Helpers/Coordinates.ts +0 -7
- package/Helpers/Debounce.ts +3 -7
- package/Helpers/Defer.ts +1 -1
- package/Helpers/GetValue.ts +0 -2
- package/Helpers/Insert.ts +0 -1
- package/Helpers/Sequential.ts +0 -2
- package/Helpers/Slice.ts +0 -3
- package/Helpers/Throttle.ts +0 -1
- package/Helpers/TransitionHelpers.ts +8 -6
- package/Helpers/Type.ts +1 -14
- package/Helpers/Unique.ts +3 -3
- package/Helpers/UrlParser.ts +14 -23
- package/Helpers/Wait.ts +1 -1
- package/Modules/Accordion/Tab.ts +19 -17
- package/Modules/Accordion/index.ts +27 -19
- package/Modules/Autocomplete.ts +95 -101
- package/Modules/DragSlider.ts +72 -63
- package/Modules/GlobalState.ts +60 -53
- package/Modules/LoadGMap.ts +4 -7
- package/Modules/Notifications/Notification.ts +28 -32
- package/Modules/Notifications/index.ts +43 -36
- package/Modules/Popin/Popin.ts +100 -110
- package/Modules/Popin/PopinAccessibility.ts +8 -8
- package/Modules/Popin/PopinBackground.ts +12 -12
- package/Modules/Popin/PopinController.ts +24 -30
- package/Modules/Popin/Tools.ts +18 -19
- package/Modules/QuickTemplate.ts +4 -6
- package/Modules/ScrollSnap.ts +110 -104
- package/Modules/SkinCheckbox.ts +52 -38
- package/Modules/SkinFile.ts +63 -53
- package/Modules/SkinRadio.ts +63 -43
- package/Modules/SkinSelect.ts +117 -101
- package/Modules/Slider/Slide.ts +49 -52
- package/Modules/Slider/Slider.ts +100 -136
- package/Modules/Slider/SliderControls.ts +60 -59
- package/Modules/Tabs/Tab.ts +28 -24
- package/Modules/Tabs/index.ts +36 -26
- package/Modules/Validator/Date.ts +2 -1
- package/Modules/Validator/Equals.ts +1 -1
- package/Modules/Validator/Internal/Input.ts +366 -0
- package/Modules/Validator/Internal/InputValidator.ts +99 -0
- package/Modules/Validator/Internal/ValidatorFunctionsController.ts +58 -0
- package/Modules/Validator/Max.ts +1 -1
- package/Modules/Validator/Min.ts +1 -1
- package/Modules/Validator/MultiRequired.ts +5 -5
- package/Modules/Validator/Number.ts +1 -0
- package/Modules/Validator/Pattern.ts +1 -1
- package/Modules/Validator/Recaptcha.ts +1 -0
- package/Modules/Validator/Required.ts +3 -2
- package/Modules/Validator/ServerCheck.ts +23 -15
- package/Modules/Validator/Tools/GetQueryFromForm.ts +1 -6
- package/Modules/Validator/Tools/IsDate.ts +2 -3
- package/Modules/Validator/Tools/IsEmail.ts +2 -5
- package/Modules/Validator/Tools/IsEmpty.ts +0 -2
- package/Modules/Validator/Tools/IsNumber.ts +0 -2
- package/Modules/Validator/Tools/IsUrl.ts +1 -3
- package/Modules/Validator/Tools/Label.ts +5 -15
- package/Modules/Validator/Tools/RadioButton.ts +4 -10
- package/Modules/Validator/Url.ts +1 -0
- package/Modules/Validator/index.ts +36 -36
- package/Modules/YouTubePlayer.ts +18 -16
- package/README.md +1 -1
- package/Types/Accordion.d.ts +41 -0
- package/Types/Autocomplete.d.ts +94 -0
- package/Types/DOM.d.ts +69 -0
- package/Types/DragSlider.d.ts +56 -0
- package/Types/EventsHelpers.d.ts +390 -0
- package/Types/GLImageTransition.d.ts +47 -43
- package/Types/GlobalState.d.ts +9 -0
- package/Types/Helpers.d.ts +63 -0
- package/Types/Notifications.d.ts +48 -44
- package/Types/Popin.d.ts +113 -0
- package/Types/ScrollSnap.d.ts +66 -0
- package/Types/SkinCheckbox.d.ts +35 -0
- package/Types/SkinFile.d.ts +45 -0
- package/Types/SkinRadio.d.ts +37 -0
- package/Types/SkinSelect.d.ts +72 -0
- package/Types/Slider.d.ts +106 -0
- package/Types/Tabs.d.ts +33 -0
- package/Types/Validator.d.ts +99 -0
- package/Types/YouTubePlayer.d.ts +27 -0
- package/Types/index.d.ts +22 -21
- package/WebGL/GLImageTransition/GLImageTransition.ts +83 -80
- package/WebGL/GLImageTransition/Presets/Cellular.ts +11 -11
- package/WebGL/GLImageTransition/Presets/Fade.ts +2 -3
- package/WebGL/GLImageTransition/Presets/HorizontalMovingGrid.ts +9 -9
- package/WebGL/GLImageTransition/Presets/PresetSample.ts +11 -9
- package/WebGL/GLImageTransition/Presets/Solarisation.ts +7 -12
- package/package.json +1 -1
- package/Modules/Template.ts +0 -209
- package/Types/AccordionTypes.d.ts +0 -29
- package/Types/AutocompleteTypes.d.ts +0 -85
- package/Types/DOMTypes.d.ts +0 -62
- package/Types/DragSliderTypes.d.ts +0 -52
- package/Types/EventsHelpersTypes.d.ts +0 -370
- package/Types/GlobalStateTypes.d.ts +0 -5
- package/Types/HelpersTypes.d.ts +0 -23
- package/Types/MediaPreloaderTypes.d.ts +0 -12
- package/Types/PopinTypes.d.ts +0 -83
- package/Types/ScrollSnapTypes.d.ts +0 -62
- package/Types/SkinCheckboxTypes.d.ts +0 -23
- package/Types/SkinFileTypes.d.ts +0 -34
- package/Types/SkinRadioTypes.d.ts +0 -24
- package/Types/SkinSelectTypes.d.ts +0 -48
- package/Types/SliderTypes.d.ts +0 -97
- package/Types/TabsTypes.d.ts +0 -22
- package/Types/ValidatorTypes.d.ts +0 -61
- package/Types/YouTubePlayerTypes.d.ts +0 -23
package/Modules/DragSlider.ts
CHANGED
|
@@ -14,9 +14,9 @@ import { copy } from '../Helpers/Extend';
|
|
|
14
14
|
*/
|
|
15
15
|
export default class DragSlider {
|
|
16
16
|
#isDraggingActive: boolean;
|
|
17
|
-
#options:
|
|
18
|
-
#deltaMove:
|
|
19
|
-
#itemArray:
|
|
17
|
+
#options: FLib.DragSlider.Options;
|
|
18
|
+
#deltaMove: FLib.DragSlider.DeltaMove;
|
|
19
|
+
#itemArray: FLib.DragSlider.Item[];
|
|
20
20
|
#$slider: HTMLElement;
|
|
21
21
|
#viewportInfo;
|
|
22
22
|
#siteOffset;
|
|
@@ -25,21 +25,25 @@ export default class DragSlider {
|
|
|
25
25
|
#$items!: NodeList;
|
|
26
26
|
#$list!: HTMLElement;
|
|
27
27
|
#isDragging!: boolean;
|
|
28
|
-
#itemMap!: Map<HTMLElement,
|
|
29
|
-
#firstItem!:
|
|
30
|
-
#currentSnapItem!:
|
|
28
|
+
#itemMap!: Map<HTMLElement, FLib.DragSlider.Item>;
|
|
29
|
+
#firstItem!: FLib.DragSlider.Item;
|
|
30
|
+
#currentSnapItem!: FLib.DragSlider.Item;
|
|
31
31
|
#hasAlreadyBeenDragged!: boolean;
|
|
32
|
-
#startDragCoords!:
|
|
32
|
+
#startDragCoords!: FLib.Events.Gesture.Coords;
|
|
33
33
|
#isInitialized!: boolean;
|
|
34
34
|
#debouncedOnResize;
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
get isActive() {
|
|
37
|
+
get isActive(): boolean {
|
|
38
38
|
return this.#isDraggingActive;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
constructor( $slider: HTMLElement, options:
|
|
42
|
+
constructor( $slider: HTMLElement, options: Partial<FLib.DragSlider.Options> ) {
|
|
43
|
+
if ( !options.viewportSelector || !options.listSelector || !options.itemSelector || !options.dragClass ) {
|
|
44
|
+
throw '[Drag Slider]: Missing at least one of viewportSelector, listSelector, itemSelector, dragClass';
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
this.#deltaMove = {
|
|
44
48
|
"x": 0,
|
|
45
49
|
"deltaX": 0,
|
|
@@ -63,19 +67,19 @@ export default class DragSlider {
|
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
#cancelLinkClick = (): void => {
|
|
67
71
|
aClass( this.#$slider, this.#options.dragClass );
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
#activeLinkClick = (): void => {
|
|
72
76
|
wait().then( () => {
|
|
73
77
|
rClass( this.#$slider, this.#options.dragClass );
|
|
74
78
|
} );
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
|
|
78
|
-
#onResize = () => {
|
|
82
|
+
#onResize = (): void => {
|
|
79
83
|
this.#viewportInfo = offset( this.#$viewport );
|
|
80
84
|
this.#siteOffset = parseInt( prop( (this.#$items[ 0 ] as HTMLElement), 'marginLeft' ), 10 );
|
|
81
85
|
this.#listDelta = this.#viewportInfo.width - this.#$list.scrollWidth;
|
|
@@ -93,7 +97,7 @@ export default class DragSlider {
|
|
|
93
97
|
} );
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
tClass( this.#$slider, this.#options.lockedClass
|
|
100
|
+
tClass( this.#$slider, this.#options.lockedClass, !this.#isDraggingActive );
|
|
97
101
|
|
|
98
102
|
if ( prevIsDraggingActive !== this.#isDraggingActive ) {
|
|
99
103
|
this.#options.onChangeState?.( this.#isDraggingActive );
|
|
@@ -116,7 +120,7 @@ export default class DragSlider {
|
|
|
116
120
|
this.#itemMap.set( $ITEM, this.#itemArray[ index ] );
|
|
117
121
|
} );
|
|
118
122
|
|
|
119
|
-
this.#firstItem = this.#itemMap.get( (this.#$items[ 0 ] as HTMLElement) ) as
|
|
123
|
+
this.#firstItem = this.#itemMap.get( (this.#$items[ 0 ] as HTMLElement) ) as FLib.DragSlider.Item;
|
|
120
124
|
|
|
121
125
|
if ( !this.#currentSnapItem ) {
|
|
122
126
|
this.#currentSnapItem = this.#firstItem;
|
|
@@ -127,7 +131,7 @@ export default class DragSlider {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
|
|
130
|
-
|
|
134
|
+
#snapToItemAnimation = ( snapItem: FLib.DragSlider.Item, snapToEnd?: FLib.DragSlider.Item ): gsap.core.Tween => {
|
|
131
135
|
let finalX;
|
|
132
136
|
|
|
133
137
|
if ( snapToEnd ) {
|
|
@@ -155,31 +159,32 @@ export default class DragSlider {
|
|
|
155
159
|
"isAtEnd": IS_SNAP_TO_END
|
|
156
160
|
} );
|
|
157
161
|
|
|
158
|
-
|
|
162
|
+
this.#currentSnapItem = snapItem;
|
|
159
163
|
|
|
160
|
-
gsap.to( this.#$list, {
|
|
164
|
+
const TWEEN = gsap.to( this.#$list, {
|
|
161
165
|
"duration": 0.3,
|
|
162
166
|
"x": finalX,
|
|
163
167
|
"y": 0,
|
|
164
168
|
"z": 0,
|
|
165
|
-
"
|
|
166
|
-
|
|
169
|
+
"onUpdateParams": [ this ],
|
|
170
|
+
"onUpdate": function( ctx ) {
|
|
171
|
+
ctx.#deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' ) as number;
|
|
167
172
|
|
|
168
|
-
|
|
173
|
+
ctx.#options.onSnapUpdate?.( {
|
|
169
174
|
"item": snapItem,
|
|
170
|
-
"xPos":
|
|
171
|
-
"moveMaxSize":
|
|
175
|
+
"xPos": ctx.#deltaMove.x,
|
|
176
|
+
"moveMaxSize": ctx.#listDelta,
|
|
172
177
|
"isAtStart": IS_SNAP_TO_START,
|
|
173
178
|
"isAtEnd": IS_SNAP_TO_END
|
|
174
179
|
} );
|
|
175
180
|
}
|
|
176
181
|
} );
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
return TWEEN
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
|
|
182
|
-
|
|
187
|
+
#getFirstPreviousItem = ( xPos: number ): { snapItem: FLib.DragSlider.Item, snapToEnd: boolean } => {
|
|
183
188
|
let snapItem;
|
|
184
189
|
|
|
185
190
|
const absXPos = Math.abs( xPos );
|
|
@@ -199,7 +204,7 @@ export default class DragSlider {
|
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
|
|
202
|
-
|
|
207
|
+
#getFirstNextItem = ( xPos: number ): { snapItem: FLib.DragSlider.Item, snapToEnd: boolean } => {
|
|
203
208
|
let lastDelta, snapItem, snapToEnd;
|
|
204
209
|
|
|
205
210
|
const absXPos = Math.abs( xPos );
|
|
@@ -230,8 +235,8 @@ export default class DragSlider {
|
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
|
|
233
|
-
|
|
234
|
-
let lastDelta, snapItem, snapToEnd
|
|
238
|
+
#getClosestItem = ( xPos: number ): { snapItem: FLib.DragSlider.Item, snapToEnd: boolean } => {
|
|
239
|
+
let lastDelta, snapItem, snapToEnd = false;
|
|
235
240
|
|
|
236
241
|
const absXPos = Math.abs( xPos );
|
|
237
242
|
|
|
@@ -266,32 +271,32 @@ export default class DragSlider {
|
|
|
266
271
|
}
|
|
267
272
|
|
|
268
273
|
|
|
269
|
-
|
|
274
|
+
#snapToItem = (): void => {
|
|
270
275
|
let snapItem;
|
|
271
276
|
|
|
272
277
|
const ABS_DELTA_X = Math.abs( this.#deltaMove.deltaX );
|
|
273
278
|
|
|
274
|
-
if ( ABS_DELTA_X >= this.#options.swipeTresholdMin
|
|
279
|
+
if ( ABS_DELTA_X >= this.#options.swipeTresholdMin && ABS_DELTA_X < Math.min( this.#firstItem.info.width * this.#options.swipeTresholdSize, this.#options.swipeTresholdMin * 3 ) ) {
|
|
275
280
|
if ( this.#deltaMove.deltaX < 0 ) {
|
|
276
|
-
snapItem = this
|
|
281
|
+
snapItem = this.#getFirstNextItem( this.#deltaMove.x );
|
|
277
282
|
}
|
|
278
283
|
else {
|
|
279
|
-
snapItem = this
|
|
284
|
+
snapItem = this.#getFirstPreviousItem( this.#deltaMove.x );
|
|
280
285
|
}
|
|
281
286
|
}
|
|
282
287
|
else {
|
|
283
|
-
snapItem = this
|
|
288
|
+
snapItem = this.#getClosestItem( this.#deltaMove.x );
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
if ( !snapItem ) {
|
|
287
292
|
return;
|
|
288
293
|
}
|
|
289
294
|
|
|
290
|
-
this
|
|
295
|
+
this.#snapToItemAnimation( snapItem.snapItem, snapItem.snapToEnd );
|
|
291
296
|
}
|
|
292
297
|
|
|
293
298
|
|
|
294
|
-
#onStartDrag = ( e, $target, coords:
|
|
299
|
+
#onStartDrag = ( e: Event, $target: HTMLElement, coords: FLib.Events.Gesture.Coords ): void => {
|
|
295
300
|
if ( !this.#hasAlreadyBeenDragged ) {
|
|
296
301
|
this.#onResize();
|
|
297
302
|
this.#hasAlreadyBeenDragged = true;
|
|
@@ -331,8 +336,8 @@ export default class DragSlider {
|
|
|
331
336
|
}
|
|
332
337
|
|
|
333
338
|
|
|
334
|
-
#onMove = ( e, $target, coords:
|
|
335
|
-
this
|
|
339
|
+
#onMove = ( e: Event, $target: HTMLElement, coords: FLib.Events.Gesture.Coords ): void => {
|
|
340
|
+
this.#cancelLinkClick();
|
|
336
341
|
|
|
337
342
|
this.#deltaMove.deltaX = coords.pageX - this.#startDragCoords.pageX;
|
|
338
343
|
this.#deltaMove.deltaY = coords.pageY - this.#startDragCoords.pageY;
|
|
@@ -362,16 +367,16 @@ export default class DragSlider {
|
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
|
|
365
|
-
#onStopDrag = () => {
|
|
370
|
+
#onStopDrag = (): void => {
|
|
366
371
|
gestureOff( document.body, 'dragSlider' );
|
|
367
372
|
|
|
368
373
|
this.#isDragging = false;
|
|
369
374
|
|
|
370
375
|
this.#deltaMove.x = this.#deltaMove.newX;
|
|
371
376
|
|
|
372
|
-
this
|
|
377
|
+
this.#activeLinkClick();
|
|
373
378
|
|
|
374
|
-
this
|
|
379
|
+
this.#snapToItem();
|
|
375
380
|
|
|
376
381
|
this.#options.onStopDrag?.({
|
|
377
382
|
"item": this.#currentSnapItem,
|
|
@@ -383,7 +388,7 @@ export default class DragSlider {
|
|
|
383
388
|
}
|
|
384
389
|
|
|
385
390
|
|
|
386
|
-
#onMouseenter = () => {
|
|
391
|
+
#onMouseenter = (): void => {
|
|
387
392
|
if ( this.#isDragging || !this.#isDraggingActive ) {
|
|
388
393
|
return;
|
|
389
394
|
}
|
|
@@ -398,7 +403,7 @@ export default class DragSlider {
|
|
|
398
403
|
}
|
|
399
404
|
|
|
400
405
|
|
|
401
|
-
#onMouseleave = () => {
|
|
406
|
+
#onMouseleave = (): void => {
|
|
402
407
|
if ( this.#isDragging || !this.#isDraggingActive ) {
|
|
403
408
|
return;
|
|
404
409
|
}
|
|
@@ -413,30 +418,30 @@ export default class DragSlider {
|
|
|
413
418
|
}
|
|
414
419
|
|
|
415
420
|
|
|
416
|
-
#cancelDrag = ( e ) => {
|
|
421
|
+
#cancelDrag = ( e: Event ): void => {
|
|
417
422
|
e.preventDefault();
|
|
418
423
|
}
|
|
419
424
|
|
|
420
425
|
|
|
421
|
-
next() {
|
|
426
|
+
next(): gsap.core.Tween | void {
|
|
422
427
|
if ( !this.#isDraggingActive || this.#currentSnapItem.isLast ) {
|
|
423
428
|
return;
|
|
424
429
|
}
|
|
425
430
|
|
|
426
|
-
this
|
|
431
|
+
return this.#snapToItemAnimation( this.#itemArray[ this.#currentSnapItem.index + 1 ] );
|
|
427
432
|
}
|
|
428
433
|
|
|
429
434
|
|
|
430
|
-
previous() {
|
|
435
|
+
previous(): gsap.core.Tween | void {
|
|
431
436
|
if ( !this.#isDraggingActive || this.#currentSnapItem.isFirst ) {
|
|
432
437
|
return;
|
|
433
438
|
}
|
|
434
439
|
|
|
435
|
-
this
|
|
440
|
+
return this.#snapToItemAnimation( this.#itemArray[ this.#currentSnapItem.index - 1 ] );
|
|
436
441
|
}
|
|
437
442
|
|
|
438
443
|
|
|
439
|
-
goToItem( $block: HTMLElement ) {
|
|
444
|
+
goToItem( $block: HTMLElement ): gsap.core.Tween | void {
|
|
440
445
|
|
|
441
446
|
if ( !this.#isDraggingActive ) {
|
|
442
447
|
return;
|
|
@@ -456,31 +461,31 @@ export default class DragSlider {
|
|
|
456
461
|
"isAtEnd": this.#deltaMove.x === this.#listDelta
|
|
457
462
|
} );
|
|
458
463
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
gsap.to( this.#$list, {
|
|
464
|
+
return gsap.to( this.#$list, {
|
|
462
465
|
"duration": 0.3,
|
|
463
466
|
"x": -1 * ITEM.info.left + this.#siteOffset,
|
|
464
467
|
"y": 0,
|
|
465
468
|
"z": 0,
|
|
466
|
-
"
|
|
467
|
-
|
|
469
|
+
"onUpdateParams": [ this ],
|
|
470
|
+
"onUpdate": function( ctx ) {
|
|
471
|
+
|
|
472
|
+
ctx.#deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' ) as number;
|
|
468
473
|
|
|
469
|
-
|
|
474
|
+
ctx.#options.onSnapUpdate?.( {
|
|
470
475
|
"item": ITEM,
|
|
471
|
-
"xPos":
|
|
472
|
-
"moveMaxSize":
|
|
473
|
-
"isAtStart":
|
|
474
|
-
"isAtEnd":
|
|
476
|
+
"xPos": ctx.#deltaMove.x,
|
|
477
|
+
"moveMaxSize": ctx.#listDelta,
|
|
478
|
+
"isAtStart": ctx.#deltaMove.x === 0,
|
|
479
|
+
"isAtEnd": ctx.#deltaMove.x === ctx.#listDelta
|
|
475
480
|
} );
|
|
476
481
|
}
|
|
477
482
|
} );
|
|
478
|
-
}
|
|
483
|
+
}
|
|
479
484
|
|
|
480
485
|
|
|
481
|
-
init = () => {
|
|
486
|
+
init = (): this => {
|
|
482
487
|
if ( this.#isInitialized ) {
|
|
483
|
-
return;
|
|
488
|
+
return this;
|
|
484
489
|
}
|
|
485
490
|
|
|
486
491
|
this.#isInitialized = true;
|
|
@@ -510,7 +515,7 @@ export default class DragSlider {
|
|
|
510
515
|
}
|
|
511
516
|
|
|
512
517
|
if ( !this.#$items.length ) {
|
|
513
|
-
return;
|
|
518
|
+
return this;
|
|
514
519
|
}
|
|
515
520
|
|
|
516
521
|
this.#onResize();
|
|
@@ -549,15 +554,17 @@ export default class DragSlider {
|
|
|
549
554
|
} );
|
|
550
555
|
|
|
551
556
|
aClass( this.#$slider, 'is-active' );
|
|
557
|
+
|
|
558
|
+
return this;
|
|
552
559
|
}
|
|
553
560
|
|
|
554
561
|
|
|
555
|
-
destroy() {
|
|
562
|
+
destroy(): this {
|
|
556
563
|
this.#isInitialized = false;
|
|
557
564
|
this.#hasAlreadyBeenDragged = false;
|
|
558
565
|
|
|
559
566
|
if ( !this.#$items.length ) {
|
|
560
|
-
return;
|
|
567
|
+
return this;
|
|
561
568
|
}
|
|
562
569
|
|
|
563
570
|
off( window, {
|
|
@@ -594,6 +601,8 @@ export default class DragSlider {
|
|
|
594
601
|
rClass( this.#$viewport, this.#options.dragClass );
|
|
595
602
|
|
|
596
603
|
rClass( this.#$slider, 'is-active' );
|
|
604
|
+
|
|
605
|
+
return this;
|
|
597
606
|
}
|
|
598
607
|
|
|
599
608
|
}
|
package/Modules/GlobalState.ts
CHANGED
|
@@ -3,14 +3,42 @@ import { extend } from '../Helpers/Extend';
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
const DEFAULT_OPTIONS:
|
|
6
|
+
const DEFAULT_OPTIONS: FLib.GlobalState.Options = {
|
|
7
7
|
"dispatchEvents": false,
|
|
8
8
|
"alwaysDispatch": false
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Manage a global object that allow storing and sharing values among modules.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Use the default storage
|
|
19
|
+
* const globalState = new GlobalState();
|
|
20
|
+
* globalState.set( 'PROP', 'VALUE' );
|
|
21
|
+
* globalState.get( 'PROP' );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Use a storage with a specific name
|
|
27
|
+
* const globalState = new GlobalState();
|
|
28
|
+
* globalState.set( 'MY_STORE', 'PROP', 'VALUE' );
|
|
29
|
+
* globalState.get( 'MY_STORE', 'PROP' );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // To use events on properties change
|
|
35
|
+
* const globalState = new GlobalState({
|
|
36
|
+
* "dispatchEvents": true
|
|
37
|
+
* });
|
|
38
|
+
* globalState.registerOnEveryChange( (value, propertyName, storeName) => {} )
|
|
39
|
+
* globalState.registerOnStoreChange( (value, propertyName, storeName) => {}, 'storeName' )
|
|
40
|
+
* globalState.registerOnPropertyChange( (value, propertyName, storeName) => {}, 'storeName', 'myProperty' )
|
|
41
|
+
* ```
|
|
14
42
|
*/
|
|
15
43
|
class GlobalState {
|
|
16
44
|
|
|
@@ -18,24 +46,24 @@ class GlobalState {
|
|
|
18
46
|
|
|
19
47
|
#EVENTS_STORE: {
|
|
20
48
|
[ storeName: string ]: {
|
|
21
|
-
functions:
|
|
49
|
+
functions: FLib.GlobalState.Callback[],
|
|
22
50
|
props: {
|
|
23
|
-
[ propertyName: string ]:
|
|
51
|
+
[ propertyName: string ]: FLib.GlobalState.Callback[]
|
|
24
52
|
}
|
|
25
53
|
}
|
|
26
54
|
};
|
|
27
|
-
#GLOBAL_EVENTS_STORE:
|
|
55
|
+
#GLOBAL_EVENTS_STORE: FLib.GlobalState.Callback[] = [];
|
|
28
56
|
#stores = {};
|
|
29
57
|
#alwaysDispatch: boolean;
|
|
30
58
|
#dispatchEvents: boolean;
|
|
31
59
|
|
|
32
60
|
|
|
33
|
-
get DEFAULT_STORE_NAME() {
|
|
61
|
+
get DEFAULT_STORE_NAME(): string {
|
|
34
62
|
return this.#DEFAULT_STORE_NAME;
|
|
35
63
|
}
|
|
36
64
|
|
|
37
65
|
|
|
38
|
-
constructor( userOptions?:
|
|
66
|
+
constructor( userOptions?: Partial<FLib.GlobalState.Options> ) {
|
|
39
67
|
const options = extend( {}, DEFAULT_OPTIONS, userOptions );
|
|
40
68
|
|
|
41
69
|
this.#alwaysDispatch = options.alwaysDispatch;
|
|
@@ -54,7 +82,7 @@ class GlobalState {
|
|
|
54
82
|
}
|
|
55
83
|
|
|
56
84
|
|
|
57
|
-
|
|
85
|
+
#dispatch = ( value: any, property: string, store: string ): void => {
|
|
58
86
|
|
|
59
87
|
if ( !this.#EVENTS_STORE[ store ] ) {
|
|
60
88
|
this.#EVENTS_STORE[ store ] = {
|
|
@@ -86,27 +114,27 @@ class GlobalState {
|
|
|
86
114
|
*
|
|
87
115
|
* @param alwaysDispatch - If true, it will dispatch events even if the value in the store is the same as the value you try to set
|
|
88
116
|
*/
|
|
89
|
-
activeEventsDispatch( alwaysDispatch
|
|
117
|
+
activeEventsDispatch( alwaysDispatch = false ): this {
|
|
90
118
|
this.#dispatchEvents = true;
|
|
91
119
|
this.#alwaysDispatch = alwaysDispatch;
|
|
120
|
+
|
|
121
|
+
return this;
|
|
92
122
|
}
|
|
93
123
|
|
|
94
124
|
|
|
95
125
|
/**
|
|
96
126
|
* Stop the dispatch of events
|
|
97
127
|
*/
|
|
98
|
-
stopEventsDispatch() {
|
|
128
|
+
stopEventsDispatch(): this {
|
|
99
129
|
this.#dispatchEvents = false;
|
|
130
|
+
|
|
131
|
+
return this;
|
|
100
132
|
}
|
|
101
133
|
|
|
102
134
|
|
|
103
135
|
/**
|
|
104
136
|
* Set a value in a property. If there are only 2 arguments, the default store will be used
|
|
105
137
|
*
|
|
106
|
-
* @param propertyName
|
|
107
|
-
* @param value
|
|
108
|
-
* @param storeName
|
|
109
|
-
*
|
|
110
138
|
* @returns Return the setted value
|
|
111
139
|
*/
|
|
112
140
|
set( propertyName: string, value: any, storeName = this.#DEFAULT_STORE_NAME ): any {
|
|
@@ -123,7 +151,7 @@ class GlobalState {
|
|
|
123
151
|
this.#stores[ storeName ][ propertyName] = value;
|
|
124
152
|
|
|
125
153
|
if ( this.#dispatchEvents && ( this.#alwaysDispatch || !this.#alwaysDispatch && previousValue !== value ) ) {
|
|
126
|
-
this
|
|
154
|
+
this.#dispatch( value, propertyName, storeName );
|
|
127
155
|
}
|
|
128
156
|
|
|
129
157
|
return value;
|
|
@@ -132,9 +160,6 @@ class GlobalState {
|
|
|
132
160
|
|
|
133
161
|
/**
|
|
134
162
|
* Get the value of a property. If there are only 2 arguments, the default store will be used.
|
|
135
|
-
*
|
|
136
|
-
* @param propertyName
|
|
137
|
-
* @param storeName
|
|
138
163
|
*/
|
|
139
164
|
get( propertyName: string, storeName = this.#DEFAULT_STORE_NAME ): any {
|
|
140
165
|
if ( !propertyName ) {
|
|
@@ -148,21 +173,21 @@ class GlobalState {
|
|
|
148
173
|
/**
|
|
149
174
|
* Bind a function to be called on all properties change
|
|
150
175
|
*/
|
|
151
|
-
registerOnEveryChange( callback:
|
|
152
|
-
if (
|
|
153
|
-
|
|
176
|
+
registerOnEveryChange( callback: FLib.GlobalState.Callback ): this {
|
|
177
|
+
if ( callback ) {
|
|
178
|
+
this.#GLOBAL_EVENTS_STORE.push( callback );
|
|
154
179
|
}
|
|
155
180
|
|
|
156
|
-
this
|
|
181
|
+
return this;
|
|
157
182
|
}
|
|
158
183
|
|
|
159
184
|
|
|
160
185
|
/**
|
|
161
186
|
* Bind a function to be called on all properties change for a specific store
|
|
162
187
|
*/
|
|
163
|
-
registerOnStoreChange( callback:
|
|
188
|
+
registerOnStoreChange( callback: FLib.GlobalState.Callback, storeName: string ): this {
|
|
164
189
|
if ( !callback || !storeName ) {
|
|
165
|
-
return;
|
|
190
|
+
return this;
|
|
166
191
|
}
|
|
167
192
|
|
|
168
193
|
if ( !this.#EVENTS_STORE[ storeName ] ) {
|
|
@@ -173,15 +198,17 @@ class GlobalState {
|
|
|
173
198
|
}
|
|
174
199
|
|
|
175
200
|
this.#EVENTS_STORE[ storeName ].functions.push( callback );
|
|
201
|
+
|
|
202
|
+
return this;
|
|
176
203
|
}
|
|
177
204
|
|
|
178
205
|
|
|
179
206
|
/**
|
|
180
207
|
* Bind a function to be called on a specific property change in a specific store
|
|
181
208
|
*/
|
|
182
|
-
registerOnPropertyChange( callback:
|
|
209
|
+
registerOnPropertyChange( callback: FLib.GlobalState.Callback, storeName: string, propertyName: string ): this {
|
|
183
210
|
if ( !callback || !storeName || !propertyName ) {
|
|
184
|
-
return;
|
|
211
|
+
return this;
|
|
185
212
|
}
|
|
186
213
|
if ( !this.#EVENTS_STORE[ storeName ] ) {
|
|
187
214
|
this.#EVENTS_STORE[ storeName ] = {
|
|
@@ -195,15 +222,17 @@ class GlobalState {
|
|
|
195
222
|
}
|
|
196
223
|
|
|
197
224
|
this.#EVENTS_STORE[ storeName ].props[ propertyName ].push( callback );
|
|
225
|
+
|
|
226
|
+
return this;
|
|
198
227
|
}
|
|
199
228
|
|
|
200
229
|
|
|
201
230
|
/**
|
|
202
231
|
* Unbind the registered function from all change events
|
|
203
232
|
*/
|
|
204
|
-
remove( callback:
|
|
233
|
+
remove( callback: FLib.GlobalState.Callback ): this {
|
|
205
234
|
if ( !callback ) {
|
|
206
|
-
return;
|
|
235
|
+
return this;
|
|
207
236
|
}
|
|
208
237
|
|
|
209
238
|
slice( this.#GLOBAL_EVENTS_STORE, callback );
|
|
@@ -214,31 +243,9 @@ class GlobalState {
|
|
|
214
243
|
slice( this.#EVENTS_STORE[ storeName ].props[ propertyName ], callback );
|
|
215
244
|
} );
|
|
216
245
|
} );
|
|
246
|
+
|
|
247
|
+
return this;
|
|
217
248
|
}
|
|
218
249
|
}
|
|
219
250
|
|
|
220
|
-
/**
|
|
221
|
-
* Manage a global object that allow storing and sharing values among modules.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* // Use the default storage
|
|
225
|
-
* const globalState = new GlobalState();
|
|
226
|
-
* globalState.set( 'PROP', 'VALUE' );
|
|
227
|
-
* globalState.get( 'PROP' );
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* // Use a storage with a specific name
|
|
231
|
-
* const globalState = new GlobalState();
|
|
232
|
-
* globalState.set( 'MY_STORE', 'PROP', 'VALUE' );
|
|
233
|
-
* globalState.get( 'MY_STORE', 'PROP' );
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* // To use events on properties change
|
|
237
|
-
* const globalState = new GlobalState({
|
|
238
|
-
* "dispatchEvents": true
|
|
239
|
-
* });
|
|
240
|
-
* globalState.registerOnEveryChange( (value, propertyName, storeName) => {} )
|
|
241
|
-
* globalState.registerOnStoreChange( (value, propertyName, storeName) => {}, 'storeName' )
|
|
242
|
-
* globalState.registerOnPropertyChange( (value, propertyName, storeName) => {}, 'storeName', 'myProperty' )
|
|
243
|
-
*/
|
|
244
251
|
export default GlobalState;
|
package/Modules/LoadGMap.ts
CHANGED
|
@@ -4,18 +4,17 @@ let gMapLoadingPromise;
|
|
|
4
4
|
/**
|
|
5
5
|
* Google Map loader
|
|
6
6
|
*
|
|
7
|
-
* @param apiUrl
|
|
8
|
-
* @param callbackFunctionName
|
|
9
|
-
*
|
|
10
7
|
* @example
|
|
8
|
+
* ```ts
|
|
11
9
|
* loadGMap( urlAPI ).then(
|
|
12
10
|
* googleAPI =>
|
|
13
11
|
* {
|
|
14
12
|
* new googleAPI.maps.Map( $container, googleMapOptions );
|
|
15
13
|
* }
|
|
16
14
|
* );
|
|
15
|
+
* ```
|
|
17
16
|
*
|
|
18
|
-
* @returns
|
|
17
|
+
* @returns - a promise resolved when the API is loaded
|
|
19
18
|
*/
|
|
20
19
|
export default function loadGMap( apiUrl: string, callbackFunctionName = 'initworldMap' ): Promise<typeof window.google> {
|
|
21
20
|
if ( gMapLoadingPromise ) {
|
|
@@ -36,13 +35,11 @@ export default function loadGMap( apiUrl: string, callbackFunctionName = 'initwo
|
|
|
36
35
|
|
|
37
36
|
|
|
38
37
|
gMapLoadingPromise = new Promise( function( resolve ) {
|
|
39
|
-
let script;
|
|
40
|
-
|
|
41
38
|
window[ callbackFunctionName ] = function() {
|
|
42
39
|
resolve( window.google );
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
script = document.createElement( 'script' );
|
|
42
|
+
const script = document.createElement( 'script' );
|
|
46
43
|
script.type = 'text/javascript';
|
|
47
44
|
script.src = apiUrl;
|
|
48
45
|
|