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