@blackbyte/sugar 1.0.0-beta.4 → 1.0.0-beta.6
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/dist/js/clipboard/_exports.d.ts +2 -1
- package/dist/js/clipboard/_exports.js +2 -1
- package/dist/js/clipboard/_exports.js.map +1 -1
- package/dist/js/clipboard/copyElement.d.ts +24 -0
- package/dist/js/clipboard/copyElement.js +43 -0
- package/dist/js/clipboard/copyElement.js.map +1 -0
- package/dist/js/clipboard/copyFile.d.ts +1 -1
- package/dist/js/clipboard/copyFile.js +1 -1
- package/dist/js/clipboard/copyText.d.ts +1 -1
- package/dist/js/clipboard/copyText.js +1 -1
- package/dist/js/clipboard/readFile.d.ts +1 -1
- package/dist/js/clipboard/readFile.js +1 -1
- package/dist/js/dom/event/viewportEvents.d.ts +4 -0
- package/dist/js/dom/event/viewportEvents.js +23 -0
- package/dist/js/dom/event/viewportEvents.js.map +1 -1
- package/dist/js/feature/sectionClasses.d.ts +16 -1
- package/dist/js/feature/sectionClasses.js +54 -6
- package/dist/js/feature/sectionClasses.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import copyElement from './copyElement.js';
|
|
1
2
|
import copyFile from './copyFile.js';
|
|
2
3
|
import copyText from './copyText.js';
|
|
3
4
|
import readFile from './readFile.js';
|
|
4
5
|
import readText from './readText.js';
|
|
5
|
-
export { copyFile as __copyFile, copyText as __copyText, readFile as __readFile, readText as __readText, copyFile, copyText, readFile, readText, };
|
|
6
|
+
export { copyElement as __copyElement, copyFile as __copyFile, copyText as __copyText, readFile as __readFile, readText as __readText, copyElement, copyFile, copyText, readFile, readText, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import copyElement from './copyElement.js';
|
|
1
2
|
import copyFile from './copyFile.js';
|
|
2
3
|
import copyText from './copyText.js';
|
|
3
4
|
import readFile from './readFile.js';
|
|
4
5
|
import readText from './readText.js';
|
|
5
|
-
export { copyFile as __copyFile, copyText as __copyText, readFile as __readFile, readText as __readText, copyFile, copyText, readFile, readText, };
|
|
6
|
+
export { copyElement as __copyElement, copyFile as __copyFile, copyText as __copyText, readFile as __readFile, readText as __readText, copyElement, copyFile, copyText, readFile, readText, };
|
|
6
7
|
//# sourceMappingURL=_exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/clipboard/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EACL,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/clipboard/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EACL,WAAW,IAAI,aAAa,EAC5B,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,QAAQ,IAAI,UAAU,EACtB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name copyElement
|
|
3
|
+
* @namespace js.clipboard
|
|
4
|
+
* @type Function
|
|
5
|
+
* @platform js
|
|
6
|
+
* @async
|
|
7
|
+
* @status stable
|
|
8
|
+
*
|
|
9
|
+
* This function allows you to copy to the clipboard the passed dom node element with his style
|
|
10
|
+
*
|
|
11
|
+
* @param {HTMLElement} $elm The dom node element to copy to the clipboard
|
|
12
|
+
*
|
|
13
|
+
* @todo tests
|
|
14
|
+
*
|
|
15
|
+
* @snippet copyElement($1)
|
|
16
|
+
*
|
|
17
|
+
* @example js
|
|
18
|
+
* import { copyElement } from '@blackbyte/sugar/clipboard';
|
|
19
|
+
* copyElement($elm);
|
|
20
|
+
*
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
23
|
+
*/
|
|
24
|
+
export default function copyElement($elm: HTMLElement): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @name copyElement
|
|
4
|
+
* @namespace js.clipboard
|
|
5
|
+
* @type Function
|
|
6
|
+
* @platform js
|
|
7
|
+
* @async
|
|
8
|
+
* @status stable
|
|
9
|
+
*
|
|
10
|
+
* This function allows you to copy to the clipboard the passed dom node element with his style
|
|
11
|
+
*
|
|
12
|
+
* @param {HTMLElement} $elm The dom node element to copy to the clipboard
|
|
13
|
+
*
|
|
14
|
+
* @todo tests
|
|
15
|
+
*
|
|
16
|
+
* @snippet copyElement($1)
|
|
17
|
+
*
|
|
18
|
+
* @example js
|
|
19
|
+
* import { copyElement } from '@blackbyte/sugar/clipboard';
|
|
20
|
+
* copyElement($elm);
|
|
21
|
+
*
|
|
22
|
+
* @since 1.0.0
|
|
23
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
24
|
+
*/
|
|
25
|
+
export default function copyElement($elm) {
|
|
26
|
+
let range;
|
|
27
|
+
let selection;
|
|
28
|
+
if (document.body.createTextRange) {
|
|
29
|
+
range = document.body.createTextRange();
|
|
30
|
+
range.moveToElement($elm);
|
|
31
|
+
range.select();
|
|
32
|
+
}
|
|
33
|
+
else if (window.getSelection) {
|
|
34
|
+
selection = window.getSelection();
|
|
35
|
+
range = document.createRange();
|
|
36
|
+
range.selectNodeContents($elm);
|
|
37
|
+
selection.removeAllRanges();
|
|
38
|
+
selection.addRange(range);
|
|
39
|
+
}
|
|
40
|
+
document.execCommand('copy');
|
|
41
|
+
window.getSelection().removeAllRanges();
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=copyElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyElement.js","sourceRoot":"","sources":["../../../src/js/clipboard/copyElement.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAiB;IACnD,IAAI,KAAK,CAAC;IACV,IAAI,SAAS,CAAC;IAEd,IAAI,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;QAClC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1B,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;SAAM,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC/B,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QAClC,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/B,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC/B,SAAS,CAAC,eAAe,EAAE,CAAC;QAC5B,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,YAAY,EAAE,CAAC,eAAe,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @event viewport.enter Dispatched when the passed element enter the viewport
|
|
19
19
|
* @event viewport.leave Dispatched when the passed element leave the viewport
|
|
20
|
+
* @event viewport.enter.above Dispatched when the passed element enter the viewport from above
|
|
21
|
+
* @event viewport.enter.below Dispatched when the passed element enter the viewport from below
|
|
22
|
+
* @event viewport.leave.above Dispatched when the passed element leave the viewport from above
|
|
23
|
+
* @event viewport.leave.below Dispatched when the passed element leave the viewport from below
|
|
20
24
|
*
|
|
21
25
|
* @snippet viewportEvents($1)
|
|
22
26
|
* viewportEvents($1).addEventListener('viewport.enter', (e) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { distanceFromElementTopToViewportTop } from '../_exports.js';
|
|
1
2
|
const _viewportEventsInited = new WeakMap();
|
|
2
3
|
export default function viewportEvents($elm, settings) {
|
|
3
4
|
let observer, status = 'out';
|
|
@@ -16,6 +17,17 @@ export default function viewportEvents($elm, settings) {
|
|
|
16
17
|
if (status === 'in') {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
20
|
+
const distanceToTop = distanceFromElementTopToViewportTop($elm);
|
|
21
|
+
if (distanceToTop < window.innerHeight * 0.5) {
|
|
22
|
+
$elm.dispatchEvent(new CustomEvent('viewport.enter.above', {
|
|
23
|
+
bubbles: true,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
$elm.dispatchEvent(new CustomEvent('viewport.enter.below', {
|
|
28
|
+
bubbles: true,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
19
31
|
status = 'in';
|
|
20
32
|
$elm.dispatchEvent(new CustomEvent('viewport.enter', {
|
|
21
33
|
bubbles: true,
|
|
@@ -31,6 +43,17 @@ export default function viewportEvents($elm, settings) {
|
|
|
31
43
|
if (status === 'out') {
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
46
|
+
const distanceToTop = distanceFromElementTopToViewportTop($elm);
|
|
47
|
+
if (distanceToTop < window.innerHeight * 0.5) {
|
|
48
|
+
$elm.dispatchEvent(new CustomEvent('viewport.leave.above', {
|
|
49
|
+
bubbles: true,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
$elm.dispatchEvent(new CustomEvent('viewport.leave.below', {
|
|
54
|
+
bubbles: true,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
34
57
|
status = 'out';
|
|
35
58
|
$elm.dispatchEvent(new CustomEvent('viewport.leave', {
|
|
36
59
|
bubbles: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewportEvents.js","sourceRoot":"","sources":["../../../../src/js/dom/event/viewportEvents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewportEvents.js","sourceRoot":"","sources":["../../../../src/js/dom/event/viewportEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAsDrE,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAE,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,IAAiB,EACjB,QAA2C;IAE3C,IAAI,QAAQ,EACV,MAAM,GAAG,KAAK,CAAC;IAEjB,IAAI,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qBAAqB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtC,MAAM,aAAa,mBACjB,MAAM,EAAE,EAAE,EACV,IAAI,EAAE,KAAK,IACR,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CACpB,CAAC;IAEF,QAAQ,GAAG,IAAI,oBAAoB,CACjC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAA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C;gBACN,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,sBAAsB,EAAE;oBACtC,OAAO,EAAE,IAAI;iBACd,CAAC,CACH,CAAC;YACJ,CAAC;YAED,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,gBAAgB,EAAE;gBAChC,OAAO,EAAE,IAAI;aACd,CAAC,CACH,CAAC;YACF,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE;gBAC9B,OAAO,EAAE,IAAI;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,EACD;QACE,IAAI,EAAE,IAAI,EAAE,WAAW;QACvB,UAAU,EACR,OAAO,aAAa,CAAC,MAAM,KAAK,QAAQ;YACtC,CAAC,CAAC,aAAa,CAAC,MAAM;YACtB,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,IAAI;QACjC,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;KAC/D,CACF,CAAC;IAEF,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -6,12 +6,21 @@
|
|
|
6
6
|
* @status stable
|
|
7
7
|
*
|
|
8
8
|
*
|
|
9
|
-
* This feature allows you to add some classes on your sections when they are in the viewport, near the viewport, etc...
|
|
9
|
+
* This feature allows you to add some classes on your sections when they are in the viewport, near the viewport, above, etc...
|
|
10
10
|
* 1. `-in-viewport`: Added when the section is in the viewport
|
|
11
|
+
* 2. `-from-above`: Added when the section enters the viewport from above
|
|
12
|
+
* 3. `-from-below`: Added when the section enters the viewport from below
|
|
13
|
+
* 4. `-above-viewport`: Added when the section is above the viewport
|
|
14
|
+
* 5. `-below-viewport`: Added when the section is below the viewport
|
|
11
15
|
*
|
|
12
16
|
* @param {TSectionClassesSettings} [settings={}] The settings you want to override
|
|
13
17
|
*
|
|
14
18
|
* @setting {String} [inClass='-in-viewport'] The class to add when the section is in the viewport
|
|
19
|
+
* @setting {Boolean} [keepInClassWhenAbove=false] Whether to keep the inClass when the section is above the viewport
|
|
20
|
+
* @setting {String} [fromAboveClass='-from-above'] The class to add when the section enters the viewport from above
|
|
21
|
+
* @setting {String} [fromBelowClass='-from-below'] The class to add when the section enters the viewport from below
|
|
22
|
+
* @setting {String} [aboveClass='-above-viewport'] The class to add when the section is above the viewport
|
|
23
|
+
* @setting {String} [belowClass='-below-viewport'] The class to add when
|
|
15
24
|
* @setting {Number} [offset=25] The offset in px to consider the section is in the viewport
|
|
16
25
|
*
|
|
17
26
|
* @snippet sectionClasses($1);
|
|
@@ -25,6 +34,12 @@
|
|
|
25
34
|
*/
|
|
26
35
|
export type TSectionClassesSettings = {
|
|
27
36
|
inClass: string;
|
|
37
|
+
keepInClassWhenAbove: boolean;
|
|
38
|
+
fromAboveClass: string;
|
|
39
|
+
fromBelowClass: string;
|
|
40
|
+
aboveClass: string;
|
|
41
|
+
belowClass: string;
|
|
28
42
|
offset: number;
|
|
43
|
+
once?: boolean;
|
|
29
44
|
};
|
|
30
45
|
export default function sectionClasses(settings?: Partial<TSectionClassesSettings>): void;
|
|
@@ -6,12 +6,21 @@
|
|
|
6
6
|
* @status stable
|
|
7
7
|
*
|
|
8
8
|
*
|
|
9
|
-
* This feature allows you to add some classes on your sections when they are in the viewport, near the viewport, etc...
|
|
9
|
+
* This feature allows you to add some classes on your sections when they are in the viewport, near the viewport, above, etc...
|
|
10
10
|
* 1. `-in-viewport`: Added when the section is in the viewport
|
|
11
|
+
* 2. `-from-above`: Added when the section enters the viewport from above
|
|
12
|
+
* 3. `-from-below`: Added when the section enters the viewport from below
|
|
13
|
+
* 4. `-above-viewport`: Added when the section is above the viewport
|
|
14
|
+
* 5. `-below-viewport`: Added when the section is below the viewport
|
|
11
15
|
*
|
|
12
16
|
* @param {TSectionClassesSettings} [settings={}] The settings you want to override
|
|
13
17
|
*
|
|
14
18
|
* @setting {String} [inClass='-in-viewport'] The class to add when the section is in the viewport
|
|
19
|
+
* @setting {Boolean} [keepInClassWhenAbove=false] Whether to keep the inClass when the section is above the viewport
|
|
20
|
+
* @setting {String} [fromAboveClass='-from-above'] The class to add when the section enters the viewport from above
|
|
21
|
+
* @setting {String} [fromBelowClass='-from-below'] The class to add when the section enters the viewport from below
|
|
22
|
+
* @setting {String} [aboveClass='-above-viewport'] The class to add when the section is above the viewport
|
|
23
|
+
* @setting {String} [belowClass='-below-viewport'] The class to add when
|
|
15
24
|
* @setting {Number} [offset=25] The offset in px to consider the section is in the viewport
|
|
16
25
|
*
|
|
17
26
|
* @snippet sectionClasses($1);
|
|
@@ -25,20 +34,59 @@
|
|
|
25
34
|
*/
|
|
26
35
|
import { querySelectorLive, viewportEvents } from '@blackbyte/sugar/dom';
|
|
27
36
|
export default function sectionClasses(settings) {
|
|
28
|
-
const finalSettings = Object.assign({ inClass: '-in-viewport', offset: 25 }, settings);
|
|
37
|
+
const finalSettings = Object.assign({ inClass: '-in-viewport', keepInClassWhenAbove: false, fromAboveClass: '-from-above', fromBelowClass: '-from-below', aboveClass: '-above-viewport', belowClass: '-below-viewport', offset: 25 }, settings);
|
|
29
38
|
querySelectorLive('section', ($section) => {
|
|
30
39
|
// listen for enter/leave viewport
|
|
31
40
|
viewportEvents($section, {
|
|
32
41
|
offset: finalSettings.offset,
|
|
42
|
+
once: finalSettings.once,
|
|
33
43
|
});
|
|
34
|
-
|
|
44
|
+
const enterHandler = () => {
|
|
35
45
|
// add the inClass on the section
|
|
36
46
|
$section.classList.add(finalSettings.inClass);
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
// remove above/below classes
|
|
48
|
+
$section.classList.remove(finalSettings.aboveClass);
|
|
49
|
+
$section.classList.remove(finalSettings.belowClass);
|
|
50
|
+
// stop if "once" setting is enabled
|
|
51
|
+
if (finalSettings.once) {
|
|
52
|
+
$section.removeEventListener('viewport.enter', enterHandler);
|
|
53
|
+
$section.removeEventListener('viewport.leave', leaveHandler);
|
|
54
|
+
$section.removeEventListener('viewport.enter.above', enterAboveHandler);
|
|
55
|
+
$section.removeEventListener('viewport.enter.below', enterBelowHandler);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const leaveHandler = () => {
|
|
59
|
+
// remove the inClass on the section
|
|
60
|
+
$section.classList.remove(finalSettings.fromAboveClass);
|
|
61
|
+
$section.classList.remove(finalSettings.fromBelowClass);
|
|
62
|
+
};
|
|
63
|
+
const enterBelowHandler = () => {
|
|
64
|
+
$section.classList.add(finalSettings.fromBelowClass);
|
|
65
|
+
};
|
|
66
|
+
const enterAboveHandler = () => {
|
|
67
|
+
// add the inClass on the section
|
|
68
|
+
$section.classList.add(finalSettings.fromAboveClass);
|
|
69
|
+
};
|
|
70
|
+
const leaveAboveHandler = () => {
|
|
71
|
+
// if we want to keep the inClass when above
|
|
72
|
+
if (!finalSettings.keepInClassWhenAbove) {
|
|
73
|
+
$section.classList.remove(finalSettings.inClass);
|
|
74
|
+
}
|
|
39
75
|
// remove the inClass on the section
|
|
76
|
+
$section.classList.add(finalSettings.aboveClass);
|
|
77
|
+
};
|
|
78
|
+
const leaveBelowHandler = () => {
|
|
79
|
+
// remove the inClass
|
|
40
80
|
$section.classList.remove(finalSettings.inClass);
|
|
41
|
-
|
|
81
|
+
// remove the bellow class
|
|
82
|
+
$section.classList.add(finalSettings.belowClass);
|
|
83
|
+
};
|
|
84
|
+
$section.addEventListener('viewport.enter.above', enterAboveHandler);
|
|
85
|
+
$section.addEventListener('viewport.enter.below', enterBelowHandler);
|
|
86
|
+
$section.addEventListener('viewport.leave.above', leaveAboveHandler);
|
|
87
|
+
$section.addEventListener('viewport.leave.below', leaveBelowHandler);
|
|
88
|
+
$section.addEventListener('viewport.enter', enterHandler);
|
|
89
|
+
$section.addEventListener('viewport.leave', leaveHandler);
|
|
42
90
|
});
|
|
43
91
|
}
|
|
44
92
|
//# sourceMappingURL=sectionClasses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sectionClasses.js","sourceRoot":"","sources":["../../../src/js/feature/sectionClasses.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sectionClasses.js","sourceRoot":"","sources":["../../../src/js/feature/sectionClasses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAazE,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,QAA2C;IAE3C,MAAM,aAAa,mBACjB,OAAO,EAAE,cAAc,EACvB,oBAAoB,EAAE,KAAK,EAC3B,cAAc,EAAE,aAAa,EAC7B,cAAc,EAAE,aAAa,EAC7B,UAAU,EAAE,iBAAiB,EAC7B,UAAU,EAAE,iBAAiB,EAC7B,MAAM,EAAE,EAAE,IACP,QAAQ,CACZ,CAAC;IAEF,iBAAiB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;QACxC,kCAAkC;QAClC,cAAc,CAAC,QAAQ,EAAE;YACvB,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,IAAI,EAAE,aAAa,CAAC,IAAI;SACzB,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,iCAAiC;YACjC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAE9C,6BAA6B;YAC7B,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACpD,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAEpD,oCAAoC;YACpC,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBACvB,QAAQ,CAAC,mBAAmB,CAAC,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