@blackbyte/sugar 1.0.0-beta.6 → 1.0.0-beta.7
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/dom/event/viewportEvents.js +9 -9
- package/dist/js/dom/event/viewportEvents.js.map +1 -1
- package/dist/js/dom/query/querySelectorLive.d.ts +22 -16
- package/dist/js/dom/query/querySelectorLive.js +163 -96
- package/dist/js/dom/query/querySelectorLive.js.map +1 -1
- package/dist/js/feature/_exports.d.ts +3 -2
- package/dist/js/feature/_exports.js +3 -2
- package/dist/js/feature/_exports.js.map +1 -1
- package/dist/js/feature/disableTitleTooltips.d.ts +20 -0
- package/dist/js/feature/disableTitleTooltips.js +26 -0
- package/dist/js/feature/disableTitleTooltips.js.map +1 -0
- package/dist/js/feature/features.d.ts +32 -0
- package/dist/js/feature/features.js +19 -0
- package/dist/js/feature/features.js.map +1 -0
- package/dist/js/feature/sectionClasses.js +2 -2
- package/dist/js/feature/sectionClasses.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,20 +20,20 @@ export default function viewportEvents($elm, settings) {
|
|
|
20
20
|
const distanceToTop = distanceFromElementTopToViewportTop($elm);
|
|
21
21
|
if (distanceToTop < window.innerHeight * 0.5) {
|
|
22
22
|
$elm.dispatchEvent(new CustomEvent('viewport.enter.above', {
|
|
23
|
-
bubbles: true
|
|
23
|
+
bubbles: true
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
$elm.dispatchEvent(new CustomEvent('viewport.enter.below', {
|
|
28
|
-
bubbles: true
|
|
28
|
+
bubbles: true
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
status = 'in';
|
|
32
32
|
$elm.dispatchEvent(new CustomEvent('viewport.enter', {
|
|
33
|
-
bubbles: true
|
|
33
|
+
bubbles: true
|
|
34
34
|
}));
|
|
35
35
|
$elm.dispatchEvent(new CustomEvent('viewport.in', {
|
|
36
|
-
bubbles: true
|
|
36
|
+
bubbles: true
|
|
37
37
|
}));
|
|
38
38
|
if (finalSettings === null || finalSettings === void 0 ? void 0 : finalSettings.once) {
|
|
39
39
|
observer.disconnect();
|
|
@@ -46,20 +46,20 @@ export default function viewportEvents($elm, settings) {
|
|
|
46
46
|
const distanceToTop = distanceFromElementTopToViewportTop($elm);
|
|
47
47
|
if (distanceToTop < window.innerHeight * 0.5) {
|
|
48
48
|
$elm.dispatchEvent(new CustomEvent('viewport.leave.above', {
|
|
49
|
-
bubbles: true
|
|
49
|
+
bubbles: true
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
$elm.dispatchEvent(new CustomEvent('viewport.leave.below', {
|
|
54
|
-
bubbles: true
|
|
54
|
+
bubbles: true
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
57
|
status = 'out';
|
|
58
58
|
$elm.dispatchEvent(new CustomEvent('viewport.leave', {
|
|
59
|
-
bubbles: true
|
|
59
|
+
bubbles: true
|
|
60
60
|
}));
|
|
61
61
|
$elm.dispatchEvent(new CustomEvent('viewport.out', {
|
|
62
|
-
bubbles: true
|
|
62
|
+
bubbles: true
|
|
63
63
|
}));
|
|
64
64
|
}
|
|
65
65
|
}, {
|
|
@@ -67,7 +67,7 @@ export default function viewportEvents($elm, settings) {
|
|
|
67
67
|
rootMargin: typeof finalSettings.offset === 'string'
|
|
68
68
|
? finalSettings.offset
|
|
69
69
|
: `${finalSettings.offset}px`,
|
|
70
|
-
threshold: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
70
|
+
threshold: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
71
71
|
});
|
|
72
72
|
observer.observe($elm);
|
|
73
73
|
return $elm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewportEvents.js","sourceRoot":"","sources":["../../../../src/js/dom/event/viewportEvents.ts"],"names":[],"mappings":"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C;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,CAAA;IAED,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtB,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -12,41 +12,47 @@ import type { TWhenTrigger } from '../when/when.js';
|
|
|
12
12
|
* when you don't have the chance to use the custom elements API instead
|
|
13
13
|
*
|
|
14
14
|
* @feature Specify what you want to select and get notified each time a node like this appears in the dom
|
|
15
|
+
* @feature Promise based API
|
|
16
|
+
* @feature Callback support
|
|
15
17
|
* @feature Monitor added nodes and existing nodes that have class and id attributes updated
|
|
16
18
|
*
|
|
17
|
-
* @param {String} selector
|
|
18
|
-
* @param {Function} cb
|
|
19
|
-
* @param {TQuerySelectorLiveSettings} [settings={}]
|
|
20
|
-
* @return {
|
|
19
|
+
* @param {String} selector The css selector that we are interested in
|
|
20
|
+
* @param {Function} cb The function to call with the newly added node
|
|
21
|
+
* @param {TQuerySelectorLiveSettings} [settings={}] An optional settings object to specify things like the rootNode to monitor, etc...
|
|
22
|
+
* @return {SPromise<HTMLElement>} An SPromise instance on which to listen for nodes using the "node" event
|
|
21
23
|
*
|
|
22
|
-
* @setting {HTMLElement} [
|
|
23
|
-
* @setting {
|
|
24
|
-
* @setting {
|
|
25
|
-
* @setting {
|
|
26
|
-
* @setting {
|
|
24
|
+
* @setting {HTMLElement} [rootNode=document] The root node from where to observe childs
|
|
25
|
+
* @setting {Boolean} [once=true] If true, each observed nodes will be handled only once even if they are removed and reinjected in the dom
|
|
26
|
+
* @setting {Function} [afterFirst=null] A function that will be called once the first scan is done
|
|
27
|
+
* @setting {Boolean} [scopes=true] If true, the selector will be searched inside elements with the "s-query-selector-live-scope" attribute as scopes
|
|
28
|
+
* @setting {Boolean} [firstOnly=false] If true, the query will stop after the first matching node is found
|
|
29
|
+
* @setting {TWhenTrigger|string} [when=null] An optional when trigger or array of triggers to wait for before calling the callback with the detected node
|
|
30
|
+
* @setting {Function} [disconnectedCallback=null] An optional callback function that will be called when a previously detected node is removed from the dom
|
|
31
|
+
* @setting {String[]} [attributes=[]] An optional array of attributes to monitor for changes (in addition to class and id)
|
|
27
32
|
*
|
|
28
33
|
* @snippet querySelectorLive($1, $2)
|
|
29
34
|
* querySelectorLive($1, \$elm => {
|
|
30
|
-
*
|
|
35
|
+
* $2
|
|
31
36
|
* });
|
|
32
37
|
*
|
|
33
38
|
* @example js
|
|
34
|
-
* import { querySelectorLive } from '@
|
|
39
|
+
* import { querySelectorLive } from '@lotsof/sugar/dom'
|
|
35
40
|
* const query = querySelectorLive('.my-cool-item', (node, api) => {
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
41
|
+
* // do something here with the detected node
|
|
42
|
+
* // call api.cancel if you want to stop listening for this selector
|
|
43
|
+
* api.cancel();
|
|
39
44
|
* });
|
|
40
45
|
* // cancel the query manually when needed
|
|
41
46
|
* query.cancel();
|
|
42
47
|
*
|
|
43
48
|
* @since 1.0.0
|
|
44
|
-
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://
|
|
49
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://lotsof.dev)
|
|
45
50
|
*/
|
|
46
51
|
export type TQuerySelectorLiveSettings = {
|
|
47
|
-
|
|
52
|
+
rootNode: HTMLElement | Document;
|
|
48
53
|
once: boolean;
|
|
49
54
|
afterFirst?: Function;
|
|
55
|
+
scopes: boolean;
|
|
50
56
|
firstOnly: boolean;
|
|
51
57
|
when?: TWhenTrigger<string>;
|
|
52
58
|
disconnectedCallback?: ($elm: HTMLElement) => void;
|
|
@@ -7,22 +7,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import uniqid from '../../string/uniqid.js';
|
|
10
11
|
import when from '../when/when.js';
|
|
11
12
|
export default function querySelectorLive(selector, cb, settings, _isFirstLevel = true) {
|
|
12
|
-
var _a, _b, _c;
|
|
13
|
-
let observer, canceled = false;
|
|
14
|
-
const
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
let noScopeSelector, observer, canceled = false;
|
|
15
|
+
const selectedNodes = [];
|
|
15
16
|
// extend settings
|
|
16
|
-
const finalSettings = Object.assign({
|
|
17
|
-
// compatibility only
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
if (finalSettings.rootNode) {
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
finalSettings.$rootNode = finalSettings.rootNode;
|
|
22
|
-
}
|
|
17
|
+
const finalSettings = Object.assign({ rootNode: document, once: true, afterFirst: undefined, scopes: true, firstOnly: false, attributes: [], disconnectedCallback: undefined, when: undefined }, (settings !== null && settings !== void 0 ? settings : {}));
|
|
23
18
|
const innerQuerySelectorLive = [];
|
|
19
|
+
// process selectors when scopes are true
|
|
20
|
+
if (finalSettings.scopes) {
|
|
21
|
+
noScopeSelector = selector
|
|
22
|
+
.split(',')
|
|
23
|
+
.map((sel) => {
|
|
24
|
+
return `${sel.trim()}:not([s-query-selector-live-scope] ${sel.trim()})`;
|
|
25
|
+
})
|
|
26
|
+
.join(',');
|
|
27
|
+
}
|
|
24
28
|
function isCanceled() {
|
|
25
|
-
return canceled && _isFirstLevel;
|
|
29
|
+
return selectedNodes.length && canceled && _isFirstLevel;
|
|
26
30
|
}
|
|
27
31
|
function cancel() {
|
|
28
32
|
canceled = true;
|
|
@@ -31,59 +35,69 @@ export default function querySelectorLive(selector, cb, settings, _isFirstLevel
|
|
|
31
35
|
});
|
|
32
36
|
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
33
37
|
}
|
|
38
|
+
function handleNode($node) {
|
|
39
|
+
if (isCanceled()) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// reset the "isDisconnected" flag
|
|
43
|
+
if ($node._isDisconnected) {
|
|
44
|
+
delete $node._isDisconnected;
|
|
45
|
+
}
|
|
46
|
+
// callback with our node
|
|
47
|
+
cb === null || cb === void 0 ? void 0 : cb($node, {
|
|
48
|
+
cancel,
|
|
49
|
+
});
|
|
50
|
+
// handle firstOnly setting
|
|
51
|
+
if (finalSettings.firstOnly) {
|
|
52
|
+
cancel();
|
|
53
|
+
}
|
|
54
|
+
// mark our node as selected at least 1 time
|
|
55
|
+
if (!selectedNodes.includes($node)) {
|
|
56
|
+
selectedNodes.push($node);
|
|
57
|
+
}
|
|
58
|
+
// mark our node as selected at least 1 time
|
|
59
|
+
if (!selectedNodes.includes($node)) {
|
|
60
|
+
selectedNodes.push($node);
|
|
61
|
+
}
|
|
62
|
+
// disconnected callback
|
|
63
|
+
if (finalSettings.disconnectedCallback) {
|
|
64
|
+
let mutationTimeout;
|
|
65
|
+
if ($node.parentNode) {
|
|
66
|
+
const disconnectObserver = new MutationObserver((mutations) => {
|
|
67
|
+
clearTimeout(mutationTimeout);
|
|
68
|
+
mutationTimeout = setTimeout(() => {
|
|
69
|
+
var _a;
|
|
70
|
+
if (!$node.parentNode && !$node._isDisconnected) {
|
|
71
|
+
$node._isDisconnected = true;
|
|
72
|
+
(_a = finalSettings.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(finalSettings, $node);
|
|
73
|
+
disconnectObserver.disconnect();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
disconnectObserver.observe($node.parentNode, {
|
|
78
|
+
childList: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
34
83
|
function processNode($node, sel) {
|
|
35
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
// if is canceled
|
|
37
|
-
if (isCanceled()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
// if the process has been canceled or the node is not an element
|
|
41
85
|
if (!$node.matches || isCanceled()) {
|
|
42
86
|
return;
|
|
43
87
|
}
|
|
44
|
-
// if
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// when
|
|
55
|
-
if (finalSettings.when) {
|
|
56
|
-
yield when($node, [finalSettings.when]);
|
|
57
|
-
if (isCanceled()) {
|
|
58
|
-
return;
|
|
88
|
+
// if the node match and has not already been emitted
|
|
89
|
+
if ($node.matches(selector) &&
|
|
90
|
+
(!finalSettings.once || !selectedNodes.includes($node))) {
|
|
91
|
+
// handle the "when" setting
|
|
92
|
+
if (finalSettings.when) {
|
|
93
|
+
yield when($node, [finalSettings.when]);
|
|
94
|
+
if (isCanceled()) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
handleNode($node);
|
|
59
98
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// callback with our node
|
|
63
|
-
cb === null || cb === void 0 ? void 0 : cb($node, {
|
|
64
|
-
cancel,
|
|
65
|
-
});
|
|
66
|
-
// handle firstOnly setting
|
|
67
|
-
if (finalSettings.firstOnly) {
|
|
68
|
-
cancel();
|
|
69
|
-
}
|
|
70
|
-
// disconnected callback
|
|
71
|
-
if (finalSettings.disconnectedCallback) {
|
|
72
|
-
let mutationTimeout;
|
|
73
|
-
if ($node.parentNode) {
|
|
74
|
-
const disconnectObserver = new MutationObserver((mutations) => {
|
|
75
|
-
clearTimeout(mutationTimeout);
|
|
76
|
-
mutationTimeout = setTimeout(() => {
|
|
77
|
-
var _a;
|
|
78
|
-
if (!$node.parentNode) {
|
|
79
|
-
(_a = finalSettings.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(finalSettings, $node);
|
|
80
|
-
disconnectObserver.disconnect();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
disconnectObserver.observe($node.parentNode, {
|
|
85
|
-
childList: true,
|
|
86
|
-
});
|
|
99
|
+
else {
|
|
100
|
+
handleNode($node);
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
103
|
// search inside our node
|
|
@@ -99,50 +113,103 @@ export default function querySelectorLive(selector, cb, settings, _isFirstLevel
|
|
|
99
113
|
processNode($node, sel);
|
|
100
114
|
});
|
|
101
115
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
if (finalSettings.scopes &&
|
|
117
|
+
(finalSettings.rootNode === document ||
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
!((_b = (_a = finalSettings.rootNode) === null || _a === void 0 ? void 0 : _a.hasAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, 's-query-selector-live-scope')))) {
|
|
120
|
+
let isAfterCalledByScopeId = {};
|
|
121
|
+
// search for scopes and handle nested nodes
|
|
122
|
+
innerQuerySelectorLive.push(querySelectorLive('[s-query-selector-live-scope]', ($scope) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
// get or generate a new id
|
|
124
|
+
const scopeId = $scope.id || `s-query-selector-live-scope-${uniqid()}`;
|
|
125
|
+
if ($scope.id !== scopeId) {
|
|
126
|
+
$scope.setAttribute('id', scopeId);
|
|
106
127
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
processNode($node, selector);
|
|
110
|
-
});
|
|
128
|
+
if (isCanceled()) {
|
|
129
|
+
return;
|
|
111
130
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
(
|
|
131
|
+
yield when($scope, ['nearViewport']);
|
|
132
|
+
if (isCanceled()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
innerQuerySelectorLive.push(querySelectorLive(selector, ($elm) => {
|
|
136
|
+
processNode($elm, selector);
|
|
137
|
+
}, Object.assign({}, settings, {
|
|
138
|
+
rootNode: $scope,
|
|
139
|
+
scopes: false,
|
|
140
|
+
afterFirst() {
|
|
141
|
+
if (isAfterCalledByScopeId[scopeId] &&
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
$scope._sQuerySelectorLiveScopeDirty) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
$scope._sQuerySelectorLiveScopeDirty = true;
|
|
148
|
+
isAfterCalledByScopeId[scopeId] = true;
|
|
149
|
+
$scope.classList.add('ready');
|
|
150
|
+
$scope.setAttribute('ready', 'true');
|
|
151
|
+
},
|
|
152
|
+
}), true));
|
|
153
|
+
}), Object.assign({}, settings, {
|
|
154
|
+
firstOnly: false,
|
|
155
|
+
scopes: false,
|
|
156
|
+
}), false));
|
|
157
|
+
// handle things not in a scope
|
|
158
|
+
innerQuerySelectorLive.push(querySelectorLive(noScopeSelector, ($elm) => {
|
|
159
|
+
// findAndProcess($scope, selector);
|
|
160
|
+
processNode($elm, selector);
|
|
161
|
+
}, Object.assign({}, settings, {
|
|
162
|
+
scopes: false,
|
|
163
|
+
}), false));
|
|
164
|
+
// after first callback
|
|
165
|
+
(_c = finalSettings.afterFirst) === null || _c === void 0 ? void 0 : _c.call(finalSettings);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
observer = new MutationObserver((mutations, obs) => {
|
|
169
|
+
mutations.forEach((mutation) => {
|
|
170
|
+
if (mutation.attributeName) {
|
|
171
|
+
processNode(mutation.target, selector);
|
|
172
|
+
}
|
|
173
|
+
if (mutation.addedNodes) {
|
|
174
|
+
mutation.addedNodes.forEach(($node) => {
|
|
175
|
+
processNode($node, selector);
|
|
176
|
+
});
|
|
132
177
|
}
|
|
133
178
|
});
|
|
179
|
+
});
|
|
180
|
+
let observeSettings = {
|
|
181
|
+
childList: true,
|
|
182
|
+
subtree: true,
|
|
183
|
+
};
|
|
184
|
+
selector
|
|
185
|
+
.split(',')
|
|
186
|
+
.map((l) => l.trim())
|
|
187
|
+
.forEach((sel) => {
|
|
188
|
+
const attrMatches = sel.match(/\[[^\]]+\]/gm);
|
|
189
|
+
if (attrMatches === null || attrMatches === void 0 ? void 0 : attrMatches.length) {
|
|
190
|
+
attrMatches.forEach((attrStr) => {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
const attrName = attrStr
|
|
193
|
+
.split('=')[0]
|
|
194
|
+
.replace(/^\[/, '')
|
|
195
|
+
.replace(/\]$/, '');
|
|
196
|
+
if (!((_a = finalSettings.attributes) === null || _a === void 0 ? void 0 : _a.includes(attrName))) {
|
|
197
|
+
(_b = finalSettings.attributes) === null || _b === void 0 ? void 0 : _b.push(attrName);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if ((_d = finalSettings.attributes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
203
|
+
observeSettings = Object.assign(Object.assign({}, observeSettings), { attributes: ((_e = finalSettings.attributes) === null || _e === void 0 ? void 0 : _e.length) ? true : false, attributeFilter: finalSettings.attributes.length
|
|
204
|
+
? finalSettings.attributes
|
|
205
|
+
: undefined });
|
|
134
206
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
207
|
+
observer.observe(finalSettings.rootNode, observeSettings);
|
|
208
|
+
// first query
|
|
209
|
+
findAndProcess(finalSettings.rootNode, selector);
|
|
210
|
+
// after first callback
|
|
211
|
+
(_f = finalSettings.afterFirst) === null || _f === void 0 ? void 0 : _f.call(finalSettings);
|
|
140
212
|
}
|
|
141
|
-
observer.observe(finalSettings.$rootNode, observeSettings);
|
|
142
|
-
// first query
|
|
143
|
-
findAndProcess(finalSettings.$rootNode, selector);
|
|
144
|
-
// after first callback
|
|
145
|
-
(_c = finalSettings.afterFirst) === null || _c === void 0 ? void 0 : _c.call(finalSettings);
|
|
146
213
|
return {
|
|
147
214
|
cancel,
|
|
148
215
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"querySelectorLive.js","sourceRoot":"","sources":["../../../../src/js/dom/query/querySelectorLive.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"querySelectorLive.js","sourceRoot":"","sources":["../../../../src/js/dom/query/querySelectorLive.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAE5C,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAwEnC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,QAAgB,EAChB,EAA8B,EAC9B,QAA8C,EAC9C,aAAa,GAAG,IAAI;;IAEpB,IAAI,eAAe,EACjB,QAAQ,EACR,QAAQ,GAAG,KAAK,CAAC;IAEnB,MAAM,aAAa,GAAkB,EAAE,CAAC;IAExC,kBAAkB;IAClB,MAAM,aAAa,mBACjB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,SAAS,EACrB,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,EAAE,EACd,oBAAoB,EAAE,SAAS,EAC/B,IAAI,EAAE,SAAS,IACZ,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CACpB,CAAC;IAEF,MAAM,sBAAsB,GAA4B,EAAE,CAAC;IAE3D,yCAAyC;IACzC,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACzB,eAAe,GAAG,Q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EAAE,CAAC;wBAClD,MAAA,aAAa,CAAC,UAAU,0CAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;oBAC3C,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,IAAI,MAAA,aAAa,CAAC,UAAU,0CAAE,MAAM,EAAE,CAAC;YACrC,eAAe,mCACV,eAAe,KAClB,UAAU,EAAE,CAAA,MAAA,aAAa,CAAC,UAAU,0CAAE,MAAM,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC3D,eAAe,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM;oBAC9C,CAAC,CAAC,aAAa,CAAC,UAAU;oBAC1B,CAAC,CAAC,SAAS,GACd,CAAC;QACJ,CAAC;QAED,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAE1D,cAAc;QACd,cAAc,CAAC,aAAa,CAAC,QAAuB,EAAE,QAAQ,CAAC,CAAC;QAChE,uBAAuB;QACvB,MAAA,aAAa,CAAC,UAAU,6DAAI,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import disableTitleTooltips from './disableTitleTooltips.js';
|
|
2
|
+
import features from './features.js';
|
|
1
3
|
import scrollClasses from './scrollClasses.js';
|
|
2
4
|
import sectionClasses from './sectionClasses.js';
|
|
3
|
-
|
|
4
|
-
export { scrollProperties as __scrollProperties, scrollClasses as __scrolledClasses, sectionClasses as __sectionClasses, scrollProperties, scrollClasses, sectionClasses, };
|
|
5
|
+
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as __scrolledClasses, sectionClasses as __sectionClasses, disableTitleTooltips, features, scrollClasses, sectionClasses, };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import disableTitleTooltips from './disableTitleTooltips.js';
|
|
2
|
+
import features from './features.js';
|
|
1
3
|
import scrollClasses from './scrollClasses.js';
|
|
2
4
|
import sectionClasses from './sectionClasses.js';
|
|
3
|
-
|
|
4
|
-
export { scrollProperties as __scrollProperties, scrollClasses as __scrolledClasses, sectionClasses as __sectionClasses, scrollProperties, scrollClasses, sectionClasses, };
|
|
5
|
+
export { disableTitleTooltips as __disableTitleTooltips, features as __features, scrollClasses as __scrolledClasses, sectionClasses as __sectionClasses, disableTitleTooltips, features, scrollClasses, sectionClasses, };
|
|
5
6
|
//# sourceMappingURL=_exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/feature/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"_exports.js","sourceRoot":"","sources":["../../../src/js/feature/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EACL,oBAAoB,IAAI,sBAAsB,EAC9C,QAAQ,IAAI,UAAU,EACtB,aAAa,IAAI,iBAAiB,EAClC,cAAc,IAAI,gBAAgB,EAClC,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,cAAc,GACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name disableTitleTooltips
|
|
3
|
+
* @namespace js.dom.feature
|
|
4
|
+
* @type Function
|
|
5
|
+
* @platform js
|
|
6
|
+
* @status stable
|
|
7
|
+
*
|
|
8
|
+
* This function allows you to disable the ugly tooltips that displays when hover a link/image/etc... with a "title" attribute.
|
|
9
|
+
* If you want to support accessibility, make use of the "aria-label" attribute instead
|
|
10
|
+
*
|
|
11
|
+
* @snippet disableTitleTooltips();
|
|
12
|
+
*
|
|
13
|
+
* @example js
|
|
14
|
+
* import { disableTitleTooltips } from '@blackbyte/sugar/features';
|
|
15
|
+
* disableTitleTooltips();
|
|
16
|
+
*
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
19
|
+
*/
|
|
20
|
+
export default function disableTitleTooltips(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { querySelectorLive } from '@blackbyte/sugar/dom';
|
|
2
|
+
/**
|
|
3
|
+
* @name disableTitleTooltips
|
|
4
|
+
* @namespace js.dom.feature
|
|
5
|
+
* @type Function
|
|
6
|
+
* @platform js
|
|
7
|
+
* @status stable
|
|
8
|
+
*
|
|
9
|
+
* This function allows you to disable the ugly tooltips that displays when hover a link/image/etc... with a "title" attribute.
|
|
10
|
+
* If you want to support accessibility, make use of the "aria-label" attribute instead
|
|
11
|
+
*
|
|
12
|
+
* @snippet disableTitleTooltips();
|
|
13
|
+
*
|
|
14
|
+
* @example js
|
|
15
|
+
* import { disableTitleTooltips } from '@blackbyte/sugar/features';
|
|
16
|
+
* disableTitleTooltips();
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
20
|
+
*/
|
|
21
|
+
export default function disableTitleTooltips() {
|
|
22
|
+
querySelectorLive('[title]:is(a,img)', ($elm) => {
|
|
23
|
+
$elm.removeAttribute('title');
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=disableTitleTooltips.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableTitleTooltips.js","sourceRoot":"","sources":["../../../src/js/feature/disableTitleTooltips.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC1C,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,IAAiB,EAAE,EAAE;QAC3D,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TScrollClassesSettings } from './scrollClasses.js';
|
|
2
|
+
import { TSectionClassesSettings } from './sectionClasses.js';
|
|
3
|
+
/**
|
|
4
|
+
* @name features
|
|
5
|
+
* @namespace js.dom.feature
|
|
6
|
+
* @type Function
|
|
7
|
+
* @platform js
|
|
8
|
+
* @status stable
|
|
9
|
+
*
|
|
10
|
+
* This function allows you to activate some features like the `disableTitleTooltip`,`sectionClasses`, etc...
|
|
11
|
+
* Available features are:
|
|
12
|
+
* - `disableTitleTooltip`
|
|
13
|
+
* - `scrollClasses`
|
|
14
|
+
* - `sectionClasses`
|
|
15
|
+
*
|
|
16
|
+
* @param {'all' | TFeaturesSettings} [settings={}] The features you want to activate with some settings associated if needed
|
|
17
|
+
*
|
|
18
|
+
* @snippet features($1);
|
|
19
|
+
*
|
|
20
|
+
* @example js
|
|
21
|
+
* import { features } from '@blackbyte/sugar/features';
|
|
22
|
+
* features('all');
|
|
23
|
+
*
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
* @author Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)
|
|
26
|
+
*/
|
|
27
|
+
export type TFeaturesSettings = {
|
|
28
|
+
disableTitleTooltips?: boolean;
|
|
29
|
+
scrollClasses?: boolean | TScrollClassesSettings;
|
|
30
|
+
sectionClasses?: boolean | TSectionClassesSettings;
|
|
31
|
+
};
|
|
32
|
+
export default function features(features: 'all' | TFeaturesSettings): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import disableTitleTooltips from './disableTitleTooltips.js';
|
|
2
|
+
import scrollClasses from './scrollClasses.js';
|
|
3
|
+
import sectionClasses from './sectionClasses.js';
|
|
4
|
+
export default function features(features) {
|
|
5
|
+
if (features === 'all' || features.disableTitleTooltips) {
|
|
6
|
+
disableTitleTooltips();
|
|
7
|
+
}
|
|
8
|
+
if (features === 'all' || features.scrollClasses) {
|
|
9
|
+
scrollClasses(features === 'all'
|
|
10
|
+
? undefined
|
|
11
|
+
: features.scrollClasses);
|
|
12
|
+
}
|
|
13
|
+
if (features === 'all' || features.sectionClasses) {
|
|
14
|
+
sectionClasses(features === 'all'
|
|
15
|
+
? undefined
|
|
16
|
+
: features.sectionClasses);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../../src/js/feature/features.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,aAAyC,MAAM,oBAAoB,CAAC;AAC3E,OAAO,cAA2C,MAAM,qBAAqB,CAAC;AAiC9E,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,QAAmC;IAClE,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACxD,oBAAoB,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QACjD,aAAa,CACX,QAAQ,KAAK,KAAK;YAChB,CAAC,CAAC,SAAS;YACX,CAAC,CAAE,QAAQ,CAAC,aAAwC,CACvD,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;QAClD,cAAc,CACZ,QAAQ,KAAK,KAAK;YAChB,CAAC,CAAC,SAAS;YACX,CAAC,CAAE,QAAQ,CAAC,cAA0C,CACzD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
*/
|
|
35
35
|
import { querySelectorLive, viewportEvents } from '@blackbyte/sugar/dom';
|
|
36
36
|
export default function sectionClasses(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);
|
|
37
|
+
const finalSettings = Object.assign({ inClass: '-in-viewport', keepInClassWhenAbove: false, fromAboveClass: '-from-above', fromBelowClass: '-from-below', aboveClass: '-above-viewport', belowClass: '-below-viewport', offset: 25, once: false }, settings);
|
|
38
38
|
querySelectorLive('section', ($section) => {
|
|
39
39
|
// listen for enter/leave viewport
|
|
40
40
|
viewportEvents($section, {
|
|
41
41
|
offset: finalSettings.offset,
|
|
42
|
-
once: finalSettings.once
|
|
42
|
+
once: finalSettings.once
|
|
43
43
|
});
|
|
44
44
|
const enterHandler = () => {
|
|
45
45
|
// add the inClass on the section
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAA;AAaxE,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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