@koine/dom 2.0.0-beta.37 → 2.0.0-beta.39
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/$.d.ts +1 -2
- package/$all.d.ts +1 -2
- package/$each.d.ts +1 -2
- package/README.md +1 -0
- package/_listen-delegation.d.ts +5 -5
- package/addClass.d.ts +1 -2
- package/calculateFixedOffset.d.ts +1 -2
- package/createElement.d.ts +2 -3
- package/emitEvent.d.ts +1 -2
- package/escapeSelector.d.ts +1 -2
- package/exists.d.ts +1 -2
- package/forEach.d.ts +1 -2
- package/getDataAttr.d.ts +1 -2
- package/getDocumentHeight.d.ts +1 -2
- package/getHeight.d.ts +1 -2
- package/getListeners.d.ts +1 -2
- package/getOffset.d.ts +1 -2
- package/getOffsetTop.d.ts +1 -2
- package/getOffsetTopSlim.d.ts +1 -2
- package/getScrollbarWidth.d.ts +1 -2
- package/getStyleValue.d.ts +1 -2
- package/getVisualBackgroundColor.d.ts +1 -2
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +143 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +46 -46
- package/index.esm.js +95 -0
- package/injectCss.d.ts +1 -2
- package/isHidden.d.ts +1 -2
- package/isInViewport.d.ts +1 -2
- package/isNodeList.d.ts +1 -2
- package/isTotallyScrolled.d.ts +1 -2
- package/listen.d.ts +3 -4
- package/listenLoaded.d.ts +1 -2
- package/listenOnce.d.ts +2 -3
- package/listenResize.d.ts +2 -3
- package/listenResizeDebounced.d.ts +2 -3
- package/listenResizeThrottled.d.ts +2 -3
- package/listenScroll.d.ts +2 -3
- package/listenScrollDebounced.d.ts +2 -3
- package/listenScrollThrottled.d.ts +2 -3
- package/off.d.ts +2 -3
- package/on.d.ts +2 -3
- package/onClickOutside.d.ts +1 -1
- package/once.d.ts +2 -3
- package/package.json +8 -146
- package/removeClass.d.ts +1 -2
- package/scrollTo.d.ts +1 -2
- package/setDataAttr.d.ts +1 -2
- package/setVendorCSS.d.ts +1 -2
- package/siblings.d.ts +1 -2
- package/toArray.d.ts +1 -2
- package/types.d.ts +1 -2
- package/unlisten.d.ts +3 -4
- package/$.js +0 -4
- package/$all.js +0 -4
- package/$each.js +0 -8
- package/_listen-delegation.js +0 -46
- package/addClass.js +0 -12
- package/calculateFixedOffset.js +0 -10
- package/createElement.js +0 -9
- package/emitEvent.js +0 -11
- package/escapeSelector.js +0 -4
- package/exists.js +0 -7
- package/forEach.js +0 -6
- package/getDataAttr.js +0 -4
- package/getDocumentHeight.js +0 -5
- package/getHeight.js +0 -4
- package/getListeners.js +0 -9
- package/getOffset.js +0 -11
- package/getOffsetTop.js +0 -11
- package/getOffsetTopSlim.js +0 -4
- package/getScrollbarWidth.js +0 -4
- package/getStyleValue.js +0 -4
- package/getVisualBackgroundColor.js +0 -16
- package/index.js +0 -45
- package/injectCss.js +0 -13
- package/isHidden.js +0 -4
- package/isInViewport.js +0 -10
- package/isNodeList.js +0 -9
- package/isTotallyScrolled.js +0 -4
- package/listen.js +0 -19
- package/listenLoaded.js +0 -5
- package/listenOnce.js +0 -11
- package/listenResize.js +0 -3
- package/listenResizeDebounced.js +0 -11
- package/listenResizeThrottled.js +0 -11
- package/listenScroll.js +0 -8
- package/listenScrollDebounced.js +0 -11
- package/listenScrollThrottled.js +0 -11
- package/off.js +0 -11
- package/on.js +0 -15
- package/onClickOutside.js +0 -16
- package/once.js +0 -11
- package/removeClass.js +0 -12
- package/scrollTo.js +0 -30
- package/setDataAttr.js +0 -8
- package/setVendorCSS.js +0 -9
- package/siblings.js +0 -14
- package/toArray.js +0 -4
- package/types.js +0 -1
- package/typings.d.ts +0 -4
- package/unlisten.js +0 -19
package/off.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function off(el, type, handler, options) {
|
|
2
|
-
if (options === void 0) { options = false; }
|
|
3
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
4
|
-
if (!el) {
|
|
5
|
-
console.warn("[@koine/dom:off] unexisting DOM element");
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
if (el)
|
|
9
|
-
el.removeEventListener(type, handler, options);
|
|
10
|
-
}
|
|
11
|
-
export default off;
|
package/on.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import off from "./off.js";
|
|
2
|
-
export function on(el, type, handler, options) {
|
|
3
|
-
if (options === void 0) { options = false; }
|
|
4
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
5
|
-
if (!el) {
|
|
6
|
-
console.warn("[@koine/dom:on] unexisting DOM element");
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
if (el) {
|
|
10
|
-
el.addEventListener(type, handler, options);
|
|
11
|
-
return function () { return off(el, type, handler); };
|
|
12
|
-
}
|
|
13
|
-
return function () { return void 0; };
|
|
14
|
-
}
|
|
15
|
-
export default on;
|
package/onClickOutside.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { off, on } from "./index.js";
|
|
2
|
-
export function onClickOutside(element, callback, autoUnbind) {
|
|
3
|
-
if (autoUnbind === void 0) { autoUnbind = false; }
|
|
4
|
-
var bind = function (event) {
|
|
5
|
-
if (!element.contains(event.target)) {
|
|
6
|
-
callback(event);
|
|
7
|
-
if (autoUnbind)
|
|
8
|
-
unbind();
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
var unbind = function () {
|
|
12
|
-
off(document, "click", bind);
|
|
13
|
-
};
|
|
14
|
-
on(document, "click", bind);
|
|
15
|
-
return unbind;
|
|
16
|
-
}
|
package/once.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import off from "./off.js";
|
|
2
|
-
import on from "./on.js";
|
|
3
|
-
export function once(el, type, handler, options) {
|
|
4
|
-
if (options === void 0) { options = false; }
|
|
5
|
-
var handlerWrapper = function (event) {
|
|
6
|
-
handler(event);
|
|
7
|
-
off(el, type, handlerWrapper);
|
|
8
|
-
};
|
|
9
|
-
return on(el, type, handlerWrapper, options);
|
|
10
|
-
}
|
|
11
|
-
export default once;
|
package/removeClass.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function removeClass(el, className) {
|
|
2
|
-
if (className === void 0) { className = ""; }
|
|
3
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
4
|
-
if (!el) {
|
|
5
|
-
("[@koine/dom:removeClass] unexisting DOM element");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
if (el)
|
|
10
|
-
el.classList.remove(className);
|
|
11
|
-
}
|
|
12
|
-
export default removeClass;
|
package/scrollTo.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { off } from "./off.js";
|
|
2
|
-
import { on } from "./on.js";
|
|
3
|
-
export function scrollTo(destination, callback, fallbackTimeout, behavior) {
|
|
4
|
-
var fixedDestination = destination.toFixed();
|
|
5
|
-
if (callback) {
|
|
6
|
-
var callbackFired_1 = false;
|
|
7
|
-
var onScroll_1 = function () {
|
|
8
|
-
if (window.pageYOffset.toFixed() === fixedDestination) {
|
|
9
|
-
off(window, "scroll", onScroll_1);
|
|
10
|
-
callbackFired_1 = true;
|
|
11
|
-
callback();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
on(window, "scroll", onScroll_1);
|
|
15
|
-
onScroll_1();
|
|
16
|
-
if (fallbackTimeout) {
|
|
17
|
-
setTimeout(function () {
|
|
18
|
-
if (!callbackFired_1) {
|
|
19
|
-
off(window, "scroll", onScroll_1);
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
}, fallbackTimeout);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
window.scrollTo({
|
|
26
|
-
top: destination,
|
|
27
|
-
behavior: behavior || "smooth",
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
export default scrollTo;
|
package/setDataAttr.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function setDataAttr(element, attribute, value) {
|
|
2
|
-
if (value === null || typeof value === "undefined") {
|
|
3
|
-
element.removeAttribute("data-" + attribute);
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
element.setAttribute("data-" + attribute, value.toString());
|
|
7
|
-
}
|
|
8
|
-
export default setDataAttr;
|
package/setVendorCSS.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function setVendorCSS(element, prop, value) {
|
|
2
|
-
var propUpper = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
3
|
-
element.style["webkit" + propUpper] = value;
|
|
4
|
-
element.style["moz" + propUpper] = value;
|
|
5
|
-
element.style["ms" + propUpper] = value;
|
|
6
|
-
element.style["o" + propUpper] = value;
|
|
7
|
-
element.style[prop] = value;
|
|
8
|
-
}
|
|
9
|
-
export default setVendorCSS;
|
package/siblings.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function siblings(node) {
|
|
2
|
-
if (node && node.parentNode) {
|
|
3
|
-
var n = node.parentNode.firstChild;
|
|
4
|
-
var matched = [];
|
|
5
|
-
for (; n; n = n.nextSibling) {
|
|
6
|
-
if (n.nodeType === 1 && n !== node) {
|
|
7
|
-
matched.push(n);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return matched;
|
|
11
|
-
}
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
export default siblings;
|
package/toArray.js
DELETED
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/typings.d.ts
DELETED
package/unlisten.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { activeEvents, eventHandler, getIndex, } from "./_listen-delegation.js";
|
|
2
|
-
import { off } from "./off.js";
|
|
3
|
-
export function unlisten(types, selector, callback) {
|
|
4
|
-
types.split(",").forEach(function (type) {
|
|
5
|
-
type = type.trim();
|
|
6
|
-
if (!activeEvents[type])
|
|
7
|
-
return;
|
|
8
|
-
if (activeEvents[type].length < 2 || !selector) {
|
|
9
|
-
delete activeEvents[type];
|
|
10
|
-
off(window, type, eventHandler, true);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
var index = getIndex(activeEvents[type], selector, callback);
|
|
14
|
-
if (index < 0)
|
|
15
|
-
return;
|
|
16
|
-
activeEvents[type].splice(index, 1);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
export default unlisten;
|