leafer-game 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/dist/web.cjs CHANGED
@@ -2,697 +2,39 @@
2
2
 
3
3
  var leaferUi = require('leafer-ui');
4
4
  var robot = require('@leafer-in/robot');
5
- var draw = require('@leafer-ui/draw');
6
- var core = require('@leafer-ui/core');
5
+ var state = require('@leafer-in/state');
7
6
  var animate = require('@leafer-in/animate');
7
+ var motionPath = require('@leafer-in/motion-path');
8
8
 
9
- function stateType(defaultValue, styleName) {
10
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
11
- set(value) {
12
- this.__setAttr(key, value);
13
- this.waitLeafer(() => styleName ? draw.State.setStyleName(this, styleName, value) : draw.State.set(this, value));
14
- }
15
- }));
16
- }
17
- function stateStyleType(defaultValue) {
18
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
19
- set(value) {
20
- this.__setAttr(key, value);
21
- this.__layout.stateStyleChanged = true;
22
- }
23
- }));
24
- }
25
9
 
26
- function findParentButton(leaf, button) {
27
- if (button && button !== true)
28
- return button;
29
- if (!leaf.button) {
30
- let { parent } = leaf;
31
- for (let i = 0; i < 2; i++) {
32
- if (parent) {
33
- if (parent.button)
34
- return parent;
35
- parent = parent.parent;
36
- }
37
- }
38
- }
39
- return null;
40
- }
41
10
 
42
- function setStyle(leaf, style) {
43
- if (typeof style !== 'object')
44
- style = undefined;
45
- updateStyle(leaf, style, 'in');
46
- }
47
- function unsetStyle(leaf, style) {
48
- const { normalStyle } = leaf;
49
- if (typeof style !== 'object')
50
- style = undefined;
51
- if (normalStyle) {
52
- if (!style)
53
- style = normalStyle;
54
- updateStyle(leaf, style, 'out');
55
- }
56
- }
57
- const emprtyStyle = {};
58
- function updateStyle(leaf, style, type) {
59
- const { normalStyle } = leaf;
60
- if (!style)
61
- style = emprtyStyle;
62
- if (style.scale) {
63
- core.MathHelper.assignScale(style, style.scale);
64
- delete style.scale;
65
- }
66
- if (style === emprtyStyle || !core.State.canAnimate)
67
- type = null;
68
- let transition = type ? getTransition(type, style, leaf) : false;
69
- const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
70
- leaf.killAnimate('transition');
71
- if (normalStyle)
72
- leaf.set(normalStyle, 'temp');
73
- const statesStyle = getStyle(leaf);
74
- if (statesStyle) {
75
- const { animation } = statesStyle;
76
- if (animation) {
77
- const animate = leaf.animate(animation, undefined, 'animation', true);
78
- Object.assign(statesStyle, animate.endingStyle);
79
- if (type !== 'in' || style.animation !== animation)
80
- animate.kill();
81
- else
82
- transition = false;
83
- delete statesStyle.animation;
84
- }
85
- leaf.normalStyle = filterStyle(statesStyle, leaf);
86
- leaf.set(statesStyle, 'temp');
87
- }
88
- else {
89
- leaf.normalStyle = undefined;
90
- }
91
- if (transition) {
92
- const toStyle = filterStyle(fromStyle, leaf);
93
- leaf.set(fromStyle, 'temp');
94
- leaf.animate([fromStyle, toStyle], transition, 'transition', true);
95
- }
96
- leaf.__layout.stateStyleChanged = false;
97
- }
98
- function getStyle(leaf) {
99
- let exist;
100
- const style = {}, { state } = leaf, button = findParentButton(leaf);
101
- const stateStyle = state && leaf.states[state];
102
- if (stateStyle && core.State.isState(state, leaf, button))
103
- exist = assign(style, stateStyle);
104
- const selectedStyle = style.selectedStyle || leaf.selectedStyle;
105
- if (selectedStyle && core.State.isSelected(leaf, button))
106
- exist = assign(style, selectedStyle);
107
- if (core.State.isDisabled(leaf, button)) {
108
- const disabledStyle = style.disabledStyle || leaf.disabledStyle;
109
- if (disabledStyle)
110
- exist = assign(style, disabledStyle);
111
- }
112
- else {
113
- const focusStyle = style.focusStyle || leaf.focusStyle;
114
- if (focusStyle && core.State.isFocus(leaf, button))
115
- exist = assign(style, focusStyle);
116
- const hoverStyle = style.hoverStyle || leaf.hoverStyle;
117
- if (hoverStyle && core.State.isHover(leaf, button))
118
- exist = assign(style, hoverStyle);
119
- const pressStyle = style.pressStyle || leaf.pressStyle;
120
- if (pressStyle && core.State.isPress(leaf, button))
121
- exist = assign(style, pressStyle);
122
- }
123
- return exist ? style : undefined;
124
- }
125
- function filterStyle(style, data, addStyle, useAnimateExcludes) {
126
- const to = addStyle ? style : {}, forStyle = addStyle || style;
127
- for (let key in forStyle) {
128
- if (useAnimateExcludes) {
129
- if (!core.State.animateExcludes[key])
130
- to[key] = data[key];
131
- }
132
- else
133
- to[key] = data[key];
134
- }
135
- return to;
136
- }
137
- function filterAnimateStyle(style, data, addStyle) {
138
- return filterStyle(style, data, addStyle, true);
139
- }
140
- function getFromStyle(leaf, style) {
141
- const fromStyle = filterAnimateStyle(style, leaf), animate = leaf.animate();
142
- if (animate)
143
- filterAnimateStyle(fromStyle, leaf, animate.fromStyle);
144
- return fromStyle;
145
- }
146
- function getTransition(type, style, data) {
147
- let name = type === 'in' ? 'transition' : 'transitionOut';
148
- if (type === 'out' && core.isNull(data[name]) && core.isNull(style[name]))
149
- name = 'transition';
150
- return core.isNull(style[name]) ? data[name] : style[name];
151
- }
152
- function assign(style, stateStyle) {
153
- Object.assign(style, stateStyle);
154
- return true;
155
- }
156
-
157
- function setPointerState(leaf, stateName) {
158
- const style = leaf[stateName];
159
- if (style)
160
- setStyle(leaf, style);
161
- if (leaf.button)
162
- setChildrenState(leaf.children, stateName);
163
- }
164
- function setState(leaf, stateName, stateStyle) {
165
- if (!stateStyle)
166
- stateStyle = leaf.states[stateName];
167
- setStyle(leaf, stateStyle);
168
- if (leaf.button)
169
- setChildrenState(leaf.children, null, stateName);
170
- }
171
- function setChildrenState(children, stateType, state) {
172
- if (!children)
173
- return;
174
- let leaf, update;
175
- for (let i = 0, len = children.length; i < len; i++) {
176
- leaf = children[i];
177
- if (stateType) {
178
- update = true;
179
- switch (stateType) {
180
- case 'hoverStyle':
181
- if (core.State.isHover(leaf))
182
- update = false;
183
- break;
184
- case 'pressStyle':
185
- if (core.State.isPress(leaf))
186
- update = false;
187
- break;
188
- case 'focusStyle':
189
- if (core.State.isFocus(leaf))
190
- update = false;
191
- }
192
- if (update)
193
- setPointerState(leaf, stateType);
194
- }
195
- else if (state)
196
- setState(leaf, state);
197
- if (leaf.isBranch)
198
- setChildrenState(leaf.children, stateType, state);
199
- }
200
- }
201
-
202
- function unsetPointerState(leaf, stateName) {
203
- const style = leaf[stateName];
204
- if (style)
205
- unsetStyle(leaf, style);
206
- if (leaf.button)
207
- unsetChildrenState(leaf.children, stateName);
208
- }
209
- function unsetState(leaf, stateName, stateStyle) {
210
- unsetStyle(leaf, stateStyle);
211
- if (leaf.button)
212
- unsetChildrenState(leaf.children, null, stateName);
213
- }
214
- function unsetChildrenState(children, stateType, state) {
215
- if (!children)
216
- return;
217
- let leaf;
218
- for (let i = 0, len = children.length; i < len; i++) {
219
- leaf = children[i];
220
- if (stateType)
221
- unsetPointerState(leaf, stateType);
222
- else if (state)
223
- unsetState(leaf, state);
224
- if (leaf.isBranch)
225
- unsetChildrenState(leaf.children, stateType, state);
226
- }
227
- }
228
-
229
- function updateEventStyle(leaf, eventType) {
230
- switch (eventType) {
231
- case core.PointerEvent.ENTER:
232
- setPointerState(leaf, 'hoverStyle');
233
- break;
234
- case core.PointerEvent.LEAVE:
235
- unsetPointerState(leaf, 'hoverStyle');
236
- break;
237
- case core.PointerEvent.DOWN:
238
- setPointerState(leaf, 'pressStyle');
239
- break;
240
- case core.PointerEvent.UP:
241
- unsetPointerState(leaf, 'pressStyle');
242
- break;
243
- }
244
- }
245
-
246
- function checkPointerState(fnName, leaf, button) {
247
- let find;
248
- const interaction = leaf.leafer ? leaf.leafer.interaction : null;
249
- if (interaction) {
250
- find = interaction[fnName](leaf);
251
- if (!find && button) {
252
- const parentButton = findParentButton(leaf, button);
253
- if (parentButton)
254
- find = interaction[fnName](parentButton);
255
- }
256
- }
257
- return find;
258
- }
259
- function checkFixedState(attrName, leaf, button) {
260
- let find = leaf[attrName];
261
- if (!find && button) {
262
- const parentButton = findParentButton(leaf, button);
263
- if (parentButton)
264
- find = parentButton[attrName];
265
- }
266
- return find;
267
- }
268
- function checkState(stateName, leaf, button) {
269
- let find = leaf.states[stateName];
270
- if (!find && button) {
271
- const parentButton = findParentButton(leaf, button);
272
- if (parentButton)
273
- find = parentButton.states[stateName];
274
- }
275
- return !!find;
276
- }
277
-
278
- core.State.animateExcludes = {
279
- animation: 1,
280
- animationOut: 1,
281
- transition: 1,
282
- transitionOut: 1,
283
- states: 1,
284
- state: 1,
285
- normalStyle: 1,
286
- hoverStyle: 1,
287
- pressStyle: 1,
288
- focusStyle: 1,
289
- selectedStyle: 1,
290
- disabledStyle: 1
291
- };
292
- core.State.isState = function (state, leaf, button) { return checkState(state, leaf, button); };
293
- core.State.isSelected = function (leaf, button) { return checkFixedState('selected', leaf, button); };
294
- core.State.isDisabled = function (leaf, button) { return checkFixedState('disabled', leaf, button); };
295
- core.State.isFocus = function (leaf, button) { return checkPointerState('isFocus', leaf, button); };
296
- core.State.isHover = function (leaf, button) { return checkPointerState('isHover', leaf, button); };
297
- core.State.isPress = function (leaf, button) { return checkPointerState('isPress', leaf, button); };
298
- core.State.isDrag = function (leaf, button) { return checkPointerState('isDrag', leaf, button); };
299
- core.State.setStyleName = function (leaf, stateType, value) { value ? setState(leaf, stateType, leaf[stateType]) : unsetState(leaf, stateType, leaf[stateType]); };
300
- core.State.set = function (leaf, stateName) { const style = leaf.states[stateName]; style ? setState(leaf, stateName, style) : unsetState(leaf, stateName, style); };
301
- core.State.getStyle = getStyle;
302
- core.State.updateStyle = updateStyle;
303
- core.State.updateEventStyle = updateEventStyle;
304
- const ui$1 = core.UI.prototype;
305
- stateType(false, 'selectedStyle')(ui$1, 'selected');
306
- stateType(false, 'disabledStyle')(ui$1, 'disabled');
307
- stateStyleType({})(ui$1, 'states');
308
- stateType('')(ui$1, 'state');
309
- core.dataType()(ui$1, 'normalStyle');
310
- stateStyleType()(ui$1, 'hoverStyle');
311
- stateStyleType()(ui$1, 'pressStyle');
312
- stateStyleType()(ui$1, 'focusStyle');
313
- stateStyleType()(ui$1, 'selectedStyle');
314
- stateStyleType()(ui$1, 'disabledStyle');
315
- core.dataType(false)(ui$1, 'button');
316
- ui$1.focus = function (value = true) {
317
- this.waitLeafer(() => {
318
- let { focusData } = this.app.interaction;
319
- if (value) {
320
- if (focusData)
321
- focusData.focus(false);
322
- focusData = this;
323
- }
324
- else
325
- focusData = null;
326
- this.app.interaction.focusData = focusData;
327
- value ? setPointerState(this, 'focusStyle') : unsetPointerState(this, 'focusStyle');
328
- });
329
- };
330
- ui$1.updateState = function () {
331
- core.State.updateStyle(this, undefined, 'in');
332
- };
333
-
334
- const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285];
335
- const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
336
- const { sqrt } = Math;
337
- const HighBezierHelper = {
338
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
339
- let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
340
- for (let i = 0; i < gaussNodes.length; i++) {
341
- t1 = half * (1 + gaussNodes[i]);
342
- t2 = half * (1 - gaussNodes[i]);
343
- d1X = getDerivative(t1, fromX, x1, x2, toX);
344
- d1Y = getDerivative(t1, fromY, y1, y2, toY);
345
- d2X = getDerivative(t2, fromX, x1, x2, toX);
346
- d2Y = getDerivative(t2, fromY, y1, y2, toY);
347
- distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
348
- }
349
- return distance * half;
350
- },
351
- getDerivative(t, fromV, v1, v2, toV) {
352
- const o = 1 - t;
353
- return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
354
- },
355
- getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
356
- const dx = getDerivative(t, fromX, x1, x2, toX);
357
- const dy = getDerivative(t, fromY, y1, y2, toY);
358
- return Math.atan2(dy, dx) / draw.OneRadian;
359
- },
360
- getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
361
- let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
362
- if (middle >= 1)
363
- return 1;
364
- if (middle <= 0)
365
- return 0;
366
- while (high - low > realPrecision) {
367
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
368
- middle = (low + high) / 2;
369
- }
370
- return middle;
371
- },
372
- cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
373
- const o = 1 - t;
374
- const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
375
- const mbx = o * x1 + t * x2, mby = o * y1 + t * y2;
376
- const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY;
377
- const bx = o * ax + t * mbx, by = o * ay + t * mby;
378
- const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy;
379
- const cx = o * bx + t * mbcx, cy = o * by + t * mbcy;
380
- data.push(draw.PathCommandMap.C, ax, ay, bx, by, cx, cy);
381
- }
382
- };
383
- const { getDerivative, getDistance } = HighBezierHelper;
384
-
385
- const { M, L, C, Z } = draw.PathCommandMap;
386
- const tempPoint = {}, tempFrom = {};
387
- const HighCurveHelper = {
388
- transform(data, matrix) {
389
- let i = 0, command;
390
- const len = data.length;
391
- while (i < len) {
392
- command = data[i];
393
- switch (command) {
394
- case M:
395
- case L:
396
- HighCurveHelper.transformPoints(data, matrix, i, 1);
397
- i += 3;
398
- break;
399
- case C:
400
- HighCurveHelper.transformPoints(data, matrix, i, 3);
401
- i += 7;
402
- break;
403
- case Z:
404
- i += 1;
405
- }
406
- }
407
- },
408
- transformPoints(data, matrix, start, pointCount) {
409
- for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {
410
- tempPoint.x = data[i];
411
- tempPoint.y = data[i + 1];
412
- draw.MatrixHelper.toOuterPoint(matrix, tempPoint);
413
- data[i] = tempPoint.x;
414
- data[i + 1] = tempPoint.y;
415
- }
416
- },
417
- getMotionPathData(data) {
418
- let total = 0, distance, segments = [];
419
- let i = 0, x = 0, y = 0, toX, toY, command;
420
- const len = data.length;
421
- while (i < len) {
422
- command = data[i];
423
- switch (command) {
424
- case M:
425
- case L:
426
- toX = data[i + 1];
427
- toY = data[i + 2];
428
- distance = (command === L && i > 0) ? draw.PointHelper.getDistanceFrom(x, y, toX, toY) : 0;
429
- x = toX;
430
- y = toY;
431
- i += 3;
432
- break;
433
- case C:
434
- toX = data[i + 5];
435
- toY = data[i + 6];
436
- distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY);
437
- x = toX;
438
- y = toY;
439
- i += 7;
440
- break;
441
- case Z:
442
- i += 1;
443
- default:
444
- distance = 0;
445
- }
446
- segments.push(distance);
447
- total += distance;
448
- }
449
- return { total, segments, data };
450
- },
451
- getDistancePoint(distanceData, motionDistance, motionPrecision) {
452
- const { segments, data } = distanceData;
453
- motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
454
- let total = 0, distance, to = {};
455
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
456
- let x1, y1, x2, y2, t;
457
- const len = data.length;
458
- while (i < len) {
459
- command = data[i];
460
- switch (command) {
461
- case M:
462
- case L:
463
- toX = data[i + 1];
464
- toY = data[i + 2];
465
- distance = segments[index];
466
- if (total + distance > motionDistance || !distanceData.total) {
467
- if (!i)
468
- x = toX, y = toY;
469
- tempFrom.x = x;
470
- tempFrom.y = y;
471
- to.x = toX;
472
- to.y = toY;
473
- draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
474
- to.rotation = draw.PointHelper.getAngle(tempFrom, to);
475
- return to;
476
- }
477
- x = toX;
478
- y = toY;
479
- i += 3;
480
- break;
481
- case C:
482
- toX = data[i + 5];
483
- toY = data[i + 6];
484
- distance = segments[index];
485
- if (total + distance > motionDistance) {
486
- x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
487
- t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
488
- draw.BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
489
- to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
490
- return to;
491
- }
492
- x = toX;
493
- y = toY;
494
- i += 7;
495
- break;
496
- case Z:
497
- i += 1;
498
- default:
499
- distance = 0;
500
- }
501
- index++;
502
- total += distance;
503
- }
504
- return to;
505
- },
506
- getDistancePath(distanceData, motionDistance, motionPrecision) {
507
- const { segments, data } = distanceData, path = [];
508
- motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
509
- let total = 0, distance, to = {};
510
- let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
511
- let x1, y1, x2, y2, t;
512
- const len = data.length;
513
- while (i < len) {
514
- command = data[i];
515
- switch (command) {
516
- case M:
517
- case L:
518
- toX = data[i + 1];
519
- toY = data[i + 2];
520
- distance = segments[index];
521
- if (total + distance > motionDistance || !distanceData.total) {
522
- if (!i)
523
- x = toX, y = toY;
524
- tempFrom.x = x;
525
- tempFrom.y = y;
526
- to.x = toX;
527
- to.y = toY;
528
- draw.PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true);
529
- path.push(command, to.x, to.y);
530
- return path;
531
- }
532
- x = toX;
533
- y = toY;
534
- i += 3;
535
- path.push(command, x, y);
536
- break;
537
- case C:
538
- x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
539
- toX = data[i + 5];
540
- toY = data[i + 6];
541
- distance = segments[index];
542
- if (total + distance > motionDistance) {
543
- t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
544
- HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
545
- return path;
546
- }
547
- x = toX;
548
- y = toY;
549
- i += 7;
550
- path.push(command, x1, y1, x2, y2, toX, toY);
551
- break;
552
- case Z:
553
- i += 1;
554
- path.push(command);
555
- default:
556
- distance = 0;
557
- }
558
- index++;
559
- total += distance;
560
- }
561
- return path;
562
- }
563
- };
564
-
565
- function motionPathType(defaultValue) {
566
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
567
- set(value) {
568
- this.__setAttr(key, value);
569
- this.__hasMotionPath = this.motionPath || !draw.isNull(this.motion);
570
- this.__layout.matrixChanged || this.__layout.matrixChange();
571
- }
572
- }));
573
- }
574
-
575
- draw.Transition.register('motion', function (from, to, t, target) {
576
- if (!from)
577
- from = 0;
578
- else if (typeof from === 'object')
579
- from = draw.UnitConvert.number(from, target.getMotionTotal());
580
- if (!to)
581
- to = 0;
582
- else if (typeof to === 'object')
583
- to = draw.UnitConvert.number(to, target.getMotionTotal());
584
- return draw.Transition.number(from, to, t);
585
- });
586
- draw.Transition.register('motionRotation', function (from, to, t) {
587
- return draw.Transition.number(from, to, t);
588
- });
589
- const ui = draw.UI.prototype;
590
- const { updateMatrix, updateAllMatrix } = draw.LeafHelper;
591
- const { updateBounds } = draw.BranchHelper;
592
- motionPathType()(ui, 'motionPath');
593
- motionPathType(1)(ui, 'motionPrecision');
594
- motionPathType()(ui, 'motion');
595
- motionPathType(true)(ui, 'motionRotation');
596
- ui.getMotionPathData = function () {
597
- return getMotionPathData(getMotionPath(this));
598
- };
599
- ui.getMotionPoint = function (motionDistance) {
600
- const path = getMotionPath(this);
601
- const data = getMotionPathData(path);
602
- if (!data.total)
603
- return {};
604
- const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
605
- draw.MatrixHelper.toOuterPoint(path.localTransform, point);
606
- const { motionRotation } = this;
607
- if (motionRotation === false)
608
- delete point.rotation;
609
- else if (typeof motionRotation === 'number')
610
- point.rotation += motionRotation;
611
- return point;
612
- };
613
- ui.getMotionTotal = function () {
614
- return this.getMotionPathData().total;
615
- };
616
- ui.__updateMotionPath = function () {
617
- const data = this.__;
618
- if (this.__layout.resized && data.__pathForMotion)
619
- data.__pathForMotion = undefined;
620
- if (this.motionPath) {
621
- let child;
622
- const { children } = this.parent, { leaferIsReady } = this;
623
- for (let i = 0; i < children.length; i++) {
624
- child = children[i];
625
- if (!draw.isNull(child.motion) && !child.__layout.matrixChanged) {
626
- if (leaferIsReady && child !== this)
627
- this.leafer.layouter.addExtra(child);
628
- updateMotion(child);
629
- }
630
- }
631
- }
632
- else
633
- updateMotion(this);
634
- };
635
- function updateMotion(leaf) {
636
- const { motion, leaferIsCreated } = leaf;
637
- if (draw.isNull(motion))
638
- return;
639
- if (leaferIsCreated)
640
- leaf.leafer.created = false;
641
- if (leaf.motionPath) {
642
- const data = getMotionPathData(leaf);
643
- if (data.total)
644
- leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
645
- }
646
- else {
647
- leaf.set(leaf.getMotionPoint(motion));
648
- if (!leaf.__hasAutoLayout) {
649
- if (leaf.isBranch)
650
- updateAllMatrix(leaf), updateBounds(leaf, leaf);
651
- else
652
- updateMatrix(leaf);
653
- }
654
- }
655
- if (leaferIsCreated)
656
- leaf.leafer.created = true;
657
- }
658
- function getMotionPath(leaf) {
659
- const { parent } = leaf;
660
- if (!leaf.motionPath && parent) {
661
- const { children } = parent;
662
- for (let i = 0; i < children.length; i++) {
663
- if (children[i].motionPath)
664
- return children[i];
665
- }
666
- }
667
- return leaf;
668
- }
669
- function getMotionPathData(leaf) {
670
- const data = leaf.__;
671
- if (data.__pathForMotion)
672
- return data.__pathForMotion;
673
- return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
674
- }
675
-
676
- exports.HighBezierHelper = HighBezierHelper;
677
- exports.HighCurveHelper = HighCurveHelper;
678
- exports.motionPathType = motionPathType;
679
- exports.stateStyleType = stateStyleType;
680
- exports.stateType = stateType;
681
11
  Object.keys(leaferUi).forEach(function (k) {
682
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
683
- enumerable: true,
684
- get: function () { return leaferUi[k]; }
685
- });
12
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
+ enumerable: true,
14
+ get: function () { return leaferUi[k]; }
15
+ });
686
16
  });
687
17
  Object.keys(robot).forEach(function (k) {
688
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
689
- enumerable: true,
690
- get: function () { return robot[k]; }
691
- });
18
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
19
+ enumerable: true,
20
+ get: function () { return robot[k]; }
21
+ });
22
+ });
23
+ Object.keys(state).forEach(function (k) {
24
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
25
+ enumerable: true,
26
+ get: function () { return state[k]; }
27
+ });
692
28
  });
693
29
  Object.keys(animate).forEach(function (k) {
694
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
695
- enumerable: true,
696
- get: function () { return animate[k]; }
697
- });
30
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
31
+ enumerable: true,
32
+ get: function () { return animate[k]; }
33
+ });
34
+ });
35
+ Object.keys(motionPath).forEach(function (k) {
36
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
37
+ enumerable: true,
38
+ get: function () { return motionPath[k]; }
39
+ });
698
40
  });