-
Notifications
You must be signed in to change notification settings - Fork 0
/
skeletonize.umd.js
62 lines (47 loc) · 1.54 KB
/
skeletonize.umd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
* Skeletonize.js
* Dynamic skeleton loaders with minimal effort
*/
var Skeletonize = function Skeletonize(_node, options) {
var _this = this;
_classCallCheck(this, Skeletonize);
_defineProperty(this, "init", function () {
_this._walkDOM(_this.node);
});
_defineProperty(this, "add", function () {
_this.skeletonEls.map(function (el) {
el.style.position = "relative";
el.classList.add('skeletonizejs');
});
});
_defineProperty(this, "remove", function () {
_this.skeletonEls.map(function (el) {
el.style.position = "";
el.classList.remove('skeletonizejs');
});
});
_defineProperty(this, "_walkDOM", function (node) {
_this._filter(node);
node = node.firstElementChild;
while (node) {
_this._walkDOM(node, _this._filter);
node = node.nextElementSibling;
}
});
_defineProperty(this, "_filter", function (node) {
if (node.children.length === 0) {
_this.skeletonEls.push(node);
}
});
this.node = _node;
this.skeletonEls = [];
this.init();
};
exports["default"] = Skeletonize;