@creative-web-solution/front-library 7.0.6 → 7.1.2
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 +30 -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 +11 -17
- 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 +5 -6
- 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 +95 -0
- 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/Events/PubSub.ts
CHANGED
|
@@ -11,6 +11,7 @@ interface PubSub {
|
|
|
11
11
|
* Publish / Suscribe event system
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
|
+
* ```ts
|
|
14
15
|
* pubSub.add([ "MY_EVENT_1", "MY_EVENT_2" ]);
|
|
15
16
|
* pubSub.add( "MY_EVENT_3" );
|
|
16
17
|
*
|
|
@@ -25,6 +26,7 @@ interface PubSub {
|
|
|
25
26
|
* } );
|
|
26
27
|
*
|
|
27
28
|
* pubSub.fire( pubSub.MY_EVENT_2, { "myProp": "test" } );
|
|
29
|
+
* ```
|
|
28
30
|
*/
|
|
29
31
|
class PubSub {
|
|
30
32
|
#EVENTS_STORE = {};
|
|
@@ -54,7 +56,6 @@ class PubSub {
|
|
|
54
56
|
/**
|
|
55
57
|
* Fire an event
|
|
56
58
|
*
|
|
57
|
-
* @param eventName
|
|
58
59
|
* @param data - Data to be send to the callback functions
|
|
59
60
|
*/
|
|
60
61
|
fire( eventName: string, data? ): this {
|
|
@@ -70,10 +71,9 @@ class PubSub {
|
|
|
70
71
|
/**
|
|
71
72
|
* Bind an event
|
|
72
73
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @param callback - (data) => {}
|
|
74
|
+
* @param callback - (data) => `{}`
|
|
75
75
|
*/
|
|
76
|
-
on( eventName: string, callback:
|
|
76
|
+
on( eventName: string, callback: FLib.Events.PubSub.Callback ): this {
|
|
77
77
|
on( this.#EVENTS_STORE, {
|
|
78
78
|
"eventsName": eventName,
|
|
79
79
|
"callback": callback
|
|
@@ -85,11 +85,8 @@ class PubSub {
|
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Unbind an event
|
|
88
|
-
*
|
|
89
|
-
* @param eventName
|
|
90
|
-
* @param callback
|
|
91
88
|
*/
|
|
92
|
-
off( eventName: string, callback:
|
|
89
|
+
off( eventName: string, callback: FLib.Events.PubSub.Callback ): this {
|
|
93
90
|
off( this.#EVENTS_STORE, {
|
|
94
91
|
"eventsName": eventName,
|
|
95
92
|
"callback": callback
|
package/Events/TouchHover.ts
CHANGED
|
@@ -5,21 +5,18 @@ import { wait } from '../Helpers/Wait';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Simulate hover (on touch) on mobile device. Touch a second time to follow the link.
|
|
8
|
-
* @class
|
|
9
8
|
*
|
|
10
|
-
* @example
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* new TouchHover( {
|
|
11
12
|
* "cssClass": 'hover',
|
|
12
13
|
* "selector": '.link',
|
|
13
14
|
* "$wrapper": $myWrapper
|
|
14
15
|
* } );
|
|
15
|
-
*
|
|
16
|
-
* @param {Object} options
|
|
17
|
-
* @param {String} options.cssClass
|
|
18
|
-
* @param {String} options.selector
|
|
19
|
-
* @param {HTMLEvent} options.$wrapper
|
|
16
|
+
* ```
|
|
20
17
|
*/
|
|
21
18
|
export default class TouchHover {
|
|
22
|
-
#options:
|
|
19
|
+
#options: FLib.Events.TouchHover.Options;
|
|
23
20
|
#$lastElem: Element | null = null;
|
|
24
21
|
#hasClickOutsideListener: boolean;
|
|
25
22
|
|
|
@@ -29,7 +26,7 @@ export default class TouchHover {
|
|
|
29
26
|
#clickOutsideHandlerName = Symbol( 'touchhover2' );
|
|
30
27
|
|
|
31
28
|
|
|
32
|
-
constructor( options:
|
|
29
|
+
constructor( options: FLib.Events.TouchHover.Options ) {
|
|
33
30
|
this.#options = options;
|
|
34
31
|
this.#hasClickOutsideListener = false;
|
|
35
32
|
this.#options.$wrapper = this.#options.$wrapper || this.#$body;
|
|
@@ -40,7 +37,7 @@ export default class TouchHover {
|
|
|
40
37
|
|
|
41
38
|
gesture( this.#options.$wrapper, this.#gestureHandlerName, {
|
|
42
39
|
"selector": this.#options.selector,
|
|
43
|
-
"end": this
|
|
40
|
+
"end": this.#toggleClass.bind( this ),
|
|
44
41
|
"preventClick": ( e, $target ) => {
|
|
45
42
|
return $target[ this.#hasBeenTouchedOnce ];
|
|
46
43
|
}
|
|
@@ -48,7 +45,7 @@ export default class TouchHover {
|
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
#onClickOutside = ( e: Event, $target: HTMLElement ): void => {
|
|
52
49
|
|
|
53
50
|
if ( $target.closest( this.#options.selector ) ) {
|
|
54
51
|
return;
|
|
@@ -58,20 +55,20 @@ export default class TouchHover {
|
|
|
58
55
|
|
|
59
56
|
this.#hasClickOutsideListener = false;
|
|
60
57
|
|
|
61
|
-
this
|
|
58
|
+
this.#removeClass();
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
#addClass = ( $target: HTMLElement ): void => {
|
|
66
63
|
$target[ this.#hasBeenTouchedOnce ] = true;
|
|
67
64
|
|
|
68
|
-
aClass( $target, this.#options.cssClass );
|
|
65
|
+
aClass( $target as HTMLElement, this.#options.cssClass );
|
|
69
66
|
this.#$lastElem = $target;
|
|
70
67
|
|
|
71
68
|
if ( !this.#hasClickOutsideListener ) {
|
|
72
69
|
wait().then( () => {
|
|
73
70
|
gesture( this.#$body, this.#clickOutsideHandlerName, {
|
|
74
|
-
"end": this
|
|
71
|
+
"end": this.#onClickOutside.bind( this )
|
|
75
72
|
} );
|
|
76
73
|
} );
|
|
77
74
|
|
|
@@ -80,7 +77,7 @@ export default class TouchHover {
|
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
#removeClass = (): void => {
|
|
84
81
|
if ( this.#$lastElem ) {
|
|
85
82
|
rClass( this.#$lastElem, this.#options.cssClass );
|
|
86
83
|
|
|
@@ -90,24 +87,24 @@ export default class TouchHover {
|
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
|
|
93
|
-
|
|
90
|
+
#toggleClass = ( e: Event, $target: HTMLElement ): void => {
|
|
94
91
|
if ( $target !== this.#$lastElem ) {
|
|
95
|
-
this
|
|
92
|
+
this.#removeClass();
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
if ( $target[ this.#hasBeenTouchedOnce ] ) {
|
|
99
|
-
this
|
|
96
|
+
this.#removeClass();
|
|
100
97
|
return;
|
|
101
98
|
}
|
|
102
99
|
|
|
103
|
-
this
|
|
100
|
+
this.#addClass( $target );
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
|
|
107
104
|
/**
|
|
108
105
|
* Remove all binded events
|
|
109
106
|
*/
|
|
110
|
-
destroy() {
|
|
107
|
+
destroy(): this {
|
|
111
108
|
gestureOff( this.#options.$wrapper, this.#gestureHandlerName );
|
|
112
109
|
gestureOff( this.#$body, this.#clickOutsideHandlerName );
|
|
113
110
|
|
package/Events/WindowEvents.ts
CHANGED
|
@@ -5,17 +5,16 @@ import { windowSize } from '../DOM/WindowSize';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Window events handler
|
|
8
|
-
* @class
|
|
9
8
|
*
|
|
10
9
|
* @example
|
|
11
|
-
*
|
|
10
|
+
* ```ts
|
|
12
11
|
* let w = new WindowEvents( window );
|
|
13
12
|
*
|
|
14
|
-
* or to change throttle delay :
|
|
13
|
+
* // or to change throttle delay :
|
|
15
14
|
*
|
|
16
15
|
* let w = new WindowEvents( window, 150 );
|
|
17
16
|
*
|
|
18
|
-
* let callback = ( { windowInfo, scrollInfo, documentInfo, viewportInfo }, type, event )
|
|
17
|
+
* let callback = ( { windowInfo, scrollInfo, documentInfo, viewportInfo }, type, event ) => {};
|
|
19
18
|
*
|
|
20
19
|
* w.register( callback, 'resize' ); // type = 'resize', 'scroll' or undefined for both
|
|
21
20
|
* w.remove( callback, 'resize' );
|
|
@@ -34,6 +33,7 @@ import { windowSize } from '../DOM/WindowSize';
|
|
|
34
33
|
* { width, height } = w.windowInfo;
|
|
35
34
|
* { width, height } = w.documentInfo;
|
|
36
35
|
* { top, left, bottom, right, width, height } = w.viewportInfo;
|
|
36
|
+
* ```
|
|
37
37
|
*/
|
|
38
38
|
export default class WindowEvents {
|
|
39
39
|
|
|
@@ -52,21 +52,21 @@ export default class WindowEvents {
|
|
|
52
52
|
/**
|
|
53
53
|
* Get the last stored scroll position
|
|
54
54
|
*/
|
|
55
|
-
get scrollInfo() {
|
|
55
|
+
get scrollInfo(): FLib.Events.WindowEvents.ScrollInfo {
|
|
56
56
|
return this.#scrollInfo;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Get the last stored window size
|
|
61
61
|
*/
|
|
62
|
-
get windowInfo() {
|
|
62
|
+
get windowInfo(): FLib.Events.WindowEvents.WindowInfo {
|
|
63
63
|
return this.#windowInfo;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Get the last stored document size
|
|
68
68
|
*/
|
|
69
|
-
get documentInfo() {
|
|
69
|
+
get documentInfo(): FLib.Events.WindowEvents.DocumentInfo {
|
|
70
70
|
return this.#documentInfo;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -77,29 +77,29 @@ export default class WindowEvents {
|
|
|
77
77
|
* The viewport is the displayed part of the document.<br>
|
|
78
78
|
* So, its top and left are the scroll position and its width and height are the window size.<br>
|
|
79
79
|
*/
|
|
80
|
-
get viewportInfo() {
|
|
80
|
+
get viewportInfo(): FLib.Events.WindowEvents.ViewportInfo {
|
|
81
81
|
return this.#viewportInfo;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* @param $window - DOM object on which the events will be checked
|
|
87
|
-
* @param
|
|
87
|
+
* @param throttleDelay - Throttle delay in ms. If < 0, it use requestAnimationFrame
|
|
88
88
|
*/
|
|
89
|
-
constructor( $window, throttleDelay = -1 ) {
|
|
89
|
+
constructor( $window: HTMLElement | Window, throttleDelay = -1 ) {
|
|
90
90
|
this.#$window = $window;
|
|
91
91
|
this.#throttleDelay = throttleDelay;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
// Call each registered function for resize event
|
|
96
|
-
|
|
96
|
+
#updateResize = ( originalEvent?: Event ): void => {
|
|
97
97
|
if ( !this.#resizeFunctionSet.size ) {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
this.#resizeFunctionSet.forEach( fcn => {
|
|
102
|
-
( fcn as
|
|
102
|
+
( fcn as FLib.Events.WindowEvents.Callback )( {
|
|
103
103
|
"windowInfo": this.#windowInfo,
|
|
104
104
|
"scrollInfo": this.#scrollInfo,
|
|
105
105
|
"documentInfo": this.#documentInfo,
|
|
@@ -113,13 +113,13 @@ export default class WindowEvents {
|
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
// Call each registered function for scroll event
|
|
116
|
-
|
|
116
|
+
#updateScroll = ( originalEvent?: Event ): void => {
|
|
117
117
|
if ( !this.#scrollFunctionSet.size ) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
this.#scrollFunctionSet.forEach( fcn => {
|
|
122
|
-
( fcn as
|
|
122
|
+
( fcn as FLib.Events.WindowEvents.Callback )( {
|
|
123
123
|
"windowInfo": this.#windowInfo,
|
|
124
124
|
"scrollInfo": this.#scrollInfo,
|
|
125
125
|
"documentInfo": this.#documentInfo,
|
|
@@ -132,7 +132,7 @@ export default class WindowEvents {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
#updateValue = ( type?: FLib.Events.WindowEvents.Type ): void => {
|
|
136
136
|
if ( type !== 'resize' ) {
|
|
137
137
|
this.#scrollInfo = windowScroll();
|
|
138
138
|
}
|
|
@@ -152,7 +152,7 @@ export default class WindowEvents {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
#changeHandler = ( e: Event ) => {
|
|
155
|
+
#changeHandler = ( e: Event ): void => {
|
|
156
156
|
if ( this.#tick ) {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
@@ -162,7 +162,7 @@ export default class WindowEvents {
|
|
|
162
162
|
const FNC = ( ( ev: Event ) => {
|
|
163
163
|
return () => {
|
|
164
164
|
const TYPE = ev.type === 'scroll' ? 'scroll' : 'resize';
|
|
165
|
-
this
|
|
165
|
+
this.#updateValue( TYPE );
|
|
166
166
|
this.refresh( TYPE, ev );
|
|
167
167
|
this.#tick = false;
|
|
168
168
|
}
|
|
@@ -180,10 +180,9 @@ export default class WindowEvents {
|
|
|
180
180
|
/**
|
|
181
181
|
* Register a function on a type of event
|
|
182
182
|
*
|
|
183
|
-
* @param callback
|
|
184
183
|
* @param type - resize | scroll | undefined (both)
|
|
185
184
|
*/
|
|
186
|
-
register( callback:
|
|
185
|
+
register( callback: FLib.Events.WindowEvents.Callback, type?: FLib.Events.WindowEvents.Type ): this {
|
|
187
186
|
if ( type !== 'scroll' ) {
|
|
188
187
|
this.#resizeFunctionSet.add( callback );
|
|
189
188
|
}
|
|
@@ -195,7 +194,7 @@ export default class WindowEvents {
|
|
|
195
194
|
if ( !this.#isActive && ( this.#resizeFunctionSet.size || this.#scrollFunctionSet.size ) ) {
|
|
196
195
|
this.#$window.addEventListener( 'resize', this.#changeHandler );
|
|
197
196
|
this.#$window.addEventListener( 'scroll', this.#changeHandler );
|
|
198
|
-
this
|
|
197
|
+
this.#updateValue();
|
|
199
198
|
this.#isActive = true;
|
|
200
199
|
}
|
|
201
200
|
|
|
@@ -206,10 +205,9 @@ export default class WindowEvents {
|
|
|
206
205
|
/**
|
|
207
206
|
* Unregister a function for a type of event
|
|
208
207
|
*
|
|
209
|
-
* @param callback
|
|
210
208
|
* @param type - resize | scroll | undefined (both)
|
|
211
209
|
*/
|
|
212
|
-
remove( callback:
|
|
210
|
+
remove( callback: FLib.Events.WindowEvents.Callback, type?: FLib.Events.WindowEvents.Type ): this {
|
|
213
211
|
if ( type !== 'scroll' ) {
|
|
214
212
|
this.#resizeFunctionSet.delete( callback );
|
|
215
213
|
}
|
|
@@ -234,8 +232,8 @@ export default class WindowEvents {
|
|
|
234
232
|
*
|
|
235
233
|
* @param type - resize | scroll | undefined (both)
|
|
236
234
|
*/
|
|
237
|
-
update( type?:
|
|
238
|
-
this
|
|
235
|
+
update( type?: FLib.Events.WindowEvents.Type ): this {
|
|
236
|
+
this.#updateValue( type );
|
|
239
237
|
|
|
240
238
|
return this;
|
|
241
239
|
}
|
|
@@ -246,13 +244,13 @@ export default class WindowEvents {
|
|
|
246
244
|
*
|
|
247
245
|
* @param type - resize | scroll | undefined (both)
|
|
248
246
|
*/
|
|
249
|
-
refresh( type?:
|
|
247
|
+
refresh( type?: FLib.Events.WindowEvents.Type , _oe?: Event ): this {
|
|
250
248
|
if ( type !== 'scroll' ) {
|
|
251
|
-
this
|
|
249
|
+
this.#updateResize( _oe );
|
|
252
250
|
}
|
|
253
251
|
|
|
254
252
|
if ( type !== 'resize' ) {
|
|
255
|
-
this
|
|
253
|
+
this.#updateScroll( _oe );
|
|
256
254
|
}
|
|
257
255
|
|
|
258
256
|
return this;
|
|
@@ -261,10 +259,8 @@ export default class WindowEvents {
|
|
|
261
259
|
|
|
262
260
|
/**
|
|
263
261
|
* Call a function with the last stored positions and sizes
|
|
264
|
-
*
|
|
265
|
-
* @param callback
|
|
266
262
|
*/
|
|
267
|
-
get( callback:
|
|
263
|
+
get( callback: FLib.Events.WindowEvents.Callback ): this {
|
|
268
264
|
callback({
|
|
269
265
|
"windowInfo": this.#windowInfo,
|
|
270
266
|
"scrollInfo": this.#scrollInfo,
|
package/Helpers/Colors.ts
CHANGED
|
@@ -25,8 +25,6 @@ function toHexValue( c: number ): string {
|
|
|
25
25
|
/**
|
|
26
26
|
* Convert a rgba string to a hex string
|
|
27
27
|
*
|
|
28
|
-
* @param rgba
|
|
29
|
-
*
|
|
30
28
|
* @example
|
|
31
29
|
* rgbaToHex( 'rgb(125 ,233, 105)' );
|
|
32
30
|
*
|
|
@@ -41,8 +39,6 @@ export function rgbaToHex( rgba: string ): string {
|
|
|
41
39
|
/**
|
|
42
40
|
* Convert a hex string to a rgba string
|
|
43
41
|
*
|
|
44
|
-
* @param hex
|
|
45
|
-
*
|
|
46
42
|
* @example
|
|
47
43
|
* hexToRgba( '#F5C' );
|
|
48
44
|
*
|
|
@@ -57,8 +53,6 @@ export function hexToRgba( hex: string ): string {
|
|
|
57
53
|
/**
|
|
58
54
|
* Return true if the string is an rgb or rgba color
|
|
59
55
|
*
|
|
60
|
-
* @param rgba
|
|
61
|
-
*
|
|
62
56
|
* @example
|
|
63
57
|
* isRGBA( 'rgb(125 ,233, 105)' );
|
|
64
58
|
*
|
|
@@ -74,8 +68,6 @@ export function isRGBA( rgba: string ): boolean {
|
|
|
74
68
|
/**
|
|
75
69
|
* Return true if the string is an hexadecimal color
|
|
76
70
|
*
|
|
77
|
-
* @param hexColor
|
|
78
|
-
*
|
|
79
71
|
* @example
|
|
80
72
|
* isHexColor( '#FFF' );
|
|
81
73
|
*
|
|
@@ -93,15 +85,13 @@ export function isHexColor( hexColor: string ): boolean {
|
|
|
93
85
|
/**
|
|
94
86
|
* Split an rgb or rgba color
|
|
95
87
|
*
|
|
96
|
-
* @param rgba
|
|
97
|
-
*
|
|
98
88
|
* @example
|
|
99
89
|
* splitRGBA( 'rgb(125 ,233, 105)' );
|
|
100
90
|
*
|
|
101
91
|
* @example
|
|
102
92
|
* splitRGBA( 'rgba(125 ,233, 105, 0.75)' );
|
|
103
93
|
*/
|
|
104
|
-
export function splitRGBA( rgba: string ):
|
|
94
|
+
export function splitRGBA( rgba: string ): FLib.Helpers.Color.Color {
|
|
105
95
|
|
|
106
96
|
const parts: number[] = rgba
|
|
107
97
|
.replace( RGBA_CLEAN_1, '' )
|
|
@@ -133,8 +123,6 @@ export function splitRGBA( rgba: string ): ColorType {
|
|
|
133
123
|
/**
|
|
134
124
|
* Split an hexadecimal color
|
|
135
125
|
*
|
|
136
|
-
* @param hexColor
|
|
137
|
-
*
|
|
138
126
|
* @example
|
|
139
127
|
* splitHexColor( '#F5A' );
|
|
140
128
|
*
|
|
@@ -145,7 +133,7 @@ export function splitRGBA( rgba: string ): ColorType {
|
|
|
145
133
|
* // With alpha
|
|
146
134
|
* splitHexColor( '#FA58ACCC' );
|
|
147
135
|
*/
|
|
148
|
-
export function splitHexColor( hexColor: string ):
|
|
136
|
+
export function splitHexColor( hexColor: string ): FLib.Helpers.Color.Color {
|
|
149
137
|
let alpha;
|
|
150
138
|
|
|
151
139
|
hexColor = hexColor.slice( 1 );
|
|
@@ -185,12 +173,10 @@ export function splitHexColor( hexColor: string ): ColorType {
|
|
|
185
173
|
/**
|
|
186
174
|
* Format an object color to an hex color
|
|
187
175
|
*
|
|
188
|
-
* @param color
|
|
189
|
-
*
|
|
190
176
|
* @example
|
|
191
177
|
* formatHexColor( color );
|
|
192
178
|
*/
|
|
193
|
-
export function formatHexColor( color:
|
|
179
|
+
export function formatHexColor( color: FLib.Helpers.Color.Color ): string {
|
|
194
180
|
return `#${ color.hr }${ color.hg }${ color.hb }${ color.a !== 1 ? color.ha : '' }`;
|
|
195
181
|
}
|
|
196
182
|
|
|
@@ -198,13 +184,11 @@ export function formatHexColor( color: ColorType ): string {
|
|
|
198
184
|
/**
|
|
199
185
|
* Format an object color to an rgba color
|
|
200
186
|
*
|
|
201
|
-
* @param color
|
|
202
|
-
*
|
|
203
187
|
* @example
|
|
204
188
|
* formatRGBAColor( color );
|
|
205
189
|
*
|
|
206
190
|
*/
|
|
207
|
-
export function formatRGBAColor( color:
|
|
191
|
+
export function formatRGBAColor( color: FLib.Helpers.Color.Color ): string {
|
|
208
192
|
if ( color.a !== 1 ) {
|
|
209
193
|
return `rgba(${ color.r },${ color.g },${ color.b },${ color.a })`;
|
|
210
194
|
}
|
|
@@ -239,7 +223,7 @@ export function formatRGBAColor( color: ColorType ): string {
|
|
|
239
223
|
* let blendedcolor1 = shadeBlend( color1, color2, 0.333 );
|
|
240
224
|
* let blendedcolor34 = shadeBlend( color3, color4, -0.8 );
|
|
241
225
|
*/
|
|
242
|
-
export function shadeBlend( color1: string, color2: string | null, percent: number, render:
|
|
226
|
+
export function shadeBlend( color1: string, color2: string | null, percent: number, render: FLib.Helpers.Color.RenderType = 'obj' ): FLib.Helpers.Color.Color | string {
|
|
243
227
|
let color;
|
|
244
228
|
|
|
245
229
|
const coef = Math.abs( percent );
|
|
@@ -282,7 +266,7 @@ export function shadeBlend( color1: string, color2: string | null, percent: numb
|
|
|
282
266
|
* @param percent - Percent (between 0 and 1)
|
|
283
267
|
* @param render - render type: obj, hex or rgba
|
|
284
268
|
*/
|
|
285
|
-
export function lighten( color: string, percent: number, render:
|
|
269
|
+
export function lighten( color: string, percent: number, render: FLib.Helpers.Color.RenderType = 'obj' ): FLib.Helpers.Color.Color | string {
|
|
286
270
|
return shadeBlend( color, null, Math.abs( percent ), render );
|
|
287
271
|
}
|
|
288
272
|
|
|
@@ -294,6 +278,6 @@ export function lighten( color: string, percent: number, render: ColorRenderType
|
|
|
294
278
|
* @param percent - Percent (between 0 and 1)
|
|
295
279
|
* @param render - render type: obj, hex or rgba
|
|
296
280
|
*/
|
|
297
|
-
export function darken( color: string, percent: number, render:
|
|
281
|
+
export function darken( color: string, percent: number, render: FLib.Helpers.Color.RenderType = 'obj' ): FLib.Helpers.Color.Color | string {
|
|
298
282
|
return shadeBlend( color, null, percent > 0 ? percent * -1 : percent, render );
|
|
299
283
|
}
|
package/Helpers/Cookie.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const defaultOptions:
|
|
1
|
+
const defaultOptions: FLib.Helpers.Cookie.Options = {
|
|
2
2
|
"days": null,
|
|
3
3
|
"secure": window.location.protocol.indexOf('https') > -1,
|
|
4
4
|
"domain": window.location.hostname,
|
|
@@ -8,9 +8,9 @@ const defaultOptions: CookieOptionsType = {
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Manage cookie
|
|
11
|
-
* @class
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
13
|
+
* ```ts
|
|
14
14
|
* cookie.create( 'cookieName', 'cookieValue' )
|
|
15
15
|
* cookie.read( 'cookieName' )
|
|
16
16
|
* cookie.delete( 'cookieName' )
|
|
@@ -22,20 +22,17 @@ const defaultOptions: CookieOptionsType = {
|
|
|
22
22
|
* "domain": "test.com",
|
|
23
23
|
* "path": "/myDir"
|
|
24
24
|
* } );
|
|
25
|
+
* ```
|
|
25
26
|
*/
|
|
26
27
|
class Cookie {
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Create a cookie
|
|
30
|
-
*
|
|
31
|
-
* @param name
|
|
32
|
-
* @param value
|
|
33
|
-
* @param userOptions
|
|
34
31
|
*/
|
|
35
|
-
create( name: string, value: string, userOptions
|
|
32
|
+
create( name: string, value: string, userOptions: Partial<FLib.Helpers.Cookie.Options> = {} ): this {
|
|
36
33
|
let date;
|
|
37
34
|
|
|
38
|
-
const { days, secure, domain, path } = Object.assign( defaultOptions, userOptions
|
|
35
|
+
const { days, secure, domain, path } = Object.assign( defaultOptions, userOptions );
|
|
39
36
|
|
|
40
37
|
const cookieText: string[] = [];
|
|
41
38
|
|
|
@@ -65,8 +62,6 @@ class Cookie {
|
|
|
65
62
|
|
|
66
63
|
/**
|
|
67
64
|
* Read a cookie
|
|
68
|
-
*
|
|
69
|
-
* @param name
|
|
70
65
|
*/
|
|
71
66
|
read( name: string ): string {
|
|
72
67
|
let c;
|
|
@@ -89,8 +84,6 @@ class Cookie {
|
|
|
89
84
|
|
|
90
85
|
/**
|
|
91
86
|
* Delete a cookie
|
|
92
|
-
*
|
|
93
|
-
* @param name
|
|
94
87
|
*/
|
|
95
88
|
delete( name: string ): this {
|
|
96
89
|
this.create( name, '' );
|
package/Helpers/Coordinates.ts
CHANGED
|
@@ -5,13 +5,6 @@ function degToRad( angle: number ): number {
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Compute the distance (in km) between 2 coordinates
|
|
8
|
-
*
|
|
9
|
-
* @param latitude1
|
|
10
|
-
* @param longitude1
|
|
11
|
-
* @param latitude2
|
|
12
|
-
* @param longitude2
|
|
13
|
-
*
|
|
14
|
-
* @return The distance in kilometers between 2 points
|
|
15
8
|
*/
|
|
16
9
|
export function distance( latitude1: number, longitude1: number, latitude2: number, longitude2: number ): number {
|
|
17
10
|
let dist: number;
|
package/Helpers/Debounce.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Debounce
|
|
3
3
|
*
|
|
4
|
-
* @param callback
|
|
5
|
-
* @param threshold
|
|
6
|
-
* @param immediate
|
|
7
|
-
*
|
|
8
4
|
* @example
|
|
9
5
|
* debouncedFunction = debounce( myFunction, 200 )
|
|
10
6
|
*/
|
|
11
7
|
export function debounce(
|
|
12
8
|
callback: ( ...args: any[] ) => void,
|
|
13
9
|
threshold = 100,
|
|
14
|
-
immediate
|
|
10
|
+
immediate = false
|
|
15
11
|
): ( ...args: any[] ) => void {
|
|
16
|
-
let timeout: ReturnType<typeof setTimeout> |
|
|
12
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
17
13
|
|
|
18
14
|
return function<Type>( this: Type, ...args: any[] ) {
|
|
19
15
|
|
|
20
16
|
const later = () => {
|
|
21
|
-
timeout =
|
|
17
|
+
timeout = undefined;
|
|
22
18
|
|
|
23
19
|
if ( !immediate ) {
|
|
24
20
|
callback.apply( this, args );
|
package/Helpers/Defer.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* // To reject:
|
|
11
11
|
* dfd.reject()
|
|
12
12
|
*
|
|
13
|
-
* @returns
|
|
13
|
+
* @returns - a promise with a resolve and reject function
|
|
14
14
|
*/
|
|
15
15
|
export function defer(): Promise<any> & { resolve: ( a?: any ) => void; reject: ( a?: any ) => void; } {
|
|
16
16
|
let res: (a: any ) => void,
|
package/Helpers/GetValue.ts
CHANGED
package/Helpers/Insert.ts
CHANGED
package/Helpers/Sequential.ts
CHANGED
package/Helpers/Slice.ts
CHANGED