@vnejs/plugins.view.coralina.interface.fastforward 0.0.1 → 0.1.0

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/index.js CHANGED
@@ -5,7 +5,4 @@ import { SUBSCRIBE_EVENTS } from "./const/events";
5
5
  import { InterfaceFastForwardController } from "./modules/controller";
6
6
  import { InterfaceFastForwardView } from "./modules/view";
7
7
 
8
- regPlugin("INTERFACE_FASTFORWARD", { events: SUBSCRIBE_EVENTS }, [
9
- InterfaceFastForwardController,
10
- InterfaceFastForwardView,
11
- ]);
8
+ regPlugin("INTERFACE_FASTFORWARD", { events: SUBSCRIBE_EVENTS }, [InterfaceFastForwardController, InterfaceFastForwardView]);
@@ -1,6 +1,8 @@
1
- import { Module } from "@vnejs/module";
1
+ import { ModuleController } from "@vnejs/module.components";
2
2
 
3
- export class InterfaceFastForwardController extends Module.Controller {
3
+ import { ZINDEX } from "../view";
4
+
5
+ export class InterfaceFastForwardController extends ModuleController {
4
6
  name = "interface.fastforward.controller";
5
7
 
6
8
  updateEvent = this.EVENTS.INTERFACE_FASTFORWARD.UPDATE;
@@ -12,7 +14,7 @@ export class InterfaceFastForwardController extends Module.Controller {
12
14
  };
13
15
  controlsUnvisible = {};
14
16
  controlsCheckNext = true;
15
- controlsIndex = 1100;
17
+ controlsIndex = ZINDEX;
16
18
 
17
19
  subscribe = () => {
18
20
  this.on(this.EVENTS.INTERFACE_FASTFORWARD.SHOW, this.onShow);
@@ -20,7 +22,9 @@ export class InterfaceFastForwardController extends Module.Controller {
20
22
  this.on(this.EVENTS.INTERFACE_FASTFORWARD.CLICK, this.onClick);
21
23
 
22
24
  this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
23
- this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisible);
25
+ this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
26
+ this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
27
+ this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
24
28
 
25
29
  this.on(this.EVENTS.CHOOSE.SHOW, this.onChooseShow);
26
30
  this.on(this.EVENTS.CHOOSE.HIDE, this.onChooseHide);
@@ -34,31 +38,47 @@ export class InterfaceFastForwardController extends Module.Controller {
34
38
  if (isShow && isVisible) return this.emitFastforwardEvent(this.EVENTS.FASTFORWARD.TOGGLE);
35
39
  };
36
40
 
37
- onShowChanged = ({ force = false } = {}) => {
38
- const { isShow = false, view = "" } = this.globalState.interface;
41
+ onShowChanged = ({ isForce = false } = {}) => {
42
+ const { isShow = false } = this.globalState.interface;
39
43
  const event = isShow ? this.EVENTS.INTERFACE_FASTFORWARD.SHOW : this.EVENTS.INTERFACE_FASTFORWARD.HIDE;
40
44
 
41
- this.updateStateAndView({ view }, force, !force);
42
- if (this.state.isShow !== isShow) return this.emit(event, { force });
45
+ if (this.state.isShow !== isShow) return this.emit(event, { isForce });
46
+ };
47
+
48
+ onViewChanged = ({ isForce = false } = {}) => {
49
+ const { view = "" } = this.globalState.interface;
50
+
51
+ if (this.state.view !== view) return this.updateStateAndView({ view }, isForce, !isForce);
43
52
  };
44
53
 
45
- onVisible = async ({ force = false } = {}) => {
54
+ onVisibleChanged = ({ isForce = false } = {}) => {
46
55
  const { isVisible = false } = this.globalState.interface;
47
56
 
48
- if (this.state.isVisible === isVisible) return;
57
+ this.toggleUnvisibleControls(isVisible);
49
58
 
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);
59
+ if (this.state.isVisible !== isVisible) return this.updateStateAndView({ isVisible }, isForce, !isForce);
53
60
  };
54
61
 
55
- onFastForward = ({ value } = {}) => this.isReady && this.updateStateAndView({ isActive: value }, false, true);
62
+ onStateChanged = () => {
63
+ const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
64
+
65
+ this.toggleUnvisibleControls(isVisible);
56
66
 
57
- onChooseShow = () => this.updateStateAndView({ isChooseShow: true }, false, true);
58
- onChooseHide = () => this.updateStateAndView({ isChooseShow: false }, false, true);
67
+ return this.updateStateAndViewForce({ isVisible, isShow, view });
68
+ };
69
+
70
+ onFastForward = ({ value } = {}) => this.isReady && this.updateStateAndViewFast({ isActive: value });
71
+
72
+ onChooseShow = () => this.updateStateAndViewFast({ isChooseShow: true });
73
+ onChooseHide = () => this.updateStateAndViewFast({ isChooseShow: false });
74
+
75
+ toggleUnvisibleControls = (isVisible) => {
76
+ const args = { key: `${this.name}-unvisible`, controls: this.controlsUnvisible, index: this.controlsIndex + 500 };
77
+
78
+ return this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
79
+ };
59
80
 
60
- emitFastforwardEvent = (event) =>
61
- this.globalState.interface.isVisible ? this.emit(event) : this.emit(this.EVENTS.INTERFACE.VISIBLE);
81
+ emitFastforwardEvent = (event) => this.emit(this.globalState.interface.isVisible ? event : this.EVENTS.INTERFACE.VISIBLE);
62
82
 
63
83
  getDefaultState = () => ({ isActive: false, isVisible: false, isShow: false, isChooseShow: false });
64
84
  }
package/modules/view.js CHANGED
@@ -1,10 +1,10 @@
1
- import { Module } from "@vnejs/module";
1
+ import { ModuleView } from "@vnejs/module.components";
2
2
 
3
- import { render } from "../view";
3
+ import { render, TRANSITION } from "../view";
4
4
 
5
- export class InterfaceFastForwardView extends Module.View {
5
+ export class InterfaceFastForwardView extends ModuleView {
6
6
  name = "interface.fastforward.view";
7
- animationTime = 500;
7
+ animationTime = TRANSITION;
8
8
  renderFunc = render;
9
9
  updateEvent = this.EVENTS.INTERFACE_FASTFORWARD.UPDATE;
10
10
  updateHandler = this.onUpdateReactComponent;
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.view.coralina.interface.fastforward",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
7
+ "publish:major:plugin": "npm run publish:major",
8
+ "publish:minor:plugin": "npm run publish:minor",
9
+ "publish:patch:plugin": "npm run publish:patch",
7
10
  "publish:major": "npm version major && npm publish --access public",
8
11
  "publish:minor": "npm version minor && npm publish --access public",
9
12
  "publish:patch": "npm version patch && npm publish --access public"
10
13
  },
11
14
  "author": "",
12
15
  "license": "ISC",
13
- "description": "",
14
- "peerDependencies": {
15
- "@vnejs/shared": "*",
16
- "@vnejs/module": "*"
17
- }
16
+ "description": ""
18
17
  }
package/view/index.jsx CHANGED
@@ -3,28 +3,50 @@ import ReactDOM from "react-dom";
3
3
 
4
4
  import { cn } from "@bem-react/classname";
5
5
 
6
+ import { Icon, View } from "@vnejs/uis.base";
7
+
6
8
  import "./index.styl";
7
9
 
10
+ import iconSrc from "./media/fastforward.png";
11
+
8
12
  const b = cn("InterfaceFastForward");
9
13
 
14
+ export const TRANSITION = 500;
15
+ export const ZINDEX = 1100;
16
+
10
17
  class InterfaceFastForward extends React.Component {
11
18
  state = {};
12
- onClick = (e) => {
13
- e.stopPropagation();
14
- this.props.emit(this.props.EVENTS.INTERFACE_FASTFORWARD.CLICK);
15
- };
19
+ onClick = () => this.props.emit(this.props.EVENTS.INTERFACE_FASTFORWARD.CLICK);
16
20
  render() {
17
- const {
18
- isShow = false,
19
- isVisible = false,
20
- isForce = false,
21
- isActive = false,
22
- isChooseShow = false,
23
- view = "",
24
- } = this.state;
21
+ const { isShow = false, isVisible = false, isForce = false, isActive = false, isChooseShow = false, view = "" } = this.state;
25
22
  const isAnimated = isActive && !isChooseShow;
26
23
 
27
- return <div className={b({ isShow, isForce, isVisible, isAnimated, view })} onClick={this.onClick} />;
24
+ const size = view === "adv" ? 396 : 96;
25
+
26
+ const bottom = view === "adv" ? 96 : 24;
27
+ const right = view === "adv" ? 96 : 360;
28
+
29
+ return (
30
+ <View
31
+ className={b({ isAnimated })}
32
+ isShow={isShow}
33
+ isForce={isForce}
34
+ isHidden={!isVisible}
35
+ bottom={bottom}
36
+ right={right}
37
+ zIndex={ZINDEX}
38
+ transition={TRANSITION}
39
+ onClick={this.onClick}
40
+ >
41
+ <Icon
42
+ width={size}
43
+ height={size}
44
+ isOpacityOnHover={true}
45
+ src={iconSrc}
46
+ transition={isForce ? 0 : TRANSITION}
47
+ />
48
+ </View>
49
+ );
28
50
  }
29
51
  }
30
52
 
package/view/index.styl CHANGED
@@ -1,55 +1,19 @@
1
1
  @keyframes fastforward
2
2
  from
3
- transform: translateY(50%) scale(1.1)
3
+ transform: scale(1.1)
4
4
 
5
5
  50%
6
- transform: translateY(50%) scale(0.9)
6
+ transform: scale(0.9)
7
7
 
8
8
  to
9
- transform: translateY(50%) scale(1.1)
9
+ transform: scale(1.1)
10
10
 
11
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
12
  &_isAnimated
28
13
  animation-duration: 500ms
29
14
  animation-name: fastforward
30
15
  animation-iteration-count: infinite
31
16
  animation-timing-function: ease-in-out
32
17
 
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
18
 
55
19