@creative-web-solution/front-library 7.0.7 → 7.1.0
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 +15 -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 +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 +13 -22
- package/Helpers/Wait.ts +1 -1
- package/Modules/Accordion/Tab.ts +18 -16
- package/Modules/Accordion/index.ts +24 -16
- 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 +11 -11
- package/Modules/Popin/PopinController.ts +23 -29
- package/Modules/Popin/Tools.ts +18 -19
- package/Modules/QuickTemplate.ts +4 -6
- package/Modules/ScrollSnap.ts +110 -104
- package/Modules/SkinCheckbox.ts +51 -37
- package/Modules/SkinFile.ts +62 -52
- package/Modules/SkinRadio.ts +62 -42
- package/Modules/SkinSelect.ts +116 -100
- 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 +27 -23
- package/Modules/Tabs/index.ts +35 -25
- package/Modules/Validator/Date.ts +2 -1
- package/Modules/Validator/Equals.ts +1 -1
- package/Modules/Validator/Internal/Input.ts +370 -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 +36 -0
- package/Types/Autocomplete.d.ts +95 -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 +30 -0
- package/Types/Notifications.d.ts +48 -44
- package/Types/Popin.d.ts +95 -0
- package/Types/ScrollSnap.d.ts +66 -0
- package/Types/SkinCheckbox.d.ts +26 -0
- package/Types/SkinFile.d.ts +38 -0
- package/Types/SkinRadio.d.ts +28 -0
- package/Types/SkinSelect.d.ts +59 -0
- package/Types/Slider.d.ts +106 -0
- package/Types/Tabs.d.ts +26 -0
- package/Types/Validator.d.ts +72 -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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## 7.1.0
|
|
5
|
+
|
|
6
|
+
* Typescript cleanup
|
|
7
|
+
* Remove micro templating modules
|
|
8
|
+
* Fix Validator missing files
|
|
9
|
+
|
|
10
|
+
**Compatibility warning:**
|
|
11
|
+
|
|
12
|
+
* SkinSelect: Change templating system
|
|
13
|
+
* Popin: Change templating system
|
|
14
|
+
* onImageLoad and onAllImagesLoad:
|
|
15
|
+
* Update function signature
|
|
16
|
+
* Update callback param from array to hash
|
|
17
|
+
|
|
18
|
+
|
|
4
19
|
## 7.0.7
|
|
5
20
|
|
|
6
21
|
* Add transition helpers function : `transitionWatcher`, `animationWatcher` and `killWatcher`
|
package/DOM/Class.ts
CHANGED
|
@@ -11,7 +11,7 @@ function normalizeCssClass( cssClass: string[] | string ): string[] {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
function isIterable( obj:
|
|
14
|
+
function isIterable( obj: FLib.DOM.ClassInput ): boolean {
|
|
15
15
|
return ( obj instanceof NodeList || obj instanceof Array ) && typeof obj.forEach !== 'undefined'
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -30,7 +30,7 @@ function applyToggle( $element: Element, cleanedCssClass: string[], forceAdd?: b
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
// Use to toggle class only
|
|
33
|
-
function classToggle( $elements:
|
|
33
|
+
function classToggle( $elements: FLib.DOM.ClassInput, cssClass: string | string[], forceAdd?: boolean ): FLib.DOM.ClassInput {
|
|
34
34
|
const cleanedCssClass: string[] = normalizeCssClass( cssClass );
|
|
35
35
|
|
|
36
36
|
if ( isIterable( $elements ) ) {
|
|
@@ -47,7 +47,7 @@ function classToggle( $elements: ClassInputType, cssClass: string | string[], fo
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
// Used to add/remove class only
|
|
50
|
-
function classChange( $elements:
|
|
50
|
+
function classChange( $elements: FLib.DOM.ClassInput, cssClass: string | string[], add: boolean ): FLib.DOM.ClassInput {
|
|
51
51
|
const functionName: 'add' | 'remove' = add ? 'add' : 'remove';
|
|
52
52
|
const cleanedCssClass: string[] = normalizeCssClass( cssClass );
|
|
53
53
|
|
|
@@ -86,8 +86,6 @@ function classReplace( $element: Element, oldCssClass: string, newCssClass:strin
|
|
|
86
86
|
*
|
|
87
87
|
* @example
|
|
88
88
|
* boolean = hClass( $element, "css-class" )
|
|
89
|
-
*
|
|
90
|
-
* @return - true if a class is present on a DOM element
|
|
91
89
|
*/
|
|
92
90
|
export function hClass( $element: Element, cssClass: string ): boolean {
|
|
93
91
|
return $element.classList.contains( cssClass );
|
|
@@ -105,7 +103,7 @@ export function hClass( $element: Element, cssClass: string ): boolean {
|
|
|
105
103
|
*
|
|
106
104
|
* @returns $elements
|
|
107
105
|
*/
|
|
108
|
-
export function aClass( $elements:
|
|
106
|
+
export function aClass( $elements: FLib.DOM.ClassInput, cssClass: string | string[] ): FLib.DOM.ClassInput {
|
|
109
107
|
return classChange( $elements, cssClass, true );
|
|
110
108
|
}
|
|
111
109
|
|
|
@@ -120,7 +118,7 @@ export function aClass( $elements: ClassInputType, cssClass: string | string[] )
|
|
|
120
118
|
*
|
|
121
119
|
* @returns $elements
|
|
122
120
|
*/
|
|
123
|
-
export function rClass( $elements:
|
|
121
|
+
export function rClass( $elements: FLib.DOM.ClassInput, cssClass: string | string[] ): FLib.DOM.ClassInput {
|
|
124
122
|
return classChange( $elements, cssClass, false );
|
|
125
123
|
}
|
|
126
124
|
|
|
@@ -140,7 +138,7 @@ export function rClass( $elements: ClassInputType, cssClass: string | string[] )
|
|
|
140
138
|
*
|
|
141
139
|
* @returns $elements
|
|
142
140
|
*/
|
|
143
|
-
export function tClass( $elements:
|
|
141
|
+
export function tClass( $elements: FLib.DOM.ClassInput, cssClass: string | string[], forceAdd?: boolean ): FLib.DOM.ClassInput {
|
|
144
142
|
return classToggle(
|
|
145
143
|
$elements,
|
|
146
144
|
cssClass,
|
|
@@ -153,16 +151,16 @@ export function tClass( $elements: ClassInputType, cssClass: string | string[],
|
|
|
153
151
|
* Replace a css class by another.
|
|
154
152
|
* Remove oldCssClass and add newCssClass only if oldCssClass exists
|
|
155
153
|
*
|
|
156
|
-
* @param $elements
|
|
157
|
-
* @param oldCssClass
|
|
158
|
-
* @param newCssClass
|
|
154
|
+
* @param $elements - DOM element or array of DOM element
|
|
155
|
+
* @param oldCssClass - Class name to replace
|
|
156
|
+
* @param newCssClass - Class name used to replace the old one
|
|
159
157
|
*
|
|
160
158
|
* @example
|
|
161
159
|
* sClass( $elements, "old-css-class", "new-css-class" )
|
|
162
160
|
*
|
|
163
161
|
* @returns $elements
|
|
164
162
|
*/
|
|
165
|
-
export function sClass( $elements:
|
|
163
|
+
export function sClass( $elements: FLib.DOM.ClassInput, oldCssClass: string, newCssClass: string ): FLib.DOM.ClassInput {
|
|
166
164
|
|
|
167
165
|
if ( isIterable( $elements ) ) {
|
|
168
166
|
($elements as Element[]).forEach( $element => {
|
package/DOM/DocumentSize.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Get the current document size
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
|
+
* ```ts
|
|
5
6
|
* { width, height } = documentSize()
|
|
7
|
+
* ```
|
|
6
8
|
*/
|
|
7
|
-
export function documentSize():
|
|
9
|
+
export function documentSize(): FLib.DOM.Size {
|
|
8
10
|
return {
|
|
9
11
|
"height": document.documentElement.scrollHeight,
|
|
10
12
|
"width": document.documentElement.scrollWidth
|
package/DOM/Filter.ts
CHANGED
package/DOM/Index.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Return the index of a DOM element
|
|
3
3
|
*
|
|
4
|
-
* @param $element
|
|
5
|
-
*
|
|
6
4
|
* @example
|
|
7
5
|
* elementIndex = index( $element );
|
|
8
6
|
*
|
|
9
7
|
* @returns - Position (starting at 0) of the element in the DOM list is belong to. -1 if there is no parentNode.
|
|
10
8
|
*/
|
|
11
9
|
export function index( $element: Element ): number {
|
|
12
|
-
let $child: ChildNode |
|
|
10
|
+
let $child: ChildNode | null, idx: number;
|
|
13
11
|
|
|
14
12
|
if ( !$element.parentNode ) {
|
|
15
13
|
return -1;
|
package/DOM/Manipulation.ts
CHANGED
|
@@ -70,8 +70,6 @@ export function insertAfter( $what: Element, $after: Element ): Element {
|
|
|
70
70
|
/**
|
|
71
71
|
* Clone a DOM element
|
|
72
72
|
*
|
|
73
|
-
* @param $element
|
|
74
|
-
*
|
|
75
73
|
* @example
|
|
76
74
|
* $clonedElement = clone( $element )
|
|
77
75
|
*
|
|
@@ -85,7 +83,6 @@ export function clone( $element: Node ): Node {
|
|
|
85
83
|
/**
|
|
86
84
|
* Remove an element from the DOM
|
|
87
85
|
*
|
|
88
|
-
* @param $element
|
|
89
86
|
* @param $parentNode - If undefined the parentNode will be used
|
|
90
87
|
*
|
|
91
88
|
* @example
|
package/DOM/Matrix.ts
CHANGED
|
@@ -4,15 +4,15 @@ import { transformPropertyName } from '../Tools/PrefixedProperties';
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the matrix of a DOM element
|
|
6
6
|
*
|
|
7
|
-
* @param $elem
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
8
|
+
* ```ts
|
|
10
9
|
* { m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44 } = getMatrix ( $elem )
|
|
10
|
+
* ```
|
|
11
11
|
*
|
|
12
12
|
* @returns the translate properties
|
|
13
13
|
*/
|
|
14
|
-
export function getMatrix( $elem: Element ):
|
|
15
|
-
let matrix:
|
|
14
|
+
export function getMatrix( $elem: Element ): FLib.Matrix.Matrix {
|
|
15
|
+
let matrix: FLib.Matrix.Matrix;
|
|
16
16
|
|
|
17
17
|
const matrixString = prop( $elem, transformPropertyName );
|
|
18
18
|
const c = matrixString.split( /\s*[(),]\s*/ ).slice( 1, -1 );
|
|
@@ -88,15 +88,15 @@ export function getMatrix( $elem: Element ): MatrixMatrixType {
|
|
|
88
88
|
/**
|
|
89
89
|
* Get the translation values of a DOM element
|
|
90
90
|
*
|
|
91
|
-
* @param $elem
|
|
92
|
-
*
|
|
93
91
|
* @example
|
|
92
|
+
* ```ts
|
|
94
93
|
* { tx, ty, tz } = getTranslate ( $elem )
|
|
94
|
+
* ```
|
|
95
95
|
*
|
|
96
96
|
* @returns the translate properties
|
|
97
97
|
*/
|
|
98
|
-
export function getTranslate( $elem: Element ):
|
|
99
|
-
const matrix:
|
|
98
|
+
export function getTranslate( $elem: Element ): FLib.Matrix.Translate {
|
|
99
|
+
const matrix: FLib.Matrix.Matrix = getMatrix( $elem );
|
|
100
100
|
|
|
101
101
|
return {
|
|
102
102
|
"tx": matrix.m41,
|
|
@@ -109,17 +109,17 @@ export function getTranslate( $elem: Element ): MatrixTranslateType {
|
|
|
109
109
|
/**
|
|
110
110
|
* Get the transform values of a DOM element
|
|
111
111
|
*
|
|
112
|
-
* @param $elem
|
|
113
|
-
*
|
|
114
112
|
* @example
|
|
113
|
+
* ```ts
|
|
115
114
|
* { tx, ty, tz, rx, ry, rz } = getTransform ( $elem )
|
|
115
|
+
* ```
|
|
116
116
|
*
|
|
117
117
|
* @returns the transform properties
|
|
118
118
|
*/
|
|
119
|
-
export function getTransform( $elem: Element ):
|
|
119
|
+
export function getTransform( $elem: Element ): FLib.Matrix.Transform {
|
|
120
120
|
let rotateX: number, rotateZ: number;
|
|
121
121
|
|
|
122
|
-
const matrix:
|
|
122
|
+
const matrix: FLib.Matrix.Matrix = getMatrix( $elem );
|
|
123
123
|
const rotateY: number = Math.asin( -matrix.m13 );
|
|
124
124
|
|
|
125
125
|
if ( Math.cos(rotateY) !== 0 ) {
|
package/DOM/Offset.ts
CHANGED
|
@@ -10,26 +10,25 @@ function getWindow( $element: Window | Document ): Window | null {
|
|
|
10
10
|
/**
|
|
11
11
|
* Get the transform values of a DOM element
|
|
12
12
|
*
|
|
13
|
-
* @param $element
|
|
14
13
|
* @param isRelativeToViewport - If true, the position is computed relatively to the viewport (top/left of the browser) and not the top/left of the document. This mean, it doesn't take the scroll in count.
|
|
15
14
|
* @param $relativeTo - Optional, compute top and left relatively to another Element
|
|
16
15
|
*
|
|
17
16
|
* @example
|
|
17
|
+
* ```ts
|
|
18
18
|
* // Get offset from the top/left of the document
|
|
19
19
|
* { width, height, top, left, bottom, right } = offset( $element )
|
|
20
20
|
*
|
|
21
|
-
* @example
|
|
22
21
|
* // Same without taking the scroll position in count (top/left of the browser).
|
|
23
22
|
* result = offset( $element, true )
|
|
24
23
|
*
|
|
25
|
-
* @example
|
|
26
24
|
* // Get offset relatively from another element
|
|
27
25
|
* result = offset( $element, false, $target )
|
|
26
|
+
* ```
|
|
28
27
|
*
|
|
29
28
|
* @returns the offset properties
|
|
30
29
|
*/
|
|
31
|
-
export function offset( $element: Element, isRelativeToViewport?: boolean, $relativeTo?: Element ):
|
|
32
|
-
let $window, rootValue, box:
|
|
30
|
+
export function offset( $element: Element, isRelativeToViewport?: boolean, $relativeTo?: Element ): FLib.DOM.Offset {
|
|
31
|
+
let $window, rootValue, box: FLib.DOM.Offset;
|
|
33
32
|
|
|
34
33
|
box = { "top": 0, "y": 0, "left": 0, "x": 0, "right": 0, "bottom": 0, "width": 0, "height": 0 };
|
|
35
34
|
const $document = $element && $element.ownerDocument;
|
package/DOM/OuterSize.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { getStyle } from './Styles';
|
|
|
3
3
|
|
|
4
4
|
function getOuterDim(
|
|
5
5
|
$element: HTMLElement,
|
|
6
|
-
border
|
|
7
|
-
margin
|
|
6
|
+
border = false,
|
|
7
|
+
margin = false,
|
|
8
8
|
dimensionName?: string
|
|
9
|
-
):
|
|
9
|
+
): FLib.DOM.Size {
|
|
10
10
|
let size, elementStyle;
|
|
11
11
|
|
|
12
12
|
|
|
@@ -43,21 +43,21 @@ function getOuterDim(
|
|
|
43
43
|
/**
|
|
44
44
|
* Get the outside width of a DOM element
|
|
45
45
|
*
|
|
46
|
-
* @param $element
|
|
47
46
|
* @param border - Include border width?
|
|
48
47
|
* @param margin - Include margin width?
|
|
49
48
|
*
|
|
50
49
|
* @example
|
|
50
|
+
* ```ts
|
|
51
51
|
* // width including padding
|
|
52
52
|
* elementWidth = outerWidth($element)
|
|
53
53
|
*
|
|
54
|
-
* @example
|
|
55
54
|
* // width including padding, border and margin
|
|
56
55
|
* elementWidth = outerWidth($element, true, true)
|
|
56
|
+
* ```
|
|
57
57
|
*
|
|
58
58
|
* @returns The width of the object
|
|
59
59
|
*/
|
|
60
|
-
export function outerWidth( $element: HTMLElement, border
|
|
60
|
+
export function outerWidth( $element: HTMLElement, border = false, margin = false ): number {
|
|
61
61
|
return getOuterDim(
|
|
62
62
|
$element,
|
|
63
63
|
border,
|
|
@@ -70,21 +70,21 @@ export function outerWidth( $element: HTMLElement, border: boolean = false, marg
|
|
|
70
70
|
/**
|
|
71
71
|
* Get the outside height of a DOM element
|
|
72
72
|
*
|
|
73
|
-
* @param $element
|
|
74
73
|
* @param border - Include border width?
|
|
75
74
|
* @param margin - Include margin width?
|
|
76
75
|
*
|
|
77
76
|
* @example
|
|
77
|
+
* ```ts
|
|
78
78
|
* // height including padding
|
|
79
79
|
* elementHeight = outerHeight($element)
|
|
80
80
|
*
|
|
81
|
-
* @example
|
|
82
81
|
* // height including padding, border and margin
|
|
83
82
|
* elementHeight = outerHeight($element, true, true)
|
|
83
|
+
* ```
|
|
84
84
|
*
|
|
85
85
|
* @returns the height of the object
|
|
86
86
|
*/
|
|
87
|
-
export function outerHeight( $element: HTMLElement, border
|
|
87
|
+
export function outerHeight( $element: HTMLElement, border = false, margin = false ): number {
|
|
88
88
|
return getOuterDim(
|
|
89
89
|
$element,
|
|
90
90
|
border,
|
|
@@ -97,21 +97,21 @@ export function outerHeight( $element: HTMLElement, border: boolean = false, mar
|
|
|
97
97
|
/**
|
|
98
98
|
* Get the outside size of a DOM element
|
|
99
99
|
*
|
|
100
|
-
* @param $element
|
|
101
100
|
* @param border - Include border width?
|
|
102
101
|
* @param margin - Include margin width?
|
|
103
102
|
*
|
|
104
103
|
* @example
|
|
104
|
+
* ```ts
|
|
105
105
|
* // size including padding
|
|
106
106
|
* {width, height} = outerSize($element)
|
|
107
107
|
*
|
|
108
|
-
* @example
|
|
109
108
|
* // height including padding, border and margin
|
|
110
109
|
* size = outerSize($element, true, true)
|
|
110
|
+
* ```
|
|
111
111
|
*
|
|
112
112
|
* @returns The width and height of the object
|
|
113
113
|
*/
|
|
114
|
-
export function outerSize( $element: HTMLElement, border
|
|
114
|
+
export function outerSize( $element: HTMLElement, border = false, margin = false ): FLib.DOM.Size {
|
|
115
115
|
return getOuterDim(
|
|
116
116
|
$element,
|
|
117
117
|
border,
|
package/DOM/PageToDOM.ts
CHANGED
|
@@ -232,10 +232,10 @@ function string2dom( html: string, callback: ( document: Document, destroy: () =
|
|
|
232
232
|
/**
|
|
233
233
|
* Convert a whole HTML page string in a document
|
|
234
234
|
*
|
|
235
|
-
* @param html
|
|
236
|
-
*
|
|
237
235
|
* @example
|
|
236
|
+
* ```ts
|
|
238
237
|
* pageToDOM( html ).then( $document => {} )
|
|
238
|
+
* ```
|
|
239
239
|
*
|
|
240
240
|
* @returns a Promise with the converted document in parameter
|
|
241
241
|
*/
|
package/DOM/Position.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* Return the position of an element or
|
|
3
3
|
* The position relative to another element
|
|
4
4
|
*
|
|
5
|
-
* @param $element
|
|
6
5
|
* @param $target - If set, the position of $element will be computed relatively to this element
|
|
7
6
|
*
|
|
8
7
|
* @example
|
|
8
|
+
* ```ts
|
|
9
9
|
* { top, left } = position( $element )
|
|
10
10
|
*
|
|
11
|
-
* @example
|
|
12
11
|
* { top, left } = position( $element, $target )
|
|
12
|
+
* ```
|
|
13
13
|
*
|
|
14
14
|
* @returns The coordinate of the object
|
|
15
15
|
*/
|
|
16
|
-
export function position( $element: HTMLElement, $target?: HTMLElement ):
|
|
16
|
+
export function position( $element: HTMLElement, $target?: HTMLElement ): FLib.DOM.Position {
|
|
17
17
|
|
|
18
18
|
if ( !$target ) {
|
|
19
19
|
return {
|
package/DOM/Size.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { prop, getStyle } from './Styles';
|
|
|
4
4
|
/**
|
|
5
5
|
* Compute the width of an element
|
|
6
6
|
*
|
|
7
|
-
* @param $element
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* elementWidth = width( $element )
|
|
11
9
|
*
|
|
@@ -19,8 +17,6 @@ export function width( $element: Element ): number {
|
|
|
19
17
|
/**
|
|
20
18
|
* Compute the height of an element
|
|
21
19
|
*
|
|
22
|
-
* @param $element
|
|
23
|
-
*
|
|
24
20
|
* @example
|
|
25
21
|
* elementHeight = height( $element )
|
|
26
22
|
*
|
|
@@ -34,14 +30,14 @@ export function height( $element: Element ): number {
|
|
|
34
30
|
/**
|
|
35
31
|
* Compute the size of an element
|
|
36
32
|
*
|
|
37
|
-
* @param $element
|
|
38
|
-
*
|
|
39
33
|
* @example
|
|
34
|
+
* ```ts
|
|
40
35
|
* {width, height} = size( $element )
|
|
36
|
+
* ```
|
|
41
37
|
*
|
|
42
38
|
* @returns The width and height of an element
|
|
43
39
|
*/
|
|
44
|
-
export function size( $element: Element ):
|
|
40
|
+
export function size( $element: Element ): FLib.DOM.Size {
|
|
45
41
|
const style = getStyle( $element );
|
|
46
42
|
const width = style[ 'width' ];
|
|
47
43
|
const height = style[ 'height' ];
|
package/DOM/StrToDOM.ts
CHANGED
package/DOM/Styles.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Return the style of a DOM element
|
|
3
3
|
*
|
|
4
|
-
* @param $element
|
|
5
|
-
*
|
|
6
4
|
* @example
|
|
7
5
|
* styles = getStyle($element)
|
|
8
6
|
*/
|
|
@@ -14,32 +12,28 @@ export function getStyle( $element: Element ): CSSStyleDeclaration {
|
|
|
14
12
|
/**
|
|
15
13
|
* Return the value of a style property of a DOM element
|
|
16
14
|
*
|
|
17
|
-
* @param $element
|
|
18
15
|
* @param property - Camel case property name
|
|
19
16
|
*
|
|
20
17
|
* @example
|
|
21
18
|
* styles = prop($element, 'marginTop')
|
|
22
19
|
*/
|
|
23
20
|
export function prop( $element: Element, property: string ): string {
|
|
24
|
-
return getStyle( $element )[
|
|
21
|
+
return getStyle( $element )[ property ];
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
|
|
28
25
|
/**
|
|
29
26
|
* Set a CSS property on an element
|
|
30
27
|
*
|
|
31
|
-
* @param $element
|
|
32
|
-
* @param property
|
|
33
|
-
* @param value
|
|
34
|
-
*
|
|
35
28
|
* @example
|
|
29
|
+
* ```ts
|
|
36
30
|
* $element = setCssVar($element, '--my-var', '12px')
|
|
37
31
|
*
|
|
38
|
-
* @example
|
|
39
32
|
* $element = setCssVar($element, {
|
|
40
33
|
* "--my-var": "12px",
|
|
41
34
|
* "--my-var-2": "100%"
|
|
42
35
|
* })
|
|
36
|
+
* ```
|
|
43
37
|
*
|
|
44
38
|
* @returns $element
|
|
45
39
|
*/
|
|
@@ -62,9 +56,6 @@ export function setCssProperty(
|
|
|
62
56
|
/**
|
|
63
57
|
* Get a CSS property of an element
|
|
64
58
|
*
|
|
65
|
-
* @param $element
|
|
66
|
-
* @param property
|
|
67
|
-
*
|
|
68
59
|
* @example
|
|
69
60
|
* value = getCssProperty($element, '--my-var')
|
|
70
61
|
*/
|
package/DOM/Traversing.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Return the next element in the DOM
|
|
3
3
|
*
|
|
4
|
-
* @param $element
|
|
5
|
-
*
|
|
6
4
|
* @example
|
|
7
5
|
* $nextElement = next($element)
|
|
8
6
|
*
|
|
@@ -16,8 +14,6 @@ export function next( $element: Element ): Element | null {
|
|
|
16
14
|
/**
|
|
17
15
|
* Return the previous element in the DOM
|
|
18
16
|
*
|
|
19
|
-
* @param $element
|
|
20
|
-
*
|
|
21
17
|
* @example
|
|
22
18
|
* $previousElement = previous($element)
|
|
23
19
|
*
|
|
@@ -31,8 +27,6 @@ export function previous( $element: Element ): Element | null {
|
|
|
31
27
|
/**
|
|
32
28
|
* Return all the children of a DOM element
|
|
33
29
|
*
|
|
34
|
-
* @param $element
|
|
35
|
-
*
|
|
36
30
|
* @example
|
|
37
31
|
* $elements = children($element)
|
|
38
32
|
*/
|
package/DOM/WindowScroll.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Get the scroll position of the window
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
|
+
* ```ts
|
|
5
6
|
* {top, left} = scroll()
|
|
7
|
+
* ```
|
|
6
8
|
*
|
|
7
9
|
* @returns The position of the scroll
|
|
8
10
|
*/
|
|
9
|
-
export function windowScroll():
|
|
11
|
+
export function windowScroll(): FLib.DOM.Position {
|
|
10
12
|
let sx, sy, d, r, b;
|
|
11
13
|
|
|
12
14
|
if ( window.pageYOffset !== undefined ) {
|
package/DOM/WindowSize.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Get the size of the window
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
|
+
* ```ts
|
|
5
6
|
* {width, height} = windowSize()
|
|
7
|
+
* ```
|
|
6
8
|
*
|
|
7
9
|
* @returns The width and height of the window
|
|
8
10
|
*/
|
|
9
|
-
export function windowSize():
|
|
11
|
+
export function windowSize(): FLib.DOM.Size {
|
|
10
12
|
return {
|
|
11
13
|
"width": window.innerWidth,
|
|
12
14
|
"height": window.innerHeight
|