@leafer-game/miniapp 1.1.0 → 1.1.1

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