@vnejs/plugins.canvas.sprite 0.1.3 → 0.1.5
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/const/const.js +0 -6
- package/const/params.js +4 -4
- package/modules/change.js +5 -3
- package/modules/hide.js +2 -2
- package/modules/move.js +4 -2
- package/modules/show.js +4 -2
- package/modules/utils.js +0 -9
- package/package.json +1 -1
package/const/const.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
export const ACTIONS = { SHOW: "show", HIDE: "hide", CHANGE: "change", MOVE: "move" };
|
|
2
2
|
|
|
3
|
-
export const LINE_MOVE_REG = /^(?<id>[a-zA-Z_0-9-]+) move (?<position>[a-zA-Z_0-9-]+)( (?<duration>\d+))?( async)?$/;
|
|
4
|
-
export const LINE_SHOW_REG =
|
|
5
|
-
/^(?<id>[a-zA-Z_0-9-]+) show (?<position>[a-zA-Z_0-9-]+) {(?<variation>[a-zA-Z_0-9-/]+)}( (?<transition>[a-zA-Z_0-9-]+)[:](?<duration>\d+))?( async)?$/;
|
|
6
|
-
export const LINE_HIDE_REG = /^(?<id>[a-zA-Z_0-9-]+) hide( (?<transition>[a-zA-Z_0-9-]+)[:](?<duration>\d+))?( async)?$/;
|
|
7
|
-
export const LINE_CHANGE_REG = /^(?<id>[a-zA-Z_0-9-]+) change {(?<variation>[a-zA-Z_0-9-/]+)}( (?<duration>\d+))?( async)?$/;
|
|
8
|
-
|
|
9
3
|
export const LAYER_CHILD_TYPE = "sprite";
|
package/const/params.js
CHANGED
|
@@ -37,10 +37,10 @@ const mapEyes = (variation, parts, options) => {
|
|
|
37
37
|
|
|
38
38
|
return {
|
|
39
39
|
src: [
|
|
40
|
-
{ url: `${variation}/eyes/${parts.eyes}/opened`, duration: 3000, randomDuration: 1000, transition:
|
|
41
|
-
{ url: `${variation}/eyes/${parts.eyes}/closed`, duration: 100, randomDuration: 0, transition:
|
|
42
|
-
{ url: `${variation}/eyes/${parts.eyes}/opened`, duration: 200, randomDuration: 300, transition:
|
|
43
|
-
{ url: `${variation}/eyes/${parts.eyes}/closed`, duration: 100, randomDuration: 0, transition:
|
|
40
|
+
{ url: `${variation}/eyes/${parts.eyes}/opened`, duration: 3000, randomDuration: 1000, transition: 360 },
|
|
41
|
+
{ url: `${variation}/eyes/${parts.eyes}/closed`, duration: 100, randomDuration: 0, transition: 240 },
|
|
42
|
+
{ url: `${variation}/eyes/${parts.eyes}/opened`, duration: 200, randomDuration: 300, transition: 360 },
|
|
43
|
+
{ url: `${variation}/eyes/${parts.eyes}/closed`, duration: 100, randomDuration: 0, transition: 240 },
|
|
44
44
|
],
|
|
45
45
|
};
|
|
46
46
|
};
|
package/modules/change.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createPromiseResolve } from "@vnejs/helpers.create-promise-resolve";
|
|
4
|
+
|
|
5
|
+
import { getScale } from "./utils";
|
|
4
6
|
|
|
5
7
|
const EMPTY_IMG = { src: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxIDEiLz4=" };
|
|
6
8
|
|
|
@@ -22,7 +24,7 @@ export class LayerSpriteChange extends Module {
|
|
|
22
24
|
|
|
23
25
|
const parts = await this.getTransitionParts(layer, id, partsReal);
|
|
24
26
|
|
|
25
|
-
const { resolve: skipResolve, promise: skipPromise } =
|
|
27
|
+
const { resolve: skipResolve, promise: skipPromise } = createPromiseResolve();
|
|
26
28
|
const propsChange = { parts, indexSrc: partsReal[0].src, transition: Number(duration) };
|
|
27
29
|
|
|
28
30
|
await this.emit(this.EVENTS.INTERACT.PUSH_POP, {
|
|
@@ -49,7 +51,7 @@ export class LayerSpriteChange extends Module {
|
|
|
49
51
|
const props = positions[position] || positions.left;
|
|
50
52
|
const scale = props.scale ?? 1;
|
|
51
53
|
|
|
52
|
-
return { ...props, scale:
|
|
54
|
+
return { ...props, scale: getScale(scale) };
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
emitChildChange = (layer, childId, duration, props) => this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId, duration, props });
|
package/modules/hide.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createPromiseResolve } from "@vnejs/helpers.create-promise-resolve";
|
|
4
4
|
|
|
5
5
|
export class LayerSpriteHide extends Module {
|
|
6
6
|
name = "layer.sprite.hide";
|
|
@@ -19,7 +19,7 @@ export class LayerSpriteHide extends Module {
|
|
|
19
19
|
const childOld = await this.emitReal(this.EVENTS.LAYER.CHILD_GET, { layer, childId: id });
|
|
20
20
|
|
|
21
21
|
const { initialProps = {}, finishProps = {} } = this.getTransitionProps(transition, childOld.boxProps);
|
|
22
|
-
const { resolve: skipResolve, promise: skipPromise } =
|
|
22
|
+
const { resolve: skipResolve, promise: skipPromise } = createPromiseResolve();
|
|
23
23
|
|
|
24
24
|
const newBoxProps = { ...childOld.boxProps, transition: duration, ...initialProps };
|
|
25
25
|
|
package/modules/move.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createPromiseResolve } from "@vnejs/helpers.create-promise-resolve";
|
|
4
|
+
|
|
5
|
+
import { getScale } from "./utils";
|
|
4
6
|
|
|
5
7
|
export class LayerSpriteMove extends Module {
|
|
6
8
|
name = "layer.sprite.move";
|
|
@@ -19,7 +21,7 @@ export class LayerSpriteMove extends Module {
|
|
|
19
21
|
const childOld = await this.emitReal(this.EVENTS.LAYER.CHILD_GET, { layer, childId: id });
|
|
20
22
|
|
|
21
23
|
const newProps = { boxProps: { transition: duration, ...this.getBoxProps(position) } };
|
|
22
|
-
const { resolve: skipResolve, promise: skipPromise } =
|
|
24
|
+
const { resolve: skipResolve, promise: skipPromise } = createPromiseResolve();
|
|
23
25
|
|
|
24
26
|
await this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId: id, duration: 0, props: { boxProps: { ...childOld.boxProps, transition: duration } } });
|
|
25
27
|
|
package/modules/show.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createPromiseResolve } from "@vnejs/helpers.create-promise-resolve";
|
|
4
|
+
|
|
5
|
+
import { getScale } from "./utils";
|
|
4
6
|
|
|
5
7
|
export class LayerSpriteShow extends Module {
|
|
6
8
|
name = "layer.sprite.show";
|
|
@@ -20,7 +22,7 @@ export class LayerSpriteShow extends Module {
|
|
|
20
22
|
if (!duration || !transition || this.shared.viewForceAnimationSources.length) return this.emit(this.EVENTS.LAYER.CHILD_ADD, { layer, child: childCommon });
|
|
21
23
|
|
|
22
24
|
const { initialProps = {}, finishProps = {} } = this.getTransitionProps(transition, boxProps);
|
|
23
|
-
const { resolve: skipResolve, promise: skipPromise } =
|
|
25
|
+
const { resolve: skipResolve, promise: skipPromise } = createPromiseResolve();
|
|
24
26
|
const newBoxProps = { ...boxProps, transition: duration, ...initialProps };
|
|
25
27
|
|
|
26
28
|
await this.emit(this.EVENTS.LAYER.CHILD_ADD, { layer, child: { ...childCommon, boxProps: newBoxProps } });
|
package/modules/utils.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export const getPromiseAndResolve = () => {
|
|
2
|
-
const obj = {};
|
|
3
|
-
obj.promise = new Promise((resolve) => {
|
|
4
|
-
obj.resolve = resolve;
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
return obj;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
1
|
export const getScale = (scale) => `calc(${100 * scale} * min(calc(1vw / var(--vne-canvas-width, 3840px)), calc(1vh / var(--vne-canvas-height, 2160px))))`;
|