@blackbyte/sugar 1.0.0-beta.1 → 1.0.0-beta.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/README.md +267 -1
- package/dist/js/dom/css/reloadStylesheets.d.ts +1 -1
- package/dist/js/dom/distance/distanceFromElementTopToViewportBottom.d.ts +2 -2
- package/dist/js/dom/distance/distanceFromElementTopToViewportBottom.js +3 -3
- package/dist/js/dom/distance/distanceFromElementTopToViewportBottom.js.map +1 -1
- package/dist/js/dom/distance/distanceFromElementTopToViewportTop.d.ts +2 -2
- package/dist/js/dom/distance/distanceFromElementTopToViewportTop.js +3 -3
- package/dist/js/dom/distance/distanceFromElementTopToViewportTop.js.map +1 -1
- package/dist/js/dom/event/viewportEvents.d.ts +2 -2
- package/dist/js/dom/form/generateIdFromForm.d.ts +2 -2
- package/dist/js/dom/form/generateIdFromForm.js +2 -2
- package/dist/js/dom/form/getFormValues.d.ts +2 -2
- package/dist/js/dom/form/getFormValues.js +2 -2
- package/dist/js/dom/iframe/iframeAutoSize.d.ts +3 -3
- package/dist/js/dom/iframe/iframeAutoSize.js +3 -3
- package/dist/js/dom/inject/injectHtml.d.ts +2 -2
- package/dist/js/dom/inject/injectHtml.js +2 -2
- package/dist/js/dom/inject/injectIframeContent.d.ts +1 -1
- package/dist/js/dom/inject/injectIframeContent.js +1 -1
- package/dist/js/dom/inject/injectScript.d.ts +1 -1
- package/dist/js/dom/inject/injectScript.js +1 -1
- package/dist/js/dom/inject/injectStyle.d.ts +1 -1
- package/dist/js/dom/offset/offsetFromParent.d.ts +2 -2
- package/dist/js/dom/offset/offsetFromParent.js +2 -2
- package/dist/js/dom/offset/offsetFromViewport.d.ts +4 -4
- package/dist/js/dom/offset/offsetFromViewport.js +5 -5
- package/dist/js/dom/offset/offsetFromViewport.js.map +1 -1
- package/dist/js/dom/on/onDrag.d.ts +3 -3
- package/dist/js/dom/on/onScrollEnd.d.ts +2 -2
- package/dist/js/dom/on/onSwipe.d.ts +9 -9
- package/dist/js/dom/on/onSwipe.js +9 -9
- package/dist/js/dom/position/positionFromEvent.d.ts +21 -3
- package/dist/js/dom/position/positionFromEvent.js +29 -4
- package/dist/js/dom/position/positionFromEvent.js.map +1 -1
- package/dist/js/dom/query/closestElement.d.ts +8 -8
- package/dist/js/dom/query/closestElement.js +8 -8
- package/dist/js/dom/query/closestNotVisibleElement.d.ts +2 -2
- package/dist/js/dom/query/closestNotVisibleElement.js +2 -2
- package/dist/js/dom/query/elementsInViewport.d.ts +2 -1
- package/dist/js/dom/query/elementsInViewport.js.map +1 -1
- package/dist/js/dom/query/matches.d.ts +1 -1
- package/dist/js/dom/query/matches.js +1 -1
- package/dist/js/dom/query/nearestElement.d.ts +5 -3
- package/dist/js/dom/query/nearestElement.js.map +1 -1
- package/dist/js/dom/query/nextElement.d.ts +2 -2
- package/dist/js/dom/query/nextElement.js +2 -2
- package/dist/js/dom/query/previousElement.d.ts +2 -2
- package/dist/js/dom/query/previousElement.js +2 -2
- package/dist/js/dom/query/querySelector.d.ts +3 -3
- package/dist/js/dom/query/querySelector.js +8 -2
- package/dist/js/dom/query/querySelector.js.map +1 -1
- package/dist/js/dom/query/querySelectorAll.d.ts +3 -3
- package/dist/js/dom/query/querySelectorAll.js +8 -2
- package/dist/js/dom/query/querySelectorAll.js.map +1 -1
- package/dist/js/dom/query/querySelectorLive.d.ts +6 -6
- package/dist/js/dom/query/querySelectorLive.js +9 -3
- package/dist/js/dom/query/querySelectorLive.js.map +1 -1
- package/dist/js/dom/query/querySelectorUp.d.ts +3 -3
- package/dist/js/dom/query/querySelectorUp.js +3 -3
- package/dist/js/dom/style/getAnimationProperties.d.ts +2 -2
- package/dist/js/dom/style/getCssDeclarations.d.ts +1 -1
- package/dist/js/dom/style/getCssDeclarations.js +1 -1
- package/dist/js/dom/style/getRotateProperties.d.ts +1 -1
- package/dist/js/dom/style/getRotateProperties.js +1 -1
- package/dist/js/dom/style/getScaleProperty.d.ts +1 -1
- package/dist/js/dom/style/getStyleProperty.d.ts +2 -2
- package/dist/js/dom/style/getStyleProperty.js +2 -2
- package/dist/js/dom/style/getTransformProperties.d.ts +4 -4
- package/dist/js/dom/style/getTransitionProperties.d.ts +2 -2
- package/dist/js/dom/style/getTranslateProperties.d.ts +1 -1
- package/dist/js/dom/when/whenAnimationEnd.d.ts +2 -2
- package/dist/js/dom/when/whenAnimationEnd.js +2 -2
- package/dist/js/dom/when/whenAttribute.d.ts +9 -9
- package/dist/js/dom/when/whenDomReady.d.ts +2 -2
- package/dist/js/dom/when/whenDomReady.js +2 -2
- package/dist/js/dom/when/whenEntersViewport.d.ts +2 -2
- package/dist/js/dom/when/whenEventListener.d.ts +3 -3
- package/dist/js/dom/when/whenEventListener.js +3 -3
- package/dist/js/dom/when/whenIframeReady.d.ts +2 -2
- package/dist/js/dom/when/whenIframeReady.js +2 -2
- package/dist/js/dom/when/whenImageLoaded.d.ts +3 -3
- package/dist/js/dom/when/whenImageLoaded.js +3 -3
- package/dist/js/dom/when/whenImagesLoaded.d.ts +2 -4
- package/dist/js/dom/when/whenImagesLoaded.js +2 -4
- package/dist/js/dom/when/whenImagesLoaded.js.map +1 -1
- package/dist/js/dom/when/whenInViewport.d.ts +3 -3
- package/dist/js/dom/when/whenInteract.d.ts +1 -1
- package/dist/js/dom/when/whenInteract.js +1 -1
- package/dist/js/dom/when/whenLinkLoaded.js +3 -3
- package/dist/js/dom/when/whenNearViewport.d.ts +3 -3
- package/dist/js/dom/when/whenOutOfViewport.d.ts +3 -3
- package/dist/js/dom/when/whenOutOfViewport.js +3 -3
- package/dist/js/dom/when/whenRemoved.d.ts +3 -3
- package/dist/js/dom/when/whenRemoved.js +3 -3
- package/dist/js/dom/when/whenStylesheetsReady.d.ts +5 -5
- package/dist/js/dom/when/whenStylesheetsReady.js +8 -8
- package/dist/js/dom/when/whenStylesheetsReady.js.map +1 -1
- package/dist/js/dom/when/whenTransitionEnd.d.ts +1 -1
- package/dist/js/dom/when/whenTransitionEnd.js +1 -1
- package/dist/js/dom/when/whenVisible.d.ts +1 -1
- package/dist/js/feature/scrollProperties.d.ts +8 -4
- package/dist/js/feature/scrollProperties.js +7 -4
- package/dist/js/feature/scrollProperties.js.map +1 -1
- package/dist/js/feature/sectionClasses.d.ts +3 -7
- package/dist/js/feature/sectionClasses.js +3 -7
- package/dist/js/feature/sectionClasses.js.map +1 -1
- package/dist/js/is/isDarkMode.js +2 -2
- package/dist/js/is/isDarkMode.js.map +1 -1
- package/dist/js/is/isInViewport.d.ts +1 -1
- package/dist/js/is/isInViewport.js +1 -1
- package/dist/js/is/isUserScrolling.js +1 -1
- package/dist/js/is/isVisible.d.ts +1 -1
- package/dist/js/is/isVisible.js +1 -1
- package/dist/js/keyboard/hotkey.d.ts +4 -4
- package/dist/js/keyboard/hotkey.js +4 -4
- package/dist/js/scroll/scrollTo.d.ts +5 -5
- package/dist/js/theme/restoreTheme.d.ts +2 -2
- package/dist/js/theme/setTheme.d.ts +0 -2
- package/dist/js/theme/setTheme.js.map +1 -1
- package/dist/node/fs/ensureDirSync.js +1 -8
- package/dist/node/fs/ensureDirSync.js.map +1 -1
- package/dist/node/fs/writeFile.js +3 -3
- package/dist/node/fs/writeFile.js.map +1 -1
- package/dist/shared/array/unique.d.ts +11 -5
- package/dist/shared/array/unique.js +15 -25
- package/dist/shared/array/unique.js.map +1 -1
- package/dist/shared/color/hslaToRgba.js +2 -2
- package/dist/shared/console/SugarConsole.js +5 -5
- package/dist/shared/console/SugarConsole.js.map +1 -1
- package/dist/shared/css/transform/styleObjectToString.d.ts +2 -2
- package/dist/shared/css/transform/styleObjectToString.js +2 -2
- package/dist/shared/css/transform/styleStringToObject.d.ts +2 -2
- package/dist/shared/css/transform/styleStringToObject.js +2 -2
- package/dist/shared/currency/_exports.d.ts +4 -0
- package/dist/shared/currency/_exports.js +5 -0
- package/dist/shared/currency/_exports.js.map +1 -0
- package/dist/shared/currency/currencyCodeToSymbol.d.ts +24 -0
- package/dist/shared/currency/currencyCodeToSymbol.js +33 -0
- package/dist/shared/currency/currencyCodeToSymbol.js.map +1 -0
- package/dist/shared/currency/currencyStringToObject.d.ts +40 -0
- package/dist/shared/currency/currencyStringToObject.js +27 -0
- package/dist/shared/currency/currencyStringToObject.js.map +1 -0
- package/dist/shared/currency/currencySymbolToCode.d.ts +24 -0
- package/dist/shared/currency/currencySymbolToCode.js +34 -0
- package/dist/shared/currency/currencySymbolToCode.js.map +1 -0
- package/dist/shared/url/_exports.d.ts +5 -5
- package/dist/shared/url/_exports.js +5 -5
- package/dist/shared/url/_exports.js.map +1 -1
- package/package.json +26 -6
|
@@ -18,12 +18,12 @@ import matches from './matches.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @example js
|
|
20
20
|
* import { querySelectorUp } from '@blackbyte/sugar/dom'
|
|
21
|
-
* const closestElm = querySelectorUp(
|
|
21
|
+
* const closestElm = querySelectorUp($elm, '.my-cool-class');
|
|
22
22
|
* if (closestElm) {
|
|
23
|
-
*
|
|
23
|
+
* // we have found en element that matches the selector
|
|
24
24
|
* }
|
|
25
25
|
* // the selector param can be a function that need to return either true or false like so:
|
|
26
|
-
*
|
|
26
|
+
* querySelectorUp($elm, (elm) => {
|
|
27
27
|
* return elm.hasAttribute('my-cool-attribute')
|
|
28
28
|
* })
|
|
29
29
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Get the css animation properties from an HTMLElement in an object format
|
|
9
9
|
*
|
|
10
|
-
* @param {HTMLElement} elm
|
|
10
|
+
* @param {HTMLElement} $elm The element to get the properties from
|
|
11
11
|
* @return {Object} The animation properties
|
|
12
12
|
*
|
|
13
13
|
* @todo tests
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @example js
|
|
18
18
|
* import { getAnimationProperties } from '@blackbyte/sugar/dom'
|
|
19
|
-
* const props = getAnimationProperties(myCoolHTMLElement);
|
|
19
|
+
* const props = getAnimationProperties($myCoolHTMLElement);
|
|
20
20
|
* // output format
|
|
21
21
|
* // {
|
|
22
22
|
* // name : ['animation1'],
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Get all the CSSRules of the passed type
|
|
9
9
|
*
|
|
10
|
-
* @param {string} [typeName=
|
|
10
|
+
* @param {string} [typeName=style] CSSRule type to search for, valid types: unknown, style, charset, import, media, fontface, page, keyframes, keyframe, namespace, counter, supports, document, fontfeature, viewport, region
|
|
11
11
|
* @param {array} [rules=[]] Array of CSSRules to search
|
|
12
12
|
* @param {function} [predecate=Boolean] Predecate function to filter matches
|
|
13
13
|
* @return {array} Array of matching CSSRules
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Get all the CSSRules of the passed type
|
|
9
9
|
*
|
|
10
|
-
* @param {string} [typeName=
|
|
10
|
+
* @param {string} [typeName=style] CSSRule type to search for, valid types: unknown, style, charset, import, media, fontface, page, keyframes, keyframe, namespace, counter, supports, document, fontfeature, viewport, region
|
|
11
11
|
* @param {array} [rules=[]] Array of CSSRules to search
|
|
12
12
|
* @param {function} [predecate=Boolean] Predecate function to filter matches
|
|
13
13
|
* @return {array} Array of matching CSSRules
|
|
@@ -17,7 +17,7 @@ import * as rematrix from 'rematrix';
|
|
|
17
17
|
*
|
|
18
18
|
* @example js
|
|
19
19
|
* import { getRotateProperties } from '@blackbyte/sugar/dom'
|
|
20
|
-
* const props = getRotateProperties(myCoolHTMLElement);
|
|
20
|
+
* const props = getRotateProperties($myCoolHTMLElement);
|
|
21
21
|
* // output format
|
|
22
22
|
* // {
|
|
23
23
|
* // x : 100,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* This function try to store the actual style to not trigger more that 1 redraw
|
|
10
10
|
* each js execution loop.
|
|
11
11
|
*
|
|
12
|
-
* @param {HTMLElement} elm
|
|
12
|
+
* @param {HTMLElement} $elm The element to get style from
|
|
13
13
|
* @param {String} property The css property to get
|
|
14
14
|
* @return {Mixed} The style value
|
|
15
15
|
*
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @example js
|
|
21
21
|
* import { getStyleProperty } from '@blackbyte/sugar/dom'
|
|
22
|
-
* const opacity = getStyleProperty(myCoolHTMLElement, 'opacity');
|
|
22
|
+
* const opacity = getStyleProperty($myCoolHTMLElement, 'opacity');
|
|
23
23
|
*
|
|
24
24
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
|
|
25
25
|
* @since 1.0.0
|
|
@@ -11,7 +11,7 @@ import parse from '../../../shared/string/parse.js';
|
|
|
11
11
|
* This function try to store the actual style to not trigger more that 1 redraw
|
|
12
12
|
* each js execution loop.
|
|
13
13
|
*
|
|
14
|
-
* @param {HTMLElement} elm
|
|
14
|
+
* @param {HTMLElement} $elm The element to get style from
|
|
15
15
|
* @param {String} property The css property to get
|
|
16
16
|
* @return {Mixed} The style value
|
|
17
17
|
*
|
|
@@ -21,7 +21,7 @@ import parse from '../../../shared/string/parse.js';
|
|
|
21
21
|
*
|
|
22
22
|
* @example js
|
|
23
23
|
* import { getStyleProperty } from '@blackbyte/sugar/dom'
|
|
24
|
-
* const opacity = getStyleProperty(myCoolHTMLElement, 'opacity');
|
|
24
|
+
* const opacity = getStyleProperty($myCoolHTMLElement, 'opacity');
|
|
25
25
|
*
|
|
26
26
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
|
|
27
27
|
* @since 1.0.0
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @example js
|
|
18
18
|
* import { getTransformProperties } from '@blackbyte/sugar/dom'
|
|
19
|
-
* const props = getTransformProperties(myCoolHTMLElement);
|
|
19
|
+
* const props = getTransformProperties($myCoolHTMLElement);
|
|
20
20
|
* // output format
|
|
21
21
|
* // {
|
|
22
|
-
* //
|
|
23
|
-
* //
|
|
24
|
-
* //
|
|
22
|
+
* // translateX : 100,
|
|
23
|
+
* // translateY : 0,
|
|
24
|
+
* // translateZ : 0,
|
|
25
25
|
* // rotateX: 0,
|
|
26
26
|
* // rotateY: 0,
|
|
27
27
|
* // rotateZ: 0
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Get the css transition properties from an HTMLElement in an object format
|
|
9
9
|
*
|
|
10
|
-
* @param {HTMLElement} elm The element to get the properties from
|
|
10
|
+
* @param {HTMLElement} $elm The element to get the properties from
|
|
11
11
|
* @return {Object} The transition properties
|
|
12
12
|
*
|
|
13
13
|
* @todo tests
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @example js
|
|
18
18
|
* import { getTransitionProperties } from '@blackbyte/sugar/dom'
|
|
19
|
-
* const props = getTransitionProperties(myCoolHTMLElement);
|
|
19
|
+
* const props = getTransitionProperties($myCoolHTMLElement);
|
|
20
20
|
* // output format
|
|
21
21
|
* // {
|
|
22
22
|
* // property : ['all'],
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @example js
|
|
18
18
|
* import { getTranslateProperties } from '@blackbyte/sugar/dom'
|
|
19
|
-
* const props = getTranslateProperties(myCoolHTMLElement);
|
|
19
|
+
* const props = getTranslateProperties($myCoolHTMLElement);
|
|
20
20
|
* // output format
|
|
21
21
|
* // {
|
|
22
22
|
* // x : 100,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenAnimationEnd($1)
|
|
15
15
|
* whenAnimationEnd($1).then(\$elm => {
|
|
16
|
-
*
|
|
16
|
+
* $2
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenAnimationEnd } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenAnimationEnd(myCoolElm).then(($elm) => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @since 1.0.0
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenAnimationEnd($1)
|
|
15
15
|
* whenAnimationEnd($1).then(\$elm => {
|
|
16
|
-
*
|
|
16
|
+
* $2
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenAnimationEnd } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenAnimationEnd(myCoolElm).then(($elm) => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @since 1.0.0
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenAttribute($1, $2)
|
|
21
21
|
* whenAttribute($1, $2).then(value => {
|
|
22
|
-
*
|
|
22
|
+
* $3
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
* import { whenAttribute } from '@blackbyte/sugar/dom'
|
|
29
29
|
*
|
|
30
30
|
* // using promise
|
|
31
|
-
* whenAttribute(myCoolHTMLElement, 'value').then(value => {
|
|
32
|
-
*
|
|
31
|
+
* whenAttribute($myCoolHTMLElement, 'value').then(value => {
|
|
32
|
+
* // do something...
|
|
33
33
|
* });
|
|
34
34
|
*
|
|
35
35
|
* // with a check function
|
|
36
|
-
* whenAttribute(myCoolHTMLElement, 'value', {
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* whenAttribute($myCoolHTMLElement, 'value', {
|
|
37
|
+
* check(newVal, oldVal) {
|
|
38
|
+
* // make sure the value is a number
|
|
39
|
+
* return typeof(newVal) === 'number';
|
|
40
|
+
* }
|
|
41
41
|
* }).then(value => {
|
|
42
|
-
*
|
|
42
|
+
* // do something...
|
|
43
43
|
* });
|
|
44
44
|
*
|
|
45
45
|
* @since 1.0.0
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenDomReady()
|
|
15
15
|
* whenDomReady().then(() => {
|
|
16
|
-
*
|
|
16
|
+
* $1
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenDomReady } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenDomReady().then(() => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @see https://www.jstips.co/en/javascript/detect-document-ready-in-pure-js/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenDomReady()
|
|
15
15
|
* whenDomReady().then(() => {
|
|
16
|
-
*
|
|
16
|
+
* $1
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenDomReady } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenDomReady().then(() => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @see https://www.jstips.co/en/javascript/detect-document-ready-in-pure-js/
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenEntersViewport($1)
|
|
21
21
|
* whenEntersViewport($1).then(\$elm => {
|
|
22
|
-
*
|
|
22
|
+
* $2
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @example js
|
|
28
28
|
* import { whenEntersViewport } from '@blackbyte/sugar/dom'
|
|
29
29
|
* whenEntersViewport($myElement).then(($elm) => {
|
|
30
|
-
*
|
|
30
|
+
* // do something with your element that has entered the viewport...
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
33
|
* @since 1.0.0
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @snippet whenEventListener($1, $2)
|
|
17
17
|
* whenEventListener($1, $2).then(e: Event => {
|
|
18
|
-
*
|
|
18
|
+
* $3
|
|
19
19
|
* });
|
|
20
20
|
*
|
|
21
21
|
* @todo tests
|
|
22
22
|
*
|
|
23
23
|
* @example js
|
|
24
24
|
* import { whenEventListener } from '@blackbyte/sugar/dom'
|
|
25
|
-
* whenEventListener('click',
|
|
26
|
-
*
|
|
25
|
+
* whenEventListener('click', $elm).then((e: Event) => {
|
|
26
|
+
* // do something...
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
29
|
* @since 1.0.0
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @snippet whenEventListener($1, $2)
|
|
17
17
|
* whenEventListener($1, $2).then(e: Event => {
|
|
18
|
-
*
|
|
18
|
+
* $3
|
|
19
19
|
* });
|
|
20
20
|
*
|
|
21
21
|
* @todo tests
|
|
22
22
|
*
|
|
23
23
|
* @example js
|
|
24
24
|
* import { whenEventListener } from '@blackbyte/sugar/dom'
|
|
25
|
-
* whenEventListener('click',
|
|
26
|
-
*
|
|
25
|
+
* whenEventListener('click', $elm).then((e: Event) => {
|
|
26
|
+
* // do something...
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
29
|
* @since 1.0.0
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenIframeReady($1)
|
|
15
15
|
* whenIframeReady($1).then(\$elm => {
|
|
16
|
-
*
|
|
16
|
+
* $2
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenIframeReady } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenIframeReady($myCoolIframe).then($iframe => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @since 1.0.0
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @snippet whenIframeReady($1)
|
|
15
15
|
* whenIframeReady($1).then(\$elm => {
|
|
16
|
-
*
|
|
16
|
+
* $2
|
|
17
17
|
* });
|
|
18
18
|
*
|
|
19
19
|
* @todo tests
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @example js
|
|
22
22
|
* import { whenIframeReady } from '@blackbyte/sugar/dom'
|
|
23
23
|
* whenIframeReady($myCoolIframe).then($iframe => {
|
|
24
|
-
*
|
|
24
|
+
* // do something...
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* @since 1.0.0
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @snippet whenImageLoaded($1)
|
|
16
16
|
* whenImageLoaded($1).then(\$img => {
|
|
17
|
-
*
|
|
17
|
+
* $2
|
|
18
18
|
* });
|
|
19
19
|
*
|
|
20
20
|
* @todo tests
|
|
21
21
|
*
|
|
22
22
|
* @example js
|
|
23
23
|
* import { whenImageLoaded } from '@blackbyte/sugar/dom'
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* whenImageLoaded($myCoolHTMLImageElement).then(($img) => {
|
|
25
|
+
* // do something when the image is loaded
|
|
26
26
|
* });
|
|
27
27
|
*
|
|
28
28
|
* @since 1.0.0
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @snippet whenImageLoaded($1)
|
|
16
16
|
* whenImageLoaded($1).then(\$img => {
|
|
17
|
-
*
|
|
17
|
+
* $2
|
|
18
18
|
* });
|
|
19
19
|
*
|
|
20
20
|
* @todo tests
|
|
21
21
|
*
|
|
22
22
|
* @example js
|
|
23
23
|
* import { whenImageLoaded } from '@blackbyte/sugar/dom'
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* whenImageLoaded($myCoolHTMLImageElement).then(($img) => {
|
|
25
|
+
* // do something when the image is loaded
|
|
26
26
|
* });
|
|
27
27
|
*
|
|
28
28
|
* @since 1.0.0
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @snippet whenImagesLoaded($1)
|
|
18
18
|
* whenImagesLoaded($1).then(imgs => {
|
|
19
|
-
*
|
|
19
|
+
* $2
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
22
|
* @todo tests
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
* import { whenImagesLoaded } from '@blackbyte/sugar/dom'
|
|
26
26
|
* whenImagesLoaded([
|
|
27
27
|
* $img1, $img2, $img3
|
|
28
|
-
* ]).
|
|
29
|
-
* // do something with the loaded image
|
|
30
|
-
* }).then(imgs => {
|
|
28
|
+
* ]).then(imgs => {
|
|
31
29
|
* // do something here
|
|
32
30
|
* })
|
|
33
31
|
*
|
|
@@ -17,7 +17,7 @@ import whenImageLoaded from './whenImageLoaded.js';
|
|
|
17
17
|
*
|
|
18
18
|
* @snippet whenImagesLoaded($1)
|
|
19
19
|
* whenImagesLoaded($1).then(imgs => {
|
|
20
|
-
*
|
|
20
|
+
* $2
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
23
|
* @todo tests
|
|
@@ -26,9 +26,7 @@ import whenImageLoaded from './whenImageLoaded.js';
|
|
|
26
26
|
* import { whenImagesLoaded } from '@blackbyte/sugar/dom'
|
|
27
27
|
* whenImagesLoaded([
|
|
28
28
|
* $img1, $img2, $img3
|
|
29
|
-
* ]).
|
|
30
|
-
* // do something with the loaded image
|
|
31
|
-
* }).then(imgs => {
|
|
29
|
+
* ]).then(imgs => {
|
|
32
30
|
* // do something here
|
|
33
31
|
* })
|
|
34
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whenImagesLoaded.js","sourceRoot":"","sources":["../../../../src/js/dom/when/whenImagesLoaded.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"whenImagesLoaded.js","sourceRoot":"","sources":["../../../../src/js/dom/when/whenImagesLoaded.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,KAAyB;IAEzB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAgC,EAAE,EAC9C,YAAY,GAAuB,EAAE,CAAC;QAExC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACjC,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;YAClC,GAAG;iBACA,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACzB,IAAI,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;oBACzC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenInViewport($1)
|
|
21
21
|
* whenInViewport($1).then(\$elm => {
|
|
22
|
-
*
|
|
22
|
+
* $2
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
26
26
|
*
|
|
27
27
|
* @example js
|
|
28
28
|
* import { whenInViewport } from '@blackbyte/sugar/dom'
|
|
29
|
-
* const promise = whenInViewport(myCoolHTMLElement).then((elm) => {
|
|
30
|
-
*
|
|
29
|
+
* const promise = whenInViewport($myCoolHTMLElement).then((elm) => {
|
|
30
|
+
* // do something with your element that has entered the viewport...
|
|
31
31
|
* });
|
|
32
32
|
* // when you want to stop listening
|
|
33
33
|
* promise.cancel();
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @snippet whenLinkLoaded($1)
|
|
18
18
|
* whenLinkLoaded($1).then(\$elm => {
|
|
19
|
-
*
|
|
19
|
+
* $2
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
22
|
* @example js
|
|
23
23
|
* import { whenLinkLoaded } from '@blackbyte/sugar/dom'
|
|
24
|
-
* whenLinkLoaded(myCoolHTMLLinlElement).then($link => {
|
|
25
|
-
*
|
|
24
|
+
* whenLinkLoaded($myCoolHTMLLinlElement).then($link => {
|
|
25
|
+
* // do something when the link is loaded
|
|
26
26
|
* });
|
|
27
27
|
*
|
|
28
28
|
* @since 1.0.0
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenNearViewport($1)
|
|
21
21
|
* whenNearViewport($1).then(\$elm => {
|
|
22
|
-
*
|
|
22
|
+
* $2
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
26
26
|
*
|
|
27
27
|
* @example js
|
|
28
28
|
* import { whenNearViewport } from '@blackbyte/sugar/dom'
|
|
29
|
-
* whenNearViewport(myCoolHTMLElement).then($elm => {
|
|
30
|
-
*
|
|
29
|
+
* whenNearViewport($myCoolHTMLElement).then($elm => {
|
|
30
|
+
* // do something with your element that has entered the viewport...
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
33
|
* @since 1.0.0
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenOutOfViewport($1)
|
|
21
21
|
* whenOutOfViewport($1).then(\$$elm => {
|
|
22
|
-
*
|
|
22
|
+
* $2
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
26
26
|
*
|
|
27
27
|
* @example js
|
|
28
28
|
* import { whenOutOfViewport } from '@blackbyte/sugar/dom'
|
|
29
|
-
* whenOutOfViewport(myCoolHTMLElement).then(($elm) => {
|
|
30
|
-
*
|
|
29
|
+
* whenOutOfViewport($myCoolHTMLElement).then(($elm) => {
|
|
30
|
+
* // do something with your element that has exit the viewport...
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
33
|
* @since 1.0.0
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @snippet whenOutOfViewport($1)
|
|
21
21
|
* whenOutOfViewport($1).then(\$$elm => {
|
|
22
|
-
*
|
|
22
|
+
* $2
|
|
23
23
|
* });
|
|
24
24
|
*
|
|
25
25
|
* @todo tests
|
|
26
26
|
*
|
|
27
27
|
* @example js
|
|
28
28
|
* import { whenOutOfViewport } from '@blackbyte/sugar/dom'
|
|
29
|
-
* whenOutOfViewport(myCoolHTMLElement).then(($elm) => {
|
|
30
|
-
*
|
|
29
|
+
* whenOutOfViewport($myCoolHTMLElement).then(($elm) => {
|
|
30
|
+
* // do something with your element that has exit the viewport...
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
33
|
* @since 1.0.0
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @snippet whenRemoved($1);
|
|
19
19
|
* whenRemoved($1).then(() => {
|
|
20
|
-
*
|
|
20
|
+
* $2
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
23
|
* @todo tests
|
|
24
24
|
*
|
|
25
25
|
* @example js
|
|
26
26
|
* import { whenRemoved } from '@blackbyte/sugar/dom'
|
|
27
|
-
* whenRemoved(myCoolHTMLElement).then(() => {
|
|
28
|
-
*
|
|
27
|
+
* whenRemoved($myCoolHTMLElement).then(() => {
|
|
28
|
+
* // the element has been removed
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* @since 1.0.0
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @snippet whenRemoved($1);
|
|
19
19
|
* whenRemoved($1).then(() => {
|
|
20
|
-
*
|
|
20
|
+
* $2
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
23
|
* @todo tests
|
|
24
24
|
*
|
|
25
25
|
* @example js
|
|
26
26
|
* import { whenRemoved } from '@blackbyte/sugar/dom'
|
|
27
|
-
* whenRemoved(myCoolHTMLElement).then(() => {
|
|
28
|
-
*
|
|
27
|
+
* whenRemoved($myCoolHTMLElement).then(() => {
|
|
28
|
+
* // the element has been removed
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* @since 1.0.0
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* @feature Async promise based
|
|
12
12
|
* @feature Multiple stylesheets elements listening
|
|
13
13
|
*
|
|
14
|
-
* @param {Array<HTMLLinkElement>} [links=null] The HTMLLinkElement tags to process. If not passed, take the local stylesheets links
|
|
15
|
-
* @return {Promise<void>}
|
|
14
|
+
* @param {Array<HTMLLinkElement>} [$links=null] The HTMLLinkElement tags to process. If not passed, take the local stylesheets links
|
|
15
|
+
* @return {Promise<void>} The promise that will be resolved when all the links are loaded
|
|
16
16
|
*
|
|
17
17
|
* @todo tests
|
|
18
18
|
*
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* @example js
|
|
25
25
|
* import { whenStylesheetsReady } from '@blackbyte/sugar/dom'
|
|
26
26
|
* whenStylesheetsReady([
|
|
27
|
-
* myHTMLLinkElement1,
|
|
28
|
-
* myHTMLLinkElement2
|
|
27
|
+
* $myHTMLLinkElement1,
|
|
28
|
+
* $myHTMLLinkElement2
|
|
29
29
|
* ]).then(stylesheets => {
|
|
30
30
|
* // do something...
|
|
31
31
|
* });
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
* @since 1.0.0
|
|
34
34
|
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
35
35
|
*/
|
|
36
|
-
export default function whenStylesheetsReady(links?: HTMLLinkElement[]): Promise<HTMLLinkElement[]>;
|
|
36
|
+
export default function whenStylesheetsReady($links?: HTMLLinkElement[]): Promise<HTMLLinkElement[]>;
|