@vnejs/plugins.view.coralina.interface.fastforward 0.0.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/const/events.js +6 -0
- package/index.js +11 -0
- package/modules/controller.js +64 -0
- package/modules/view.js +11 -0
- package/package.json +18 -0
- package/view/index.jsx +31 -0
- package/view/index.styl +55 -0
- package/view/media/fastforward.png +0 -0
package/const/events.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
|
|
3
|
+
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
4
|
+
|
|
5
|
+
import { InterfaceFastForwardController } from "./modules/controller";
|
|
6
|
+
import { InterfaceFastForwardView } from "./modules/view";
|
|
7
|
+
|
|
8
|
+
regPlugin("INTERFACE_FASTFORWARD", { events: SUBSCRIBE_EVENTS }, [
|
|
9
|
+
InterfaceFastForwardController,
|
|
10
|
+
InterfaceFastForwardView,
|
|
11
|
+
]);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
export class InterfaceFastForwardController extends Module.Controller {
|
|
4
|
+
name = "interface.fastforward.controller";
|
|
5
|
+
|
|
6
|
+
updateEvent = this.EVENTS.INTERFACE_FASTFORWARD.UPDATE;
|
|
7
|
+
|
|
8
|
+
controls = {
|
|
9
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_TOGGLE]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE),
|
|
10
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_START]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.START),
|
|
11
|
+
[this.CONST.CONTROLS.BUTTONS.FASTFORWARD_FINISH]: () => this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.STOP),
|
|
12
|
+
};
|
|
13
|
+
controlsUnvisible = {};
|
|
14
|
+
controlsCheckNext = true;
|
|
15
|
+
controlsIndex = 1100;
|
|
16
|
+
|
|
17
|
+
subscribe = () => {
|
|
18
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD.SHOW, this.onShow);
|
|
19
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD.HIDE, this.onHide);
|
|
20
|
+
this.on(this.EVENTS.INTERFACE_FASTFORWARD.CLICK, this.onClick);
|
|
21
|
+
|
|
22
|
+
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
23
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisible);
|
|
24
|
+
|
|
25
|
+
this.on(this.EVENTS.CHOOSE.SHOW, this.onChooseShow);
|
|
26
|
+
this.on(this.EVENTS.CHOOSE.HIDE, this.onChooseHide);
|
|
27
|
+
|
|
28
|
+
this.on(this.EVENTS.FASTFORWARD.CHANGED, this.onFastForward);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
onClick = () => {
|
|
32
|
+
const { isShow = false, isVisible = false } = this.globalState.interface;
|
|
33
|
+
|
|
34
|
+
if (isShow && isVisible) return this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
onShowChanged = ({ force = false } = {}) => {
|
|
38
|
+
const { isShow = false, view = "" } = this.globalState.interface;
|
|
39
|
+
const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD.SHOW : this.EVENTS.INTERFACE_FASTFORWARD.HIDE;
|
|
40
|
+
|
|
41
|
+
this.updateStateAndView({ view }, force, !force);
|
|
42
|
+
if (this.state.isShow !== isShow) return this.emit(event, { force });
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
onVisible = async ({ force = false } = {}) => {
|
|
46
|
+
const { isVisible = false } = this.globalState.interface;
|
|
47
|
+
|
|
48
|
+
if (this.state.isVisible === isVisible) return;
|
|
49
|
+
|
|
50
|
+
const args = { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 };
|
|
51
|
+
await this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
|
|
52
|
+
await this.updateStateAndView({ isVisible }, force, !force);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
onFastForward = ({ value } = {}) => this.isReady && this.updateStateAndView({ isActive: value }, false, true);
|
|
56
|
+
|
|
57
|
+
onChooseShow = () => this.updateStateAndView({ isChooseShow: true }, false, true);
|
|
58
|
+
onChooseHide = () => this.updateStateAndView({ isChooseShow: false }, false, true);
|
|
59
|
+
|
|
60
|
+
emitFastforwardEvent = (event) =>
|
|
61
|
+
this.globalState.interface.isVisible ? this.emit(event) : this.emit(this.EVENTS.INTERFACE.VISIBLE);
|
|
62
|
+
|
|
63
|
+
getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isChooseShow: false });
|
|
64
|
+
}
|
package/modules/view.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view";
|
|
4
|
+
|
|
5
|
+
export class InterfaceFastForwardView extends Module.View {
|
|
6
|
+
name = "interface.fastforward.view";
|
|
7
|
+
animationTime = 500;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
updateEvent = this.EVENTS.INTERFACE_FASTFORWARD.UPDATE;
|
|
10
|
+
updateHandler = this.onUpdateReactComponent;
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/plugins.view.coralina.interface.fastforward",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"publish:major": "npm version major && npm publish --access public",
|
|
8
|
+
"publish:minor": "npm version minor && npm publish --access public",
|
|
9
|
+
"publish:patch": "npm version patch && npm publish --access public"
|
|
10
|
+
},
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"description": "",
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@vnejs/shared": "*",
|
|
16
|
+
"@vnejs/module": "*"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/view/index.jsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@bem-react/classname";
|
|
5
|
+
|
|
6
|
+
import "./index.styl";
|
|
7
|
+
|
|
8
|
+
const b = cn("InterfaceFastForward");
|
|
9
|
+
|
|
10
|
+
class InterfaceFastForward extends React.Component {
|
|
11
|
+
state = {};
|
|
12
|
+
onClick = (e) => {
|
|
13
|
+
e.stopPropagation();
|
|
14
|
+
this.props.emit(this.props.EVENTS.INTERFACE_FASTFORWARD.CLICK);
|
|
15
|
+
};
|
|
16
|
+
render() {
|
|
17
|
+
const {
|
|
18
|
+
isShow = false,
|
|
19
|
+
isVisible = false,
|
|
20
|
+
isForce = false,
|
|
21
|
+
isActive = false,
|
|
22
|
+
isChooseShow = false,
|
|
23
|
+
view = "",
|
|
24
|
+
} = this.state;
|
|
25
|
+
const isAnimated = isActive && !isChooseShow;
|
|
26
|
+
|
|
27
|
+
return <div className={b({ isShow, isForce, isVisible, isAnimated, view })} onClick={this.onClick} />;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const render = (props, root, resolve) => ReactDOM.render(<InterfaceFastForward {...props} />, root, resolve);
|
package/view/index.styl
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@keyframes fastforward
|
|
2
|
+
from
|
|
3
|
+
transform: translateY(50%) scale(1.1)
|
|
4
|
+
|
|
5
|
+
50%
|
|
6
|
+
transform: translateY(50%) scale(0.9)
|
|
7
|
+
|
|
8
|
+
to
|
|
9
|
+
transform: translateY(50%) scale(1.1)
|
|
10
|
+
|
|
11
|
+
.InterfaceFastForward
|
|
12
|
+
position: absolute
|
|
13
|
+
transform: translateY(50%) scale(1)
|
|
14
|
+
aspect-ratio: 1/1
|
|
15
|
+
background-position: center
|
|
16
|
+
background-repeat: no-repeat
|
|
17
|
+
background-size: contain
|
|
18
|
+
background-image: url("./media/fastforward.png")
|
|
19
|
+
cursor: pointer
|
|
20
|
+
opacity: 0
|
|
21
|
+
pointer-events: none
|
|
22
|
+
z-index: 1200
|
|
23
|
+
|
|
24
|
+
&:not(&_isForce)
|
|
25
|
+
transition: opacity 500ms, right 500ms, width 500ms, bottom 500ms, transform 500ms
|
|
26
|
+
|
|
27
|
+
&_isAnimated
|
|
28
|
+
animation-duration: 500ms
|
|
29
|
+
animation-name: fastforward
|
|
30
|
+
animation-iteration-count: infinite
|
|
31
|
+
animation-timing-function: ease-in-out
|
|
32
|
+
|
|
33
|
+
&:hover
|
|
34
|
+
opacity 1
|
|
35
|
+
transform: translateY(50%) scale(0.95)
|
|
36
|
+
|
|
37
|
+
&:not(&_isVisible)
|
|
38
|
+
opacity: 0
|
|
39
|
+
|
|
40
|
+
&_isShow
|
|
41
|
+
pointer-events: all
|
|
42
|
+
opacity: 0.7
|
|
43
|
+
|
|
44
|
+
&_view
|
|
45
|
+
&_line
|
|
46
|
+
right: 15%
|
|
47
|
+
width: calc(100 / 3840 * 100%)
|
|
48
|
+
bottom: 3.25%
|
|
49
|
+
&_adv
|
|
50
|
+
right: 2.5%
|
|
51
|
+
width: calc(375 / 3840 * 100%)
|
|
52
|
+
bottom: calc(300 / 2160 * 100%)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
Binary file
|