@vnejs/plugins.controllers.scenario.interface.fastforward 0.0.0-stage → 0.2.12
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/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/modules/controller.d.ts +38 -0
- package/dist/modules/controller.js +71 -0
- package/dist/modules/view.d.ts +9 -0
- package/dist/modules/view.js +8 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +1 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +11 -0
- package/dist/view/index.styles.d.ts +1 -0
- package/dist/view/index.styles.js +25 -0
- package/package.json +61 -4
- package/src/index.ts +10 -0
- package/src/modules/controller.ts +117 -0
- package/src/modules/view.ts +26 -0
- package/src/tests/controller.test.ts +73 -0
- package/src/tests/setup.ts +46 -0
- package/src/types.ts +37 -0
- package/src/view/index.styles.ts +28 -0
- package/src/view/index.tsx +62 -0
- package/tsconfig.json +10 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
2
|
+
import { regPlugin } from "@vnejs/registry";
|
|
3
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
4
|
+
import { InterfaceFastforwardViewController } from "./modules/controller.js";
|
|
5
|
+
import { InterfaceFastforwardView } from "./modules/view.js";
|
|
6
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceFastforwardViewController, InterfaceFastforwardView]);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { InterfaceFastforwardDisableAnimationPayload, InterfaceFastforwardForcePayload } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
3
|
+
import type { FastforwardChangedPayload } from "@vnejs/contracts.scenario.fastforward";
|
|
4
|
+
import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
|
|
5
|
+
import type { InterfaceFastforwardPluginState } from "../types.js";
|
|
6
|
+
export declare class InterfaceFastforwardViewController extends ModuleController<InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginSettings, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginState> {
|
|
7
|
+
name: string;
|
|
8
|
+
EVENT_UPDATE_VIEW: "vne:interface_fastforward:update";
|
|
9
|
+
EVENT_UPDATE_STATE: "vne:interface_fastforward:update_state";
|
|
10
|
+
EVENT_UPDATE_FAST: "vne:interface_fastforward:update_fast";
|
|
11
|
+
EVENT_UPDATE_FORCE: "vne:interface_fastforward:update_force";
|
|
12
|
+
EVENT_SHOW: "vne:interface_fastforward:show";
|
|
13
|
+
EVENT_HIDE: "vne:interface_fastforward:hide";
|
|
14
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP: boolean;
|
|
15
|
+
CONTROLS: {
|
|
16
|
+
abstract_fastforward_toggle: () => undefined;
|
|
17
|
+
abstract_fastforward_start: () => undefined;
|
|
18
|
+
abstract_fastforward_finish: () => undefined;
|
|
19
|
+
};
|
|
20
|
+
CONTROLS_UNVISIBLE: {};
|
|
21
|
+
CONTROLS_CHECK_NEXT: boolean;
|
|
22
|
+
CONTROLS_INDEX: number;
|
|
23
|
+
subscribe: () => void;
|
|
24
|
+
start: () => Promise<string>;
|
|
25
|
+
onClick: () => false | Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
26
|
+
onDisableAnimation: ({ isDisabled }?: InterfaceFastforwardDisableAnimationPayload) => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
27
|
+
onShowChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<import("@vnejs/registry").EmitResults<"vne:interface_fastforward:hide" | "vne:interface_fastforward:show">> | undefined;
|
|
28
|
+
onViewChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
29
|
+
onStateChanged: () => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
30
|
+
onVisibleChanged: ({ isForce }?: InterfaceFastforwardForcePayload) => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
31
|
+
onFastForward: ({ value }?: FastforwardChangedPayload) => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
32
|
+
onMemoryCleared: () => Promise<import("@vnejs/registry").EmitResults<string> | undefined>;
|
|
33
|
+
getDefaultState: () => InterfaceFastforwardPluginState;
|
|
34
|
+
emitFastforwardEvent: (event: string) => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
35
|
+
onShowBefore: () => Promise<void>;
|
|
36
|
+
toggleUnvisibleControls: (isVisible: boolean) => Promise<import("@vnejs/registry").EmitResults<"vne:controls:pop">> | Promise<import("@vnejs/registry").EmitResults<"vne:controls:push">> | undefined;
|
|
37
|
+
getIconSrc: () => Promise<string>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class InterfaceFastforwardViewController extends ModuleController {
|
|
3
|
+
name = "interface.fastforward.view.controller";
|
|
4
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
5
|
+
EVENT_UPDATE_STATE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_STATE;
|
|
6
|
+
EVENT_UPDATE_FAST = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_FAST;
|
|
7
|
+
EVENT_UPDATE_FORCE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_FORCE;
|
|
8
|
+
EVENT_SHOW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW;
|
|
9
|
+
EVENT_HIDE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
|
|
10
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP = false;
|
|
11
|
+
CONTROLS = {
|
|
12
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
|
|
13
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
|
|
14
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
|
|
15
|
+
};
|
|
16
|
+
CONTROLS_UNVISIBLE = {};
|
|
17
|
+
CONTROLS_CHECK_NEXT = true;
|
|
18
|
+
CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX + 200;
|
|
19
|
+
subscribe = () => {
|
|
20
|
+
super.subscribe();
|
|
21
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
|
|
22
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.DISABLE_ANIMATION, this.onDisableAnimation);
|
|
23
|
+
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
24
|
+
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
25
|
+
this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
|
|
26
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
|
|
27
|
+
this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
|
|
28
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
29
|
+
};
|
|
30
|
+
start = () => this.getIconSrc();
|
|
31
|
+
onClick = () => {
|
|
32
|
+
const { isShow = false, isVisible = false } = this.globalState.interface;
|
|
33
|
+
return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
|
|
34
|
+
};
|
|
35
|
+
onDisableAnimation = ({ isDisabled = false } = {}) => this.updateStateAndViewFast({ isAnimationDisabled: isDisabled });
|
|
36
|
+
onShowChanged = ({ isForce = false } = {}) => {
|
|
37
|
+
const { isShow = false } = this.globalState.interface;
|
|
38
|
+
const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
|
|
39
|
+
if (this.state.isShow !== isShow)
|
|
40
|
+
return this.emit(event, { isForce });
|
|
41
|
+
};
|
|
42
|
+
onViewChanged = ({ isForce = false } = {}) => {
|
|
43
|
+
const { view = "" } = this.globalState.interface;
|
|
44
|
+
if (this.state.view !== view)
|
|
45
|
+
return this.updateStateAndView({ view }, isForce, !isForce);
|
|
46
|
+
};
|
|
47
|
+
onStateChanged = () => {
|
|
48
|
+
const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
|
|
49
|
+
this.toggleUnvisibleControls(isVisible);
|
|
50
|
+
return this.updateStateAndViewForce({ isVisible, isShow, view });
|
|
51
|
+
};
|
|
52
|
+
onVisibleChanged = ({ isForce = false } = {}) => {
|
|
53
|
+
const { isVisible = false } = this.globalState.interface;
|
|
54
|
+
this.toggleUnvisibleControls(isVisible);
|
|
55
|
+
if (this.state.isVisible !== isVisible)
|
|
56
|
+
return this.updateStateAndView({ isVisible }, isForce, !isForce);
|
|
57
|
+
};
|
|
58
|
+
onFastForward = ({ value } = {}) => this.updateStateAndViewFast({ isActive: value });
|
|
59
|
+
onMemoryCleared = async () => this.updateStateAndViewFast({ iconSrc: await this.getIconSrc() });
|
|
60
|
+
getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isAnimationDisabled: false, isForce: false });
|
|
61
|
+
emitFastforwardEvent = (event) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
|
|
62
|
+
onShowBefore = async () => {
|
|
63
|
+
return this.updateState({ iconSrc: await this.getIconSrc() });
|
|
64
|
+
};
|
|
65
|
+
toggleUnvisibleControls = (isVisible) => {
|
|
66
|
+
if (isVisible)
|
|
67
|
+
return this.emit(this.EVENTS.CONTROLS.POP, { key: `${this.name}-unvisible` });
|
|
68
|
+
return this.emit(this.EVENTS.CONTROLS.PUSH, { key: `${this.name}-unvisible`, controls: this.CONTROLS_UNVISIBLE, index: this.CONTROLS_INDEX + 500 });
|
|
69
|
+
};
|
|
70
|
+
getIconSrc = async () => (await this.loadImageMedia("interface/fastforward", "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
|
|
71
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginSettings } from "../types.js";
|
|
3
|
+
import type { InterfaceFastforwardPluginState } from "../types.js";
|
|
4
|
+
export declare class InterfaceFastforwardView extends ModuleView<InterfaceFastforwardPluginEvents, InterfaceFastforwardPluginConstants, InterfaceFastforwardPluginSettings, InterfaceFastforwardPluginParams, InterfaceFastforwardPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_UPDATE_VIEW: "vne:interface_fastforward:update";
|
|
7
|
+
TRANSITION: number;
|
|
8
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<InterfaceFastforwardPluginState>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class InterfaceFastforwardView extends ModuleView {
|
|
4
|
+
name = "interface.fastforward.view";
|
|
5
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
6
|
+
TRANSITION = this.PARAMS.INTERFACE.TRANSITION;
|
|
7
|
+
renderFunc = render;
|
|
8
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/contracts.canvas.layer";
|
|
3
|
+
import type { Params as InterfaceParams, PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface";
|
|
4
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
5
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/contracts.controls";
|
|
6
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
|
|
7
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
|
|
8
|
+
import type { PluginName as FastforwardPluginName, SubscribeEvents as FastforwardSubscribeEvents } from "@vnejs/contracts.scenario.fastforward";
|
|
9
|
+
export type InterfaceFastforwardPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<InterfacePluginName, InterfaceSubscribeEvents> & Record<FastforwardPluginName, FastforwardSubscribeEvents> & Record<ControlsPluginName, ControlsSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
10
|
+
export type InterfaceFastforwardPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
11
|
+
export type InterfaceFastforwardPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
12
|
+
export type InterfaceFastforwardPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<InterfacePluginName, InterfaceParams>;
|
|
13
|
+
export type InterfaceFastforwardPluginState = {
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
isVisible: boolean;
|
|
16
|
+
isShow: boolean;
|
|
17
|
+
isAnimationDisabled: boolean;
|
|
18
|
+
isForce: boolean;
|
|
19
|
+
view?: string;
|
|
20
|
+
iconSrc?: string;
|
|
21
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, View, createRenderFunc, useIsForceHook, useStoreState } from "@vnejs/uis.react";
|
|
3
|
+
import { b } from "./index.styles.js";
|
|
4
|
+
const InterfaceFastForward = ({ store, onMount, emit, EVENTS, PARAMS }) => {
|
|
5
|
+
const { isShow = false, isVisible = false, isForce = false, isActive = false, isAnimationDisabled = false, view = "", iconSrc = "", } = useStoreState(store, onMount);
|
|
6
|
+
const isRealForce = useIsForceHook(isForce);
|
|
7
|
+
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
8
|
+
const propsByView = PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view];
|
|
9
|
+
return (_jsx(View, { ...propsByView?.view, isShow: isShow, isForce: isRealForce, transition: transition, onClick: () => emit(EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK), className: b({ isAnimated: isActive && !isAnimationDisabled }), isHidden: !isVisible, zIndex: PARAMS.INTERFACE.ZINDEX + 200, children: _jsx(Icon, { ...propsByView?.icon, src: iconSrc, transition: transition }) }));
|
|
10
|
+
};
|
|
11
|
+
export const render = createRenderFunc(InterfaceFastForward);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const b: import("@bem-react/classname").ClassNameFormatter;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn, injectStyles, sel } from "@vnejs/uis.utils";
|
|
2
|
+
export const b = cn("InterfaceFastForward");
|
|
3
|
+
const CSS = `
|
|
4
|
+
@keyframes fastforward {
|
|
5
|
+
from {
|
|
6
|
+
transform: scale(1.1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
50% {
|
|
10
|
+
transform: scale(0.9);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
to {
|
|
14
|
+
transform: scale(1.1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
${sel(b({ isAnimated: true }))} {
|
|
19
|
+
animation-duration: 500ms;
|
|
20
|
+
animation-name: fastforward;
|
|
21
|
+
animation-iteration-count: infinite;
|
|
22
|
+
animation-timing-function: ease-in-out;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
injectStyles(CSS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.controllers.scenario.interface.fastforward",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.12",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "npx @vnejs/monorepo test",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/contracts.controllers.scenario.interface.fastforward": "~0.2.0",
|
|
34
|
+
"@vnejs/contracts.controllers.scenario.interface": "~0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@vnejs/helpers": "~0.2.0",
|
|
38
|
+
"@vnejs/module.core": "~0.2.0",
|
|
39
|
+
"@vnejs/module.components": "~0.2.0",
|
|
40
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
41
|
+
"@vnejs/contracts.controls": "~0.2.0",
|
|
42
|
+
"@vnejs/contracts.scenario.fastforward": "~0.2.0",
|
|
43
|
+
"@vnejs/registry": "~0.2.0",
|
|
44
|
+
"@vnejs/uis.react": "~0.2.0",
|
|
45
|
+
"@vnejs/uis.utils": "~0.2.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
49
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
50
|
+
"@vnejs/test-utils": "~0.2.0",
|
|
51
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
52
|
+
"@vnejs/contracts.controls": "~0.2.0",
|
|
53
|
+
"@vnejs/contracts.scenario.fastforward": "~0.2.0",
|
|
54
|
+
"@vnejs/helpers": "~0.2.0",
|
|
55
|
+
"@vnejs/module.core": "~0.2.0",
|
|
56
|
+
"@vnejs/module.components": "~0.2.0",
|
|
57
|
+
"@vnejs/registry": "~0.2.0",
|
|
58
|
+
"@vnejs/uis.react": "~0.2.0",
|
|
59
|
+
"@vnejs/uis.utils": "~0.2.0",
|
|
60
|
+
"@vnejs/contracts.controllers.scenario.interface.fastforward": "~0.2.0",
|
|
61
|
+
"@vnejs/contracts.controllers.scenario.interface": "~0.2.0"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
2
|
+
|
|
3
|
+
import { regPlugin } from "@vnejs/registry";
|
|
4
|
+
|
|
5
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
6
|
+
|
|
7
|
+
import { InterfaceFastforwardViewController } from "./modules/controller.js";
|
|
8
|
+
import { InterfaceFastforwardView } from "./modules/view.js";
|
|
9
|
+
|
|
10
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceFastforwardViewController, InterfaceFastforwardView]);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InterfaceFastforwardDisableAnimationPayload,
|
|
5
|
+
InterfaceFastforwardForcePayload,
|
|
6
|
+
} from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
7
|
+
import type { FastforwardChangedPayload } from "@vnejs/contracts.scenario.fastforward";
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
InterfaceFastforwardPluginConstants,
|
|
11
|
+
InterfaceFastforwardPluginEvents,
|
|
12
|
+
InterfaceFastforwardPluginParams,
|
|
13
|
+
InterfaceFastforwardPluginSettings,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import type { InterfaceFastforwardPluginState } from "../types.js";
|
|
16
|
+
|
|
17
|
+
export class InterfaceFastforwardViewController extends ModuleController<
|
|
18
|
+
InterfaceFastforwardPluginEvents,
|
|
19
|
+
InterfaceFastforwardPluginConstants,
|
|
20
|
+
InterfaceFastforwardPluginSettings,
|
|
21
|
+
InterfaceFastforwardPluginParams,
|
|
22
|
+
InterfaceFastforwardPluginState
|
|
23
|
+
> {
|
|
24
|
+
name = "interface.fastforward.view.controller";
|
|
25
|
+
|
|
26
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
27
|
+
EVENT_UPDATE_STATE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_STATE;
|
|
28
|
+
EVENT_UPDATE_FAST = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_FAST;
|
|
29
|
+
EVENT_UPDATE_FORCE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE_FORCE;
|
|
30
|
+
EVENT_SHOW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW;
|
|
31
|
+
EVENT_HIDE = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
|
|
32
|
+
|
|
33
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP = false;
|
|
34
|
+
|
|
35
|
+
CONTROLS = {
|
|
36
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
|
|
37
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
|
|
38
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => void this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
|
|
39
|
+
};
|
|
40
|
+
CONTROLS_UNVISIBLE = {};
|
|
41
|
+
CONTROLS_CHECK_NEXT = true;
|
|
42
|
+
CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX + 200;
|
|
43
|
+
|
|
44
|
+
subscribe = () => {
|
|
45
|
+
super.subscribe();
|
|
46
|
+
|
|
47
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
|
|
48
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.DISABLE_ANIMATION, this.onDisableAnimation);
|
|
49
|
+
|
|
50
|
+
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
51
|
+
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
52
|
+
this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
|
|
53
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
|
|
54
|
+
|
|
55
|
+
this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
|
|
56
|
+
|
|
57
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
start = () => this.getIconSrc();
|
|
61
|
+
|
|
62
|
+
onClick = () => {
|
|
63
|
+
const { isShow = false, isVisible = false } = this.globalState.interface;
|
|
64
|
+
|
|
65
|
+
return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
onDisableAnimation = ({ isDisabled = false }: InterfaceFastforwardDisableAnimationPayload = {}) =>
|
|
69
|
+
this.updateStateAndViewFast({ isAnimationDisabled: isDisabled });
|
|
70
|
+
|
|
71
|
+
onShowChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
|
|
72
|
+
const { isShow = false } = this.globalState.interface;
|
|
73
|
+
const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
|
|
74
|
+
|
|
75
|
+
if (this.state.isShow !== isShow) return this.emit(event, { isForce });
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
onViewChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
|
|
79
|
+
const { view = "" } = this.globalState.interface;
|
|
80
|
+
|
|
81
|
+
if (this.state.view !== view) return this.updateStateAndView({ view }, isForce, !isForce);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
onStateChanged = () => {
|
|
85
|
+
const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
|
|
86
|
+
|
|
87
|
+
this.toggleUnvisibleControls(isVisible);
|
|
88
|
+
|
|
89
|
+
return this.updateStateAndViewForce({ isVisible, isShow, view });
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
onVisibleChanged = ({ isForce = false }: InterfaceFastforwardForcePayload = {}) => {
|
|
93
|
+
const { isVisible = false } = this.globalState.interface;
|
|
94
|
+
|
|
95
|
+
this.toggleUnvisibleControls(isVisible);
|
|
96
|
+
|
|
97
|
+
if (this.state.isVisible !== isVisible) return this.updateStateAndView({ isVisible }, isForce, !isForce);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
onFastForward = ({ value }: FastforwardChangedPayload = {}) => this.updateStateAndViewFast({ isActive: value });
|
|
101
|
+
|
|
102
|
+
onMemoryCleared = async () => this.updateStateAndViewFast({ iconSrc: await this.getIconSrc() });
|
|
103
|
+
|
|
104
|
+
getDefaultState = (): InterfaceFastforwardPluginState => ({ isActive: false, isVisible: false, isShow: false, isAnimationDisabled: false, isForce: false });
|
|
105
|
+
|
|
106
|
+
emitFastforwardEvent = (event: string) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
|
|
107
|
+
|
|
108
|
+
onShowBefore = async () => {
|
|
109
|
+
return this.updateState({ iconSrc: await this.getIconSrc() });
|
|
110
|
+
};
|
|
111
|
+
toggleUnvisibleControls = (isVisible: boolean) => {
|
|
112
|
+
if (isVisible) return this.emit(this.EVENTS.CONTROLS.POP, { key: `${this.name}-unvisible` });
|
|
113
|
+
|
|
114
|
+
return this.emit(this.EVENTS.CONTROLS.PUSH, { key: `${this.name}-unvisible`, controls: this.CONTROLS_UNVISIBLE, index: this.CONTROLS_INDEX + 500 });
|
|
115
|
+
};
|
|
116
|
+
getIconSrc = async () => (await this.loadImageMedia("interface/fastforward", "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
|
|
117
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InterfaceFastforwardPluginConstants,
|
|
5
|
+
InterfaceFastforwardPluginEvents,
|
|
6
|
+
InterfaceFastforwardPluginParams,
|
|
7
|
+
InterfaceFastforwardPluginSettings,
|
|
8
|
+
} from "../types.js";
|
|
9
|
+
import type { InterfaceFastforwardPluginState } from "../types.js";
|
|
10
|
+
|
|
11
|
+
import { render } from "../view/index.js";
|
|
12
|
+
export class InterfaceFastforwardView extends ModuleView<
|
|
13
|
+
InterfaceFastforwardPluginEvents,
|
|
14
|
+
InterfaceFastforwardPluginConstants,
|
|
15
|
+
InterfaceFastforwardPluginSettings,
|
|
16
|
+
InterfaceFastforwardPluginParams,
|
|
17
|
+
InterfaceFastforwardPluginState
|
|
18
|
+
> {
|
|
19
|
+
name = "interface.fastforward.view";
|
|
20
|
+
|
|
21
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
22
|
+
|
|
23
|
+
TRANSITION = this.PARAMS.INTERFACE.TRANSITION;
|
|
24
|
+
|
|
25
|
+
renderFunc = render;
|
|
26
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { InterfaceFastforwardViewController } from "../modules/controller.js";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
createInterfaceFastforwardTestModule,
|
|
9
|
+
FASTFORWARD_EVENTS,
|
|
10
|
+
INTERFACE_EVENTS,
|
|
11
|
+
registerInterfaceFastforwardPluginVne,
|
|
12
|
+
SUBSCRIBE_EVENTS,
|
|
13
|
+
} from "./setup.js";
|
|
14
|
+
|
|
15
|
+
describe("InterfaceFastforwardViewController", () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
registerInterfaceFastforwardPluginVne();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("onShowChanged emits view SHOW when interface opens", async () => {
|
|
21
|
+
const { module, observer } = createInterfaceFastforwardTestModule(InterfaceFastforwardViewController, {
|
|
22
|
+
state: { interface: { view: "line", isShow: true, isVisible: true } },
|
|
23
|
+
});
|
|
24
|
+
const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
|
|
25
|
+
|
|
26
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
27
|
+
|
|
28
|
+
expect(show).toHaveBeenCalledOnce();
|
|
29
|
+
expect((module as InterfaceFastforwardViewController).state.isShow).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("HIDE keeps isVisible and view for the next SHOW", async () => {
|
|
33
|
+
const { module, observer } = createInterfaceFastforwardTestModule(InterfaceFastforwardViewController, {
|
|
34
|
+
state: { interface: { view: "adv", isShow: false, isVisible: true } },
|
|
35
|
+
});
|
|
36
|
+
const controller = module as InterfaceFastforwardViewController;
|
|
37
|
+
|
|
38
|
+
controller.updateState({ isShow: true, isVisible: true, view: "adv", isActive: false, isAnimationDisabled: false });
|
|
39
|
+
|
|
40
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
41
|
+
|
|
42
|
+
expect(controller.state.isShow).toBe(false);
|
|
43
|
+
expect(controller.state.isVisible).toBe(true);
|
|
44
|
+
expect(controller.state.view).toBe("adv");
|
|
45
|
+
|
|
46
|
+
module.globalState.interface.isShow = true;
|
|
47
|
+
|
|
48
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
49
|
+
|
|
50
|
+
expect(controller.state.isShow).toBe(true);
|
|
51
|
+
expect(controller.state.isVisible).toBe(true);
|
|
52
|
+
expect(controller.state.view).toBe("adv");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("onFastForward updates isActive in controller state", async () => {
|
|
56
|
+
const { module, observer } = createInterfaceFastforwardTestModule(InterfaceFastforwardViewController);
|
|
57
|
+
|
|
58
|
+
await observer.emit(FASTFORWARD_EVENTS.CHANGED, { value: true });
|
|
59
|
+
|
|
60
|
+
expect((module as InterfaceFastforwardViewController).state.isActive).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("emitFastforwardEvent routes to INTERFACE.VISIBLE when interface is hidden", () => {
|
|
64
|
+
const { module, observer } = createInterfaceFastforwardTestModule(InterfaceFastforwardViewController, {
|
|
65
|
+
state: { interface: { view: "line", isShow: true, isVisible: false } },
|
|
66
|
+
});
|
|
67
|
+
const visible = spyEvent(observer, INTERFACE_EVENTS.VISIBLE);
|
|
68
|
+
|
|
69
|
+
(module as InterfaceFastforwardViewController).emitFastforwardEvent(FASTFORWARD_EVENTS.TOGGLE);
|
|
70
|
+
|
|
71
|
+
expect(visible).toHaveBeenCalledOnce();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SourcesSet } from "@vnejs/sources-set";
|
|
2
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent } from "@vnejs/test-utils";
|
|
3
|
+
|
|
4
|
+
import { CONSTANTS as LAYER_CONST, PLUGIN_NAME as LAYER, SETTINGS_KEYS as LAYER_SETTINGS } from "@vnejs/contracts.canvas.layer";
|
|
5
|
+
import { PARAMS as INTERFACE_PARAMS, PLUGIN_NAME as INTERFACE, SUBSCRIBE_EVENTS as INTERFACE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface";
|
|
6
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
7
|
+
import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
|
|
8
|
+
import { SUBSCRIBE_EVENTS as MEDIA_EVENTS } from "@vnejs/contracts.core.media";
|
|
9
|
+
import { PLUGIN_NAME as FASTFORWARD, SUBSCRIBE_EVENTS as FASTFORWARD_EVENTS } from "@vnejs/contracts.scenario.fastforward";
|
|
10
|
+
|
|
11
|
+
export const registerInterfaceFastforwardPluginVne = () => {
|
|
12
|
+
registerCoreVne();
|
|
13
|
+
registerVnePlugin(CONTROLS, { constants: CONTROLS_CONST, events: CONTROLS_EVENTS });
|
|
14
|
+
registerVnePlugin(LAYER, { constants: LAYER_CONST, settings: LAYER_SETTINGS });
|
|
15
|
+
registerVnePlugin(FASTFORWARD, { events: FASTFORWARD_EVENTS });
|
|
16
|
+
registerVnePlugin(INTERFACE, { events: INTERFACE_EVENTS, params: INTERFACE_PARAMS });
|
|
17
|
+
registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS });
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const createInterfaceFastforwardTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
21
|
+
ModuleClass: T,
|
|
22
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
23
|
+
) => {
|
|
24
|
+
const result = baseCreateTestModule(ModuleClass, {
|
|
25
|
+
state: {
|
|
26
|
+
interface: { view: INTERFACE_PARAMS.DEFAULT_VIEW, isShow: true, isVisible: true },
|
|
27
|
+
...(options.state ?? {}),
|
|
28
|
+
},
|
|
29
|
+
shared: {
|
|
30
|
+
settings: { [LAYER_SETTINGS.QUALITY]: LAYER_CONST.QUALITIES.FHD },
|
|
31
|
+
viewForceAnimationSources: new SourcesSet(),
|
|
32
|
+
...(options.shared ?? {}),
|
|
33
|
+
},
|
|
34
|
+
...options,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
stubEvent(result.observer, MEDIA_EVENTS.LOAD, () => ({ src: "fastforward.png" }));
|
|
38
|
+
stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
|
|
39
|
+
stubSilentEvent(result.observer, INTERFACE_EVENTS.VISIBLE);
|
|
40
|
+
stubSilentEvent(result.observer, CONTROLS_EVENTS.PUSH);
|
|
41
|
+
stubSilentEvent(result.observer, CONTROLS_EVENTS.POP);
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, INTERFACE_EVENTS, FASTFORWARD_EVENTS };
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/contracts.canvas.layer";
|
|
4
|
+
import type {
|
|
5
|
+
Params as InterfaceParams,
|
|
6
|
+
PluginName as InterfacePluginName,
|
|
7
|
+
SubscribeEvents as InterfaceSubscribeEvents,
|
|
8
|
+
} from "@vnejs/contracts.controllers.scenario.interface";
|
|
9
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface.fastforward";
|
|
10
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/contracts.controls";
|
|
11
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
|
|
12
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
|
|
13
|
+
import type { PluginName as FastforwardPluginName, SubscribeEvents as FastforwardSubscribeEvents } from "@vnejs/contracts.scenario.fastforward";
|
|
14
|
+
|
|
15
|
+
export type InterfaceFastforwardPluginEvents = ModuleComponentsEvents &
|
|
16
|
+
Record<PluginName, SubscribeEvents> &
|
|
17
|
+
Record<InterfacePluginName, InterfaceSubscribeEvents> &
|
|
18
|
+
Record<FastforwardPluginName, FastforwardSubscribeEvents> &
|
|
19
|
+
Record<ControlsPluginName, ControlsSubscribeEvents> &
|
|
20
|
+
Record<SystemPluginName, SystemSubscribeEvents> &
|
|
21
|
+
Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
22
|
+
|
|
23
|
+
export type InterfaceFastforwardPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
24
|
+
|
|
25
|
+
export type InterfaceFastforwardPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
26
|
+
|
|
27
|
+
export type InterfaceFastforwardPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<InterfacePluginName, InterfaceParams>;
|
|
28
|
+
|
|
29
|
+
export type InterfaceFastforwardPluginState = {
|
|
30
|
+
isActive: boolean;
|
|
31
|
+
isVisible: boolean;
|
|
32
|
+
isShow: boolean;
|
|
33
|
+
isAnimationDisabled: boolean;
|
|
34
|
+
isForce: boolean;
|
|
35
|
+
view?: string;
|
|
36
|
+
iconSrc?: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cn, injectStyles, sel } from "@vnejs/uis.utils";
|
|
2
|
+
|
|
3
|
+
export const b = cn("InterfaceFastForward");
|
|
4
|
+
|
|
5
|
+
const CSS = `
|
|
6
|
+
@keyframes fastforward {
|
|
7
|
+
from {
|
|
8
|
+
transform: scale(1.1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
50% {
|
|
12
|
+
transform: scale(0.9);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
to {
|
|
16
|
+
transform: scale(1.1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
${sel(b({ isAnimated: true }))} {
|
|
21
|
+
animation-duration: 500ms;
|
|
22
|
+
animation-name: fastforward;
|
|
23
|
+
animation-iteration-count: infinite;
|
|
24
|
+
animation-timing-function: ease-in-out;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
injectStyles(CSS);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { Icon, View, createRenderFunc, useIsForceHook, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
InterfaceFastforwardPluginConstants,
|
|
9
|
+
InterfaceFastforwardPluginEvents,
|
|
10
|
+
InterfaceFastforwardPluginParams,
|
|
11
|
+
InterfaceFastforwardPluginSettings,
|
|
12
|
+
} from "../types.js";
|
|
13
|
+
import type { InterfaceFastforwardPluginState } from "../types.js";
|
|
14
|
+
|
|
15
|
+
import { b } from "./index.styles.js";
|
|
16
|
+
|
|
17
|
+
type InterfaceFastforwardComponentProps = ReactComponentProps<
|
|
18
|
+
InterfaceFastforwardPluginEvents,
|
|
19
|
+
InterfaceFastforwardPluginConstants,
|
|
20
|
+
InterfaceFastforwardPluginSettings,
|
|
21
|
+
InterfaceFastforwardPluginParams,
|
|
22
|
+
InterfaceFastforwardPluginState
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
const InterfaceFastForward = ({ store, onMount, emit, EVENTS, PARAMS }: InterfaceFastforwardComponentProps) => {
|
|
26
|
+
const {
|
|
27
|
+
isShow = false,
|
|
28
|
+
isVisible = false,
|
|
29
|
+
isForce = false,
|
|
30
|
+
isActive = false,
|
|
31
|
+
isAnimationDisabled = false,
|
|
32
|
+
view = "",
|
|
33
|
+
iconSrc = "",
|
|
34
|
+
} = useStoreState<InterfaceFastforwardPluginState>(store, onMount);
|
|
35
|
+
|
|
36
|
+
const isRealForce = useIsForceHook(isForce);
|
|
37
|
+
|
|
38
|
+
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
39
|
+
|
|
40
|
+
const propsByView = PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view as keyof typeof PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS];
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View
|
|
44
|
+
{...propsByView?.view}
|
|
45
|
+
isShow={isShow}
|
|
46
|
+
isForce={isRealForce}
|
|
47
|
+
transition={transition}
|
|
48
|
+
onClick={() => emit(EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK)}
|
|
49
|
+
className={b({ isAnimated: isActive && !isAnimationDisabled })}
|
|
50
|
+
isHidden={!isVisible}
|
|
51
|
+
zIndex={PARAMS.INTERFACE.ZINDEX + 200}
|
|
52
|
+
>
|
|
53
|
+
<Icon
|
|
54
|
+
{...propsByView?.icon}
|
|
55
|
+
src={iconSrc}
|
|
56
|
+
transition={transition}
|
|
57
|
+
/>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const render: ViewRenderFunc<InterfaceFastforwardPluginState> = createRenderFunc(InterfaceFastForward);
|
package/tsconfig.json
ADDED
package/README.md
DELETED