targetj 1.1.0 → 1.1.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/build/AnimationManager.js +220 -152
- package/build/AnimationUtil.js +0 -1
- package/build/App.js +79 -39
- package/build/BaseModel.js +43 -11
- package/build/Easing.js +5 -0
- package/build/EventListener.js +29 -9
- package/build/HtmlToCanvas.js +411 -0
- package/build/LocationManager.js +44 -14
- package/build/PageManager.js +84 -33
- package/build/ParticleChild.js +12 -11
- package/build/ParticleExplode.js +360 -0
- package/build/ParticleRenderer.js +672 -192
- package/build/ParticleRuntime.js +844 -311
- package/build/ParticleTModel.js +370 -175
- package/build/ParticleUtil.js +9 -3
- package/build/RunScheduler.js +13 -8
- package/build/StateManager.js +125 -33
- package/build/StateUtil.js +142 -83
- package/build/TModel.js +179 -74
- package/build/TModelManager.js +127 -108
- package/build/TModelUtil.js +230 -143
- package/build/TUtil.js +4 -4
- package/build/TargetData.js +20 -12
- package/build/TargetExecutor.js +37 -14
- package/build/TargetManager.js +13 -18
- package/build/TargetParser.js +36 -2
- package/build/TargetUtil.js +189 -128
- package/build/VisibilityUtil.js +25 -14
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
package/build/PageManager.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
11
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
12
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
13
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
@@ -8,7 +17,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
8
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
19
|
import { TUtil } from "./TUtil.js";
|
|
11
|
-
import { tApp, App, getLocationManager, getEvents } from "./App.js";
|
|
20
|
+
import { tApp, App, getLocationManager, getEvents, getRunScheduler } from "./App.js";
|
|
12
21
|
import { DomInit } from "./DomInit.js";
|
|
13
22
|
import { TModelUtil } from "./TModelUtil.js";
|
|
14
23
|
|
|
@@ -20,7 +29,7 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
20
29
|
function PageManager() {
|
|
21
30
|
_classCallCheck(this, PageManager);
|
|
22
31
|
this.currentLink = TUtil.getFullLink(document.URL);
|
|
23
|
-
this.
|
|
32
|
+
this.pageCache = new Map();
|
|
24
33
|
this.initHistory();
|
|
25
34
|
}
|
|
26
35
|
return _createClass(PageManager, [{
|
|
@@ -99,38 +108,42 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
99
108
|
case 0:
|
|
100
109
|
updateHistory = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
101
110
|
link = TUtil.getFullLink(link);
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
if (!(link === this.currentLink)) {
|
|
112
|
+
_context2.next = 4;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context2.abrupt("return");
|
|
104
116
|
case 4:
|
|
105
|
-
|
|
117
|
+
_context2.next = 6;
|
|
118
|
+
return this.storePage(this.currentLink);
|
|
119
|
+
case 6:
|
|
106
120
|
if (updateHistory) {
|
|
107
121
|
history.pushState({
|
|
108
122
|
link: link
|
|
109
123
|
}, "", link);
|
|
110
124
|
}
|
|
111
125
|
this.currentLink = link;
|
|
112
|
-
if (!
|
|
113
|
-
_context2.next =
|
|
126
|
+
if (!this.pageCache.has(link)) {
|
|
127
|
+
_context2.next = 12;
|
|
114
128
|
break;
|
|
115
129
|
}
|
|
116
|
-
_context2.next =
|
|
130
|
+
_context2.next = 11;
|
|
117
131
|
return this.restorePage(link);
|
|
118
|
-
case 10:
|
|
119
|
-
return _context2.abrupt("return");
|
|
120
132
|
case 11:
|
|
121
|
-
_context2.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
_context2.next = 15;
|
|
125
|
-
return tApp.reset();
|
|
126
|
-
case 15:
|
|
133
|
+
return _context2.abrupt("return");
|
|
134
|
+
case 12:
|
|
135
|
+
// Application was already stopped and reset by storePage().
|
|
127
136
|
tApp.tRoot.$dom.innerHTML("");
|
|
128
137
|
App.oids = {};
|
|
129
138
|
App.tmodelIdMap = {};
|
|
130
139
|
tApp.tRoot = tApp.tRootFactory();
|
|
131
|
-
_context2.next =
|
|
132
|
-
return tApp.start(
|
|
133
|
-
|
|
140
|
+
_context2.next = 18;
|
|
141
|
+
return tApp.start({
|
|
142
|
+
skipSchedulerReset: true
|
|
143
|
+
});
|
|
144
|
+
case 18:
|
|
145
|
+
getRunScheduler().schedule(0, "pagemanager-processOpenLink");
|
|
146
|
+
case 19:
|
|
134
147
|
case "end":
|
|
135
148
|
return _context2.stop();
|
|
136
149
|
}
|
|
@@ -155,19 +168,33 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
155
168
|
key: "storePage",
|
|
156
169
|
value: function () {
|
|
157
170
|
var _storePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(link) {
|
|
158
|
-
var
|
|
171
|
+
var runSnapshot;
|
|
159
172
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
160
173
|
while (1) switch (_context3.prev = _context3.next) {
|
|
161
174
|
case 0:
|
|
162
175
|
link = TUtil.getFullLink(link);
|
|
176
|
+
runSnapshot = getRunScheduler().getSnapshot();
|
|
177
|
+
_context3.next = 4;
|
|
178
|
+
return tApp.stop();
|
|
179
|
+
case 4:
|
|
180
|
+
getLocationManager().cancelCurrentCalculation();
|
|
163
181
|
this.onPageClose();
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
182
|
+
this.pageCache.set(link, {
|
|
183
|
+
html: TModelUtil.getPageDom().innerHTML(),
|
|
184
|
+
tRoot: tApp.tRoot,
|
|
185
|
+
oids: _objectSpread({}, App.oids),
|
|
186
|
+
tmodelIdMap: _objectSpread({}, App.tmodelIdMap),
|
|
187
|
+
visibleOidMap: _objectSpread({}, tApp.manager.visibleOidMap),
|
|
188
|
+
scrollLeft: window.scrollX,
|
|
189
|
+
scrollTop: window.scrollY,
|
|
190
|
+
runSnapshot: runSnapshot
|
|
191
|
+
});
|
|
192
|
+
_context3.next = 9;
|
|
193
|
+
return tApp.reset({
|
|
194
|
+
preserveCachedModels: true,
|
|
195
|
+
skipSchedulerReset: true
|
|
196
|
+
});
|
|
197
|
+
case 9:
|
|
171
198
|
case "end":
|
|
172
199
|
return _context3.stop();
|
|
173
200
|
}
|
|
@@ -182,19 +209,43 @@ var PageManager = /*#__PURE__*/function () {
|
|
|
182
209
|
key: "restorePage",
|
|
183
210
|
value: function () {
|
|
184
211
|
var _restorePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(link) {
|
|
185
|
-
var
|
|
212
|
+
var cached, visibles, newVisibles, restored;
|
|
186
213
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
187
214
|
while (1) switch (_context4.prev = _context4.next) {
|
|
188
215
|
case 0:
|
|
189
|
-
|
|
190
|
-
if (
|
|
216
|
+
cached = this.pageCache.get(TUtil.getFullLink(link));
|
|
217
|
+
if (cached) {
|
|
191
218
|
_context4.next = 3;
|
|
192
219
|
break;
|
|
193
220
|
}
|
|
194
|
-
return _context4.abrupt("return", tApp.stateManager.restore(key));
|
|
195
|
-
case 3:
|
|
196
221
|
return _context4.abrupt("return", false);
|
|
197
|
-
case
|
|
222
|
+
case 3:
|
|
223
|
+
tApp.tRoot = cached.tRoot;
|
|
224
|
+
App.oids = _objectSpread({}, cached.oids);
|
|
225
|
+
App.tmodelIdMap = _objectSpread({}, cached.tmodelIdMap);
|
|
226
|
+
TModelUtil.getPageDom().innerHTML(cached.html);
|
|
227
|
+
tApp.tRoot.$dom = TModelUtil.getRootDom();
|
|
228
|
+
visibles = Object.values(cached.visibleOidMap);
|
|
229
|
+
newVisibles = DomInit.initCacheDoms(visibles);
|
|
230
|
+
visibles.forEach(function (tmodel) {
|
|
231
|
+
tmodel.visibilityStatus = undefined;
|
|
232
|
+
});
|
|
233
|
+
tApp.manager.visibleOidMap = _objectSpread({}, cached.visibleOidMap);
|
|
234
|
+
newVisibles.forEach(function (tmodel) {
|
|
235
|
+
tApp.manager.visibleOidMap[tmodel.oid] = tmodel;
|
|
236
|
+
});
|
|
237
|
+
restored = _toConsumableArray(new Set([].concat(visibles, _toConsumableArray(newVisibles))));
|
|
238
|
+
tApp.manager.activatePendingTargetsAfterDom(restored);
|
|
239
|
+
window.scrollTo(cached.scrollLeft, cached.scrollTop);
|
|
240
|
+
tApp.tRoot.markLayoutDirty("pageCacheRestore");
|
|
241
|
+
_context4.next = 19;
|
|
242
|
+
return tApp.start({
|
|
243
|
+
skipSchedulerReset: true
|
|
244
|
+
});
|
|
245
|
+
case 19:
|
|
246
|
+
getRunScheduler().restoreSnapshot(cached.runSnapshot);
|
|
247
|
+
return _context4.abrupt("return", true);
|
|
248
|
+
case 21:
|
|
198
249
|
case "end":
|
|
199
250
|
return _context4.stop();
|
|
200
251
|
}
|
package/build/ParticleChild.js
CHANGED
|
@@ -286,7 +286,8 @@ var ParticleChild = /*#__PURE__*/function () {
|
|
|
286
286
|
}, {
|
|
287
287
|
key: "isInFlow",
|
|
288
288
|
value: function isInFlow() {
|
|
289
|
-
|
|
289
|
+
var _this$val9;
|
|
290
|
+
return (_this$val9 = this.val("isInFlow")) !== null && _this$val9 !== void 0 ? _this$val9 : true;
|
|
290
291
|
}
|
|
291
292
|
}, {
|
|
292
293
|
key: "isIncluded",
|
|
@@ -543,32 +544,32 @@ var ParticleChild = /*#__PURE__*/function () {
|
|
|
543
544
|
}, {
|
|
544
545
|
key: "getBoxSizing",
|
|
545
546
|
value: function getBoxSizing() {
|
|
546
|
-
var _ref5, _ref6, _this$
|
|
547
|
-
return (_ref5 = (_ref6 = (_this$
|
|
547
|
+
var _ref5, _ref6, _this$val10;
|
|
548
|
+
return (_ref5 = (_ref6 = (_this$val10 = this.val("boxSizing")) !== null && _this$val10 !== void 0 ? _this$val10 : this.val("box-sizing")) !== null && _ref6 !== void 0 ? _ref6 : this.getParentValue("boxSizing")) !== null && _ref5 !== void 0 ? _ref5 : "content-box";
|
|
548
549
|
}
|
|
549
550
|
}, {
|
|
550
551
|
key: "getPaddingTop",
|
|
551
552
|
value: function getPaddingTop() {
|
|
552
|
-
var _ref7, _this$
|
|
553
|
-
return (_ref7 = (_this$
|
|
553
|
+
var _ref7, _this$val11;
|
|
554
|
+
return (_ref7 = (_this$val11 = this.val("paddingTop")) !== null && _this$val11 !== void 0 ? _this$val11 : this.val("topPadding")) !== null && _ref7 !== void 0 ? _ref7 : TModelUtil.getPaddingValue(this, "top");
|
|
554
555
|
}
|
|
555
556
|
}, {
|
|
556
557
|
key: "getPaddingLeft",
|
|
557
558
|
value: function getPaddingLeft() {
|
|
558
|
-
var _ref8, _this$
|
|
559
|
-
return (_ref8 = (_this$
|
|
559
|
+
var _ref8, _this$val12;
|
|
560
|
+
return (_ref8 = (_this$val12 = this.val("paddingLeft")) !== null && _this$val12 !== void 0 ? _this$val12 : this.val("leftPadding")) !== null && _ref8 !== void 0 ? _ref8 : TModelUtil.getPaddingValue(this, "left");
|
|
560
561
|
}
|
|
561
562
|
}, {
|
|
562
563
|
key: "getPaddingRight",
|
|
563
564
|
value: function getPaddingRight() {
|
|
564
|
-
var _ref9, _this$
|
|
565
|
-
return (_ref9 = (_this$
|
|
565
|
+
var _ref9, _this$val13;
|
|
566
|
+
return (_ref9 = (_this$val13 = this.val("paddingRight")) !== null && _this$val13 !== void 0 ? _this$val13 : this.val("rightPadding")) !== null && _ref9 !== void 0 ? _ref9 : TModelUtil.getPaddingValue(this, "right");
|
|
566
567
|
}
|
|
567
568
|
}, {
|
|
568
569
|
key: "getPaddingBottom",
|
|
569
570
|
value: function getPaddingBottom() {
|
|
570
|
-
var _ref10, _this$
|
|
571
|
-
return (_ref10 = (_this$
|
|
571
|
+
var _ref10, _this$val14;
|
|
572
|
+
return (_ref10 = (_this$val14 = this.val("paddingBottom")) !== null && _this$val14 !== void 0 ? _this$val14 : this.val("bottomPadding")) !== null && _ref10 !== void 0 ? _ref10 : TModelUtil.getPaddingValue(this, "bottom");
|
|
572
573
|
}
|
|
573
574
|
}]);
|
|
574
575
|
}();
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
6
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
13
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
import { TargetParser } from "./TargetParser.js";
|
|
17
|
+
import { TModel } from "./TModel.js";
|
|
18
|
+
import { TUtil } from "./TUtil.js";
|
|
19
|
+
import { getRunScheduler } from "./App.js";
|
|
20
|
+
var ParticleExplode = /*#__PURE__*/function () {
|
|
21
|
+
function ParticleExplode() {
|
|
22
|
+
_classCallCheck(this, ParticleExplode);
|
|
23
|
+
}
|
|
24
|
+
return _createClass(ParticleExplode, null, [{
|
|
25
|
+
key: "createExplodeChildren",
|
|
26
|
+
value: function createExplodeChildren(tmodel, key) {
|
|
27
|
+
var _tmodel$targets$key, _target$renderer;
|
|
28
|
+
var definition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
29
|
+
var needsDomImage = function needsDomImage(childDefinition) {
|
|
30
|
+
if (childDefinition.image === false) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (childDefinition.image === true) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
var color = childDefinition.backgroundColor;
|
|
37
|
+
|
|
38
|
+
// A fixed background color does not need a captured image.
|
|
39
|
+
return !(typeof color === 'string' && color.trim() !== '');
|
|
40
|
+
};
|
|
41
|
+
var target = (_tmodel$targets$key = tmodel.targets[key]) !== null && _tmodel$targets$key !== void 0 ? _tmodel$targets$key : {};
|
|
42
|
+
var renderer = (_target$renderer = target.renderer) !== null && _target$renderer !== void 0 ? _target$renderer : "gpu";
|
|
43
|
+
if (renderer !== "gpu" && renderer !== "dom") {
|
|
44
|
+
throw new Error("Unsupported explodeChildren renderer: ".concat(renderer));
|
|
45
|
+
}
|
|
46
|
+
var valueFactory = typeof target.value === "function" ? target.value : typeof definition === "function" ? definition : undefined;
|
|
47
|
+
var sharedDefinition = valueFactory ? undefined : definition;
|
|
48
|
+
var source = ParticleExplode.resolveSource(tmodel, target.source);
|
|
49
|
+
var sourceElement = ParticleExplode.resolveDomElement(source);
|
|
50
|
+
if (!sourceElement) {
|
|
51
|
+
throw new Error("explodeChildren.source must resolve to a TModel, $Dom, or DOM element with an existing DOM.");
|
|
52
|
+
}
|
|
53
|
+
var _ParticleExplode$getS = ParticleExplode.getSourceDimensions(source, sourceElement),
|
|
54
|
+
uiWidth = _ParticleExplode$getS.width,
|
|
55
|
+
uiHeight = _ParticleExplode$getS.height;
|
|
56
|
+
if (!Number.isFinite(uiWidth) || !Number.isFinite(uiHeight) || uiWidth <= 0 || uiHeight <= 0) {
|
|
57
|
+
throw new RangeError("explodeChildren requires positive, resolved source dimensions.");
|
|
58
|
+
}
|
|
59
|
+
var resolveDimension = function resolveDimension(name, value, index) {
|
|
60
|
+
var initial = typeof value === 'function' ? value.call(tmodel, index) : value;
|
|
61
|
+
var number = Number(TargetParser.getInitialTargetValue(tmodel, name, initial));
|
|
62
|
+
if (!Number.isFinite(number) || (name === 'width' || name === 'height') && number <= 0) {
|
|
63
|
+
throw new RangeError("explodeChildren fragment ".concat(index, " requires a valid ").concat(name, "."));
|
|
64
|
+
}
|
|
65
|
+
return number;
|
|
66
|
+
};
|
|
67
|
+
var firstExplodeChild = renderer === "gpu" ? tmodel.childHandles.length : tmodel.getChildren().length;
|
|
68
|
+
var requestedCount = TUtil.isDefined(target.instances) ? TargetParser.getTargetInstances(tmodel, key, target) : undefined;
|
|
69
|
+
var state = {
|
|
70
|
+
key: key,
|
|
71
|
+
renderer: renderer,
|
|
72
|
+
columns: undefined,
|
|
73
|
+
rows: undefined,
|
|
74
|
+
count: 0,
|
|
75
|
+
width: uiWidth,
|
|
76
|
+
height: uiHeight,
|
|
77
|
+
particleWidth: undefined,
|
|
78
|
+
particleHeight: undefined,
|
|
79
|
+
firstExplodeChild: firstExplodeChild,
|
|
80
|
+
fragments: []
|
|
81
|
+
};
|
|
82
|
+
var planned = [];
|
|
83
|
+
var maxFragments = 20000;
|
|
84
|
+
var epsilon = 1e-7;
|
|
85
|
+
var nextX = 0;
|
|
86
|
+
var rowY = 0;
|
|
87
|
+
var rowHeight = 0;
|
|
88
|
+
while (requestedCount === undefined ? rowY < uiHeight - epsilon : planned.length < requestedCount) {
|
|
89
|
+
var _raw$width, _raw$height, _raw$isInFlow;
|
|
90
|
+
var index = planned.length;
|
|
91
|
+
if (index >= maxFragments) {
|
|
92
|
+
throw new RangeError("explodeChildren exceeded ".concat(maxFragments, " fragments. Specify instances or larger dimensions."));
|
|
93
|
+
}
|
|
94
|
+
var raw = valueFactory ? valueFactory.call(tmodel, index) : sharedDefinition !== null && sharedDefinition !== void 0 ? sharedDefinition : {};
|
|
95
|
+
if (!raw || _typeof(raw) !== "object" || Array.isArray(raw)) {
|
|
96
|
+
throw new TypeError("explodeChildren.value(".concat(index, ") must return a child definition object."));
|
|
97
|
+
}
|
|
98
|
+
var childDefinition = TUtil.cloneTargetDefinition(_objectSpread(_objectSpread({}, raw), {}, {
|
|
99
|
+
width: (_raw$width = raw.width) !== null && _raw$width !== void 0 ? _raw$width : 20,
|
|
100
|
+
height: (_raw$height = raw.height) !== null && _raw$height !== void 0 ? _raw$height : 20,
|
|
101
|
+
isInFlow: (_raw$isInFlow = raw.isInFlow) !== null && _raw$isInFlow !== void 0 ? _raw$isInFlow : false
|
|
102
|
+
}));
|
|
103
|
+
var requestedWidth = resolveDimension("width", childDefinition.width, index);
|
|
104
|
+
var requestedHeight = resolveDimension("height", childDefinition.height, index);
|
|
105
|
+
var layoutX = nextX;
|
|
106
|
+
var layoutY = rowY;
|
|
107
|
+
var x = TUtil.isDefined(childDefinition.x) ? resolveDimension("x", childDefinition.x, index) : layoutX;
|
|
108
|
+
var y = TUtil.isDefined(childDefinition.y) ? resolveDimension("y", childDefinition.y, index) : layoutY;
|
|
109
|
+
var layoutWidth = Math.min(requestedWidth, uiWidth - x);
|
|
110
|
+
var layoutHeight = Math.min(requestedHeight, uiHeight - y);
|
|
111
|
+
if (layoutWidth <= epsilon || layoutHeight <= epsilon) {
|
|
112
|
+
if (requestedCount !== undefined) {
|
|
113
|
+
throw new RangeError("explodeChildren cannot fit fragment ".concat(index, " within the source dimensions."));
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (x < 0 || x >= uiWidth || y < 0 || y >= uiHeight) {
|
|
118
|
+
throw new RangeError("explodeChildren fragment ".concat(index, " starts outside the source image (").concat(x, ", ").concat(y, ")."));
|
|
119
|
+
}
|
|
120
|
+
var width = Math.min(requestedWidth, uiWidth - x);
|
|
121
|
+
var height = Math.min(requestedHeight, uiHeight - y);
|
|
122
|
+
childDefinition.x = x;
|
|
123
|
+
childDefinition.y = y;
|
|
124
|
+
childDefinition.width = width;
|
|
125
|
+
childDefinition.height = height;
|
|
126
|
+
|
|
127
|
+
// Preserve both the image rectangle and the generated layout position.
|
|
128
|
+
state.fragments.push({
|
|
129
|
+
index: index,
|
|
130
|
+
x: x,
|
|
131
|
+
y: y,
|
|
132
|
+
width: width,
|
|
133
|
+
height: height,
|
|
134
|
+
layoutX: layoutX,
|
|
135
|
+
layoutY: layoutY
|
|
136
|
+
});
|
|
137
|
+
planned.push(childDefinition);
|
|
138
|
+
nextX += layoutWidth;
|
|
139
|
+
rowHeight = Math.max(rowHeight, layoutHeight);
|
|
140
|
+
if (nextX >= uiWidth - epsilon) {
|
|
141
|
+
nextX = 0;
|
|
142
|
+
rowY += rowHeight;
|
|
143
|
+
rowHeight = 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
state.count = state.fragments.length;
|
|
147
|
+
tmodel.explodeChildrenState = state;
|
|
148
|
+
var needsCapture = planned.some(needsDomImage);
|
|
149
|
+
var capturePromise = needsCapture ? tmodel.captureExplodeSource(uiWidth, uiHeight, source) : undefined;
|
|
150
|
+
var domChildren = [];
|
|
151
|
+
for (var _index = 0; _index < planned.length; _index++) {
|
|
152
|
+
var _tmodel$addedChildren;
|
|
153
|
+
var _childDefinition = planned[_index];
|
|
154
|
+
var _state$fragments$_ind = state.fragments[_index],
|
|
155
|
+
_x = _state$fragments$_ind.x,
|
|
156
|
+
_y = _state$fragments$_ind.y,
|
|
157
|
+
_layoutX = _state$fragments$_ind.layoutX,
|
|
158
|
+
_layoutY = _state$fragments$_ind.layoutY;
|
|
159
|
+
if (renderer === "gpu") {
|
|
160
|
+
if (!tmodel.addGpuChild(_childDefinition)) {
|
|
161
|
+
throw new Error("Could not create GPU fragment ".concat(_index, "."));
|
|
162
|
+
}
|
|
163
|
+
var _child = tmodel.childHandles[firstExplodeChild + _index];
|
|
164
|
+
_child.layoutX = _layoutX;
|
|
165
|
+
_child.layoutY = _layoutY;
|
|
166
|
+
_child.targets.excludeXYCalc = true;
|
|
167
|
+
_child.setLayoutX(_x);
|
|
168
|
+
_child.setLayoutY(_y);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
var useImage = needsDomImage(_childDefinition);
|
|
172
|
+
if (useImage) {
|
|
173
|
+
_childDefinition.backgroundImage = {
|
|
174
|
+
enabledOn: false,
|
|
175
|
+
value: function value() {
|
|
176
|
+
var color = this.val('backgroundColor');
|
|
177
|
+
return !TUtil.isDefined(color) || color === '' ? "url(\"".concat(state.imageUrl, "\")") : 'none';
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
_childDefinition.backgroundSize = "".concat(uiWidth, "px ").concat(uiHeight, "px");
|
|
181
|
+
_childDefinition.backgroundPosition = "-".concat(_x, "px -").concat(_y, "px");
|
|
182
|
+
_childDefinition.backgroundRepeat = "no-repeat";
|
|
183
|
+
}
|
|
184
|
+
var previousCount = tmodel.addedChildren.length;
|
|
185
|
+
tmodel.addChild(_childDefinition);
|
|
186
|
+
var child = (_tmodel$addedChildren = tmodel.addedChildren[previousCount]) === null || _tmodel$addedChildren === void 0 ? void 0 : _tmodel$addedChildren.child;
|
|
187
|
+
if (!child) {
|
|
188
|
+
throw new Error("Could not create DOM fragment ".concat(_index, "."));
|
|
189
|
+
}
|
|
190
|
+
child.layoutX = _layoutX;
|
|
191
|
+
child.layoutY = _layoutY;
|
|
192
|
+
child.targets.excludeXYCalc = true;
|
|
193
|
+
child.setLayoutX(_x);
|
|
194
|
+
child.setLayoutY(_y);
|
|
195
|
+
if (useImage) {
|
|
196
|
+
domChildren.push(child);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
tmodel.explodeCapturePromise = capturePromise ? capturePromise.then(function (capture) {
|
|
200
|
+
return ParticleExplode.applyExplodeCapture(tmodel, state, capture, domChildren);
|
|
201
|
+
}).catch(function (error) {
|
|
202
|
+
if (tmodel.explodeChildrenState === state) {
|
|
203
|
+
state.captureError = error;
|
|
204
|
+
}
|
|
205
|
+
console.error("Could not prepare explode image:", error);
|
|
206
|
+
return false;
|
|
207
|
+
}) : undefined;
|
|
208
|
+
if (renderer === "gpu") {
|
|
209
|
+
return tmodel.finalizeChildrenTarget(key);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "applyExplodeCapture",
|
|
214
|
+
value: function () {
|
|
215
|
+
var _applyExplodeCapture = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tmodel, state, capture, children) {
|
|
216
|
+
var imageUrl, image, _iterator, _step, child;
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
218
|
+
while (1) switch (_context.prev = _context.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
if (!(tmodel.explodeChildrenState !== state)) {
|
|
221
|
+
_context.next = 2;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
return _context.abrupt("return", false);
|
|
225
|
+
case 2:
|
|
226
|
+
if (!(state.renderer === "gpu")) {
|
|
227
|
+
_context.next = 4;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
return _context.abrupt("return", tmodel.particleRenderer.setExplodeSource(capture));
|
|
231
|
+
case 4:
|
|
232
|
+
imageUrl = capture.canvas.toDataURL("image/png");
|
|
233
|
+
image = new Image();
|
|
234
|
+
image.src = imageUrl;
|
|
235
|
+
_context.next = 9;
|
|
236
|
+
return image.decode();
|
|
237
|
+
case 9:
|
|
238
|
+
if (!(tmodel.explodeChildrenState !== state)) {
|
|
239
|
+
_context.next = 11;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
return _context.abrupt("return", false);
|
|
243
|
+
case 11:
|
|
244
|
+
state.imageUrl = imageUrl;
|
|
245
|
+
tmodel.getChildren();
|
|
246
|
+
_iterator = _createForOfIteratorHelper(children);
|
|
247
|
+
_context.prev = 14;
|
|
248
|
+
_iterator.s();
|
|
249
|
+
case 16:
|
|
250
|
+
if ((_step = _iterator.n()).done) {
|
|
251
|
+
_context.next = 24;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
child = _step.value;
|
|
255
|
+
if (!(tmodel.allChildrenMap[child.oid] !== child)) {
|
|
256
|
+
_context.next = 20;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context.abrupt("continue", 22);
|
|
260
|
+
case 20:
|
|
261
|
+
child.targets.backgroundImage.enabledOn = true;
|
|
262
|
+
child.addToActiveTargets("backgroundImage");
|
|
263
|
+
case 22:
|
|
264
|
+
_context.next = 16;
|
|
265
|
+
break;
|
|
266
|
+
case 24:
|
|
267
|
+
_context.next = 29;
|
|
268
|
+
break;
|
|
269
|
+
case 26:
|
|
270
|
+
_context.prev = 26;
|
|
271
|
+
_context.t0 = _context["catch"](14);
|
|
272
|
+
_iterator.e(_context.t0);
|
|
273
|
+
case 29:
|
|
274
|
+
_context.prev = 29;
|
|
275
|
+
_iterator.f();
|
|
276
|
+
return _context.finish(29);
|
|
277
|
+
case 32:
|
|
278
|
+
tmodel.markLayoutDirty("domExplodeImagesReady");
|
|
279
|
+
getRunScheduler().schedule(1, "dom-explode-".concat(tmodel.oid));
|
|
280
|
+
return _context.abrupt("return", true);
|
|
281
|
+
case 35:
|
|
282
|
+
case "end":
|
|
283
|
+
return _context.stop();
|
|
284
|
+
}
|
|
285
|
+
}, _callee, null, [[14, 26, 29, 32]]);
|
|
286
|
+
}));
|
|
287
|
+
function applyExplodeCapture(_x2, _x3, _x4, _x5) {
|
|
288
|
+
return _applyExplodeCapture.apply(this, arguments);
|
|
289
|
+
}
|
|
290
|
+
return applyExplodeCapture;
|
|
291
|
+
}()
|
|
292
|
+
}, {
|
|
293
|
+
key: "resolveSource",
|
|
294
|
+
value: function resolveSource(tmodel, dom) {
|
|
295
|
+
var _dom;
|
|
296
|
+
if (typeof dom === "function") {
|
|
297
|
+
dom = dom.call(tmodel);
|
|
298
|
+
}
|
|
299
|
+
return (_dom = dom) !== null && _dom !== void 0 ? _dom : tmodel;
|
|
300
|
+
}
|
|
301
|
+
}, {
|
|
302
|
+
key: "resolveDomElement",
|
|
303
|
+
value: function resolveDomElement(source) {
|
|
304
|
+
if (source instanceof Element) {
|
|
305
|
+
return source;
|
|
306
|
+
}
|
|
307
|
+
if (source instanceof TModel) {
|
|
308
|
+
var _source$$dom;
|
|
309
|
+
return (_source$$dom = source.$dom) === null || _source$$dom === void 0 ? void 0 : _source$$dom.element;
|
|
310
|
+
}
|
|
311
|
+
if ((source === null || source === void 0 ? void 0 : source.element) instanceof Element) {
|
|
312
|
+
return source.element;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "getSourceDimensions",
|
|
317
|
+
value: function getSourceDimensions(source, element) {
|
|
318
|
+
var width;
|
|
319
|
+
var height;
|
|
320
|
+
if (source instanceof TModel) {
|
|
321
|
+
width = Number(source.getWidth());
|
|
322
|
+
height = Number(source.getHeight());
|
|
323
|
+
}
|
|
324
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
325
|
+
var rect = element.getBoundingClientRect();
|
|
326
|
+
width = rect.width;
|
|
327
|
+
height = rect.height;
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
width: width,
|
|
331
|
+
height: height
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
key: "getExplodeFragment",
|
|
336
|
+
value: function getExplodeFragment(state, childIndex) {
|
|
337
|
+
var index = childIndex - state.firstExplodeChild;
|
|
338
|
+
if (index < 0 || index >= state.count) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (state.fragments) {
|
|
342
|
+
return state.fragments[index];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Support checkpoints created with the original uniform-grid format.
|
|
346
|
+
var column = index % state.columns;
|
|
347
|
+
var row = Math.floor(index / state.columns);
|
|
348
|
+
var x = column * state.particleWidth;
|
|
349
|
+
var y = row * state.particleHeight;
|
|
350
|
+
return {
|
|
351
|
+
index: index,
|
|
352
|
+
x: x,
|
|
353
|
+
y: y,
|
|
354
|
+
width: Math.min(state.particleWidth, state.width - x),
|
|
355
|
+
height: Math.min(state.particleHeight, state.height - y)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}]);
|
|
359
|
+
}();
|
|
360
|
+
export { ParticleExplode };
|