@koine/dom 2.0.0-alpha.4 → 2.0.0-beta.2
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/getVisualBackgroundColor.d.ts +6 -0
- package/getVisualBackgroundColor.js +25 -0
- package/getVisualBackgroundColor.mjs +21 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/index.mjs +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the background color of an element eventually looking recursively into
|
|
3
|
+
* its parents, if nothing is found it returns a `#fff` background
|
|
4
|
+
*/
|
|
5
|
+
export declare function getVisualBackgroundColor(elem?: null | HTMLElement): string;
|
|
6
|
+
export default getVisualBackgroundColor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVisualBackgroundColor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get the background color of an element eventually looking recursively into
|
|
6
|
+
* its parents, if nothing is found it returns a `#fff` background
|
|
7
|
+
*/
|
|
8
|
+
function getVisualBackgroundColor(elem) {
|
|
9
|
+
if (!elem)
|
|
10
|
+
return "#fff";
|
|
11
|
+
var transparent = "rgba(0, 0, 0, 0)";
|
|
12
|
+
var transparentIE11 = "transparent";
|
|
13
|
+
// if (!elem) return transparent;
|
|
14
|
+
var bg = window.getComputedStyle(elem).backgroundColor;
|
|
15
|
+
if (bg === transparent || bg === transparentIE11) {
|
|
16
|
+
var parent_1 = elem.parentElement;
|
|
17
|
+
if (parent_1) {
|
|
18
|
+
return getVisualBackgroundColor(parent_1);
|
|
19
|
+
}
|
|
20
|
+
return "#fff";
|
|
21
|
+
}
|
|
22
|
+
return bg;
|
|
23
|
+
}
|
|
24
|
+
exports.getVisualBackgroundColor = getVisualBackgroundColor;
|
|
25
|
+
exports.default = getVisualBackgroundColor;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the background color of an element eventually looking recursively into
|
|
3
|
+
* its parents, if nothing is found it returns a `#fff` background
|
|
4
|
+
*/
|
|
5
|
+
export function getVisualBackgroundColor(elem) {
|
|
6
|
+
if (!elem)
|
|
7
|
+
return "#fff";
|
|
8
|
+
var transparent = "rgba(0, 0, 0, 0)";
|
|
9
|
+
var transparentIE11 = "transparent";
|
|
10
|
+
// if (!elem) return transparent;
|
|
11
|
+
var bg = window.getComputedStyle(elem).backgroundColor;
|
|
12
|
+
if (bg === transparent || bg === transparentIE11) {
|
|
13
|
+
var parent_1 = elem.parentElement;
|
|
14
|
+
if (parent_1) {
|
|
15
|
+
return getVisualBackgroundColor(parent_1);
|
|
16
|
+
}
|
|
17
|
+
return "#fff";
|
|
18
|
+
}
|
|
19
|
+
return bg;
|
|
20
|
+
}
|
|
21
|
+
export default getVisualBackgroundColor;
|
package/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { getOffsetTop } from "./getOffsetTop";
|
|
|
17
17
|
export { getOffsetTopSlim } from "./getOffsetTopSlim";
|
|
18
18
|
export { getScrollbarWidth } from "./getScrollbarWidth";
|
|
19
19
|
export { getStyleValue } from "./getStyleValue";
|
|
20
|
+
export { getVisualBackgroundColor } from "./getVisualBackgroundColor";
|
|
20
21
|
export { injectCss } from "./injectCss";
|
|
21
22
|
export { isHidden } from "./isHidden";
|
|
22
23
|
export { isInViewport } from "./isInViewport";
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unlisten = exports.toArray = exports.siblings = exports.setVendorCSS = exports.setDataAttr = exports.scrollTo = exports.removeClass = exports.on = exports.onClickOutside = exports.once = exports.off = exports.listen = exports.listenScrollThrottled = exports.listenScrollDebounced = exports.listenScroll = exports.listenResizeThrottled = exports.listenResizeDebounced = exports.listenResize = exports.listenOnce = exports.listenLoaded = exports.isTotallyScrolled = exports.isNodeList = exports.isInViewport = exports.isHidden = exports.injectCss = exports.getStyleValue = exports.getScrollbarWidth = exports.getOffsetTopSlim = exports.getOffsetTop = exports.getOffset = exports.getListeners = exports.getHeight = exports.getDocumentHeight = exports.getDataAttr = exports.forEach = exports.exists = exports.escapeSelector = exports.emitEvent = exports.createElement = exports.calculateFixedOffset = exports.addClass = exports.$ = exports.$each = exports.$$ = void 0;
|
|
3
|
+
exports.unlisten = exports.toArray = exports.siblings = exports.setVendorCSS = exports.setDataAttr = exports.scrollTo = exports.removeClass = exports.on = exports.onClickOutside = exports.once = exports.off = exports.listen = exports.listenScrollThrottled = exports.listenScrollDebounced = exports.listenScroll = exports.listenResizeThrottled = exports.listenResizeDebounced = exports.listenResize = exports.listenOnce = exports.listenLoaded = exports.isTotallyScrolled = exports.isNodeList = exports.isInViewport = exports.isHidden = exports.injectCss = exports.getVisualBackgroundColor = exports.getStyleValue = exports.getScrollbarWidth = exports.getOffsetTopSlim = exports.getOffsetTop = exports.getOffset = exports.getListeners = exports.getHeight = exports.getDocumentHeight = exports.getDataAttr = exports.forEach = exports.exists = exports.escapeSelector = exports.emitEvent = exports.createElement = exports.calculateFixedOffset = exports.addClass = exports.$ = exports.$each = exports.$$ = void 0;
|
|
4
4
|
var __1 = require("./$$");
|
|
5
5
|
Object.defineProperty(exports, "$$", { enumerable: true, get: function () { return __1.$$; } });
|
|
6
6
|
var _each_1 = require("./$each");
|
|
@@ -39,6 +39,8 @@ var getScrollbarWidth_1 = require("./getScrollbarWidth");
|
|
|
39
39
|
Object.defineProperty(exports, "getScrollbarWidth", { enumerable: true, get: function () { return getScrollbarWidth_1.getScrollbarWidth; } });
|
|
40
40
|
var getStyleValue_1 = require("./getStyleValue");
|
|
41
41
|
Object.defineProperty(exports, "getStyleValue", { enumerable: true, get: function () { return getStyleValue_1.getStyleValue; } });
|
|
42
|
+
var getVisualBackgroundColor_1 = require("./getVisualBackgroundColor");
|
|
43
|
+
Object.defineProperty(exports, "getVisualBackgroundColor", { enumerable: true, get: function () { return getVisualBackgroundColor_1.getVisualBackgroundColor; } });
|
|
42
44
|
var injectCss_1 = require("./injectCss");
|
|
43
45
|
Object.defineProperty(exports, "injectCss", { enumerable: true, get: function () { return injectCss_1.injectCss; } });
|
|
44
46
|
var isHidden_1 = require("./isHidden");
|
package/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ export { getOffsetTop } from "./getOffsetTop";
|
|
|
17
17
|
export { getOffsetTopSlim } from "./getOffsetTopSlim";
|
|
18
18
|
export { getScrollbarWidth } from "./getScrollbarWidth";
|
|
19
19
|
export { getStyleValue } from "./getStyleValue";
|
|
20
|
+
export { getVisualBackgroundColor } from "./getVisualBackgroundColor";
|
|
20
21
|
export { injectCss } from "./injectCss";
|
|
21
22
|
export { isHidden } from "./isHidden";
|
|
22
23
|
export { isInViewport } from "./isInViewport";
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koine/dom",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"clsx": "1.2.1",
|
|
6
|
+
"ts-debounce": "^4.0.0",
|
|
7
|
+
"type-fest": "^3.11.1"
|
|
8
|
+
},
|
|
4
9
|
"peerDependencies": {
|
|
5
10
|
"tslib": "2.5.3"
|
|
6
11
|
},
|
|
7
12
|
"main": "./index.js",
|
|
8
13
|
"types": "./index.d.ts",
|
|
9
|
-
"version": "2.0.0-
|
|
14
|
+
"version": "2.0.0-beta.2",
|
|
10
15
|
"module": "./index.mjs"
|
|
11
16
|
}
|