@vnejs/plugins.view.coralina.interface.fastforward 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/const/params.js +15 -0
- package/index.js +2 -1
- package/modules/controller.js +14 -9
- package/modules/view.js +6 -4
- package/package.json +1 -1
- package/view/index.jsx +31 -43
- package/view/media/fastforward.png +0 -0
package/const/params.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const createView = (x, y, tX, tY) => ({
|
|
2
|
+
bottom: 0,
|
|
3
|
+
right: 0,
|
|
4
|
+
translateX: `calc(-1px * var(--vne-length-${x}))`,
|
|
5
|
+
translateY: `calc(-1px * var(--vne-length-${y}))`,
|
|
6
|
+
transformOriginX: tX,
|
|
7
|
+
transformOriginY: tY,
|
|
8
|
+
});
|
|
9
|
+
const createIcon = (scale) => ({ width: 384, height: 384, isOpacityOnHover: true, scale, transformOriginX: "100%", transformOriginY: "100%" });
|
|
10
|
+
|
|
11
|
+
export const VIEW_PROPS = {
|
|
12
|
+
adv: { view: createView(96, 96, "50%", "50%"), icon: createIcon(1) },
|
|
13
|
+
line: { view: createView(360, 24, "87.5%", "87.5%"), icon: createIcon(0.25) },
|
|
14
|
+
wall: { view: createView(24, 360, "87.5%", "87.5%"), icon: createIcon(0.25) },
|
|
15
|
+
};
|
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { regPlugin } from "@vnejs/shared";
|
|
2
2
|
|
|
3
3
|
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
4
|
+
import * as params from "./const/params";
|
|
4
5
|
|
|
5
6
|
import { InterfaceFastForwardController } from "./modules/controller";
|
|
6
7
|
import { InterfaceFastForwardView } from "./modules/view";
|
|
7
8
|
|
|
8
|
-
regPlugin("
|
|
9
|
+
regPlugin("INTERFACE_FASTFORWARD_VIEW", { events: SUBSCRIBE_EVENTS, params }, [InterfaceFastForwardController, InterfaceFastForwardView]);
|
package/modules/controller.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
import { ZINDEX } from "../view";
|
|
4
|
-
|
|
5
3
|
export class InterfaceFastForwardController extends ModuleController {
|
|
6
4
|
name = "interface.fastforward.controller";
|
|
7
5
|
|
|
8
|
-
updateEvent = this.EVENTS.
|
|
6
|
+
updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
9
7
|
|
|
10
8
|
controls = {
|
|
11
9
|
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
|
|
@@ -14,12 +12,12 @@ export class InterfaceFastForwardController extends ModuleController {
|
|
|
14
12
|
};
|
|
15
13
|
controlsUnvisible = {};
|
|
16
14
|
controlsCheckNext = true;
|
|
17
|
-
controlsIndex = ZINDEX;
|
|
15
|
+
controlsIndex = this.PARAMS.INTERFACE_VIEW.ZINDEX + 200;
|
|
18
16
|
|
|
19
17
|
subscribe = () => {
|
|
20
|
-
this.on(this.EVENTS.
|
|
21
|
-
this.on(this.EVENTS.
|
|
22
|
-
this.on(this.EVENTS.
|
|
18
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW, this.onShow);
|
|
19
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE, this.onHide);
|
|
20
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK, this.onClick);
|
|
23
21
|
|
|
24
22
|
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
25
23
|
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
@@ -30,17 +28,22 @@ export class InterfaceFastForwardController extends ModuleController {
|
|
|
30
28
|
this.on(this.EVENTS.CHOOSE.HIDE, this.onChooseHide);
|
|
31
29
|
|
|
32
30
|
this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
|
|
31
|
+
|
|
32
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.getIconSrc);
|
|
33
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.getIconSrc);
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
beforeShow = async () => this.updateState({ iconSrc: await this.getIconSrc() });
|
|
37
|
+
|
|
35
38
|
onClick = () => {
|
|
36
39
|
const { isShow = false, isVisible = false } = this.globalState.interface;
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
return isShow && isVisible && this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
onShowChanged = ({ isForce = false } = {}) => {
|
|
42
45
|
const { isShow = false } = this.globalState.interface;
|
|
43
|
-
const event = isShow ? this.EVENTS.
|
|
46
|
+
const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD_VIEW.SHOW : this.EVENTS.INTERFACE_FASTFORWARD_VIEW.HIDE;
|
|
44
47
|
|
|
45
48
|
if (this.state.isShow !== isShow) return this.emit(event, { isForce });
|
|
46
49
|
};
|
|
@@ -80,5 +83,7 @@ export class InterfaceFastForwardController extends ModuleController {
|
|
|
80
83
|
|
|
81
84
|
emitFastforwardEvent = (event) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
|
|
82
85
|
|
|
86
|
+
getIconSrc = async () => (await this.loadImageMedia(`interface/fastforward`, "icons", this.shared.settings[this.SETTINGS.CANVAS.QUALITY], false, false)).src;
|
|
87
|
+
|
|
83
88
|
getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isChooseShow: false });
|
|
84
89
|
}
|
package/modules/view.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ModuleView } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
import { render
|
|
3
|
+
import { render } from "../view";
|
|
4
4
|
|
|
5
5
|
export class InterfaceFastForwardView extends ModuleView {
|
|
6
6
|
name = "interface.fastforward.view";
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
animationTime = this.PARAMS.INTERFACE_VIEW.TRANSITION;
|
|
9
|
+
updateEvent = this.EVENTS.INTERFACE_FASTFORWARD_VIEW.UPDATE;
|
|
10
|
+
|
|
8
11
|
renderFunc = render;
|
|
9
|
-
|
|
10
|
-
updateHandler = this.onUpdateReactComponent;
|
|
12
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
11
13
|
}
|
package/package.json
CHANGED
package/view/index.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
|
|
4
4
|
import { cn } from "@bem-react/classname";
|
|
@@ -7,47 +7,35 @@ import { Icon, View } from "@vnejs/uis.base";
|
|
|
7
7
|
|
|
8
8
|
import "./index.styl";
|
|
9
9
|
|
|
10
|
-
import iconSrc from "./media/fastforward.png";
|
|
11
|
-
|
|
12
10
|
const b = cn("InterfaceFastForward");
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
isOpacityOnHover={true}
|
|
45
|
-
src={iconSrc}
|
|
46
|
-
transition={isForce ? 0 : TRANSITION}
|
|
47
|
-
/>
|
|
48
|
-
</View>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const render = (props, root, resolve) => ReactDOM.render(<InterfaceFastForward {...props} />, root, resolve);
|
|
12
|
+
const InterfaceFastForward = ({ store, onMount, ...props } = {}) => {
|
|
13
|
+
const [{ isShow = false, isVisible = false, isForce = false, isActive = false, isChooseShow = false, view = "", iconSrc = "" }, setState] = useState({});
|
|
14
|
+
|
|
15
|
+
useEffect(() => store.subscribe(setState), []);
|
|
16
|
+
useEffect(() => void onMount(), []);
|
|
17
|
+
|
|
18
|
+
const onClick = useCallback(() => props.emit(props.EVENTS.INTERFACE_FASTFORWARD_VIEW.CLICK));
|
|
19
|
+
|
|
20
|
+
const transition = isForce ? 0 : props.PARAMS.INTERFACE_VIEW.TRANSITION;
|
|
21
|
+
|
|
22
|
+
const propsIconByView = useMemo(() => props.PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view]?.icon, [view]);
|
|
23
|
+
const propsIcon = useMemo(() => ({ ...propsIconByView, src: iconSrc, transition }), [propsIconByView, iconSrc, transition]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
{...props.PARAMS.INTERFACE_FASTFORWARD_VIEW.VIEW_PROPS[view]?.view}
|
|
28
|
+
className={b({ isAnimated: isActive && !isChooseShow })}
|
|
29
|
+
isShow={isShow}
|
|
30
|
+
isForce={isForce}
|
|
31
|
+
isHidden={!isVisible}
|
|
32
|
+
zIndex={props.PARAMS.INTERFACE_VIEW.ZINDEX + 200}
|
|
33
|
+
transition={transition}
|
|
34
|
+
onClick={onClick}
|
|
35
|
+
>
|
|
36
|
+
<Icon {...propsIcon} />
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const render = (props, root) => ReactDOM.render(<InterfaceFastForward {...props} />, root);
|
|
Binary file
|