@vnejs/plugins.view.coralina.point-and-click 0.0.1 → 0.1.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/modules/controller.js +5 -4
- package/modules/view.js +7 -5
- package/package.json +5 -6
- package/view/index.jsx +32 -22
- package/view/index.styl +6 -41
package/modules/controller.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { ZINDEX } from "../view";
|
|
4
|
+
|
|
5
|
+
export class PointAndClickController extends ModuleController {
|
|
4
6
|
name = "point-and-click.controller";
|
|
5
7
|
|
|
6
8
|
maxCurrentItem = 0;
|
|
@@ -13,7 +15,7 @@ export class PointAndClickController extends Module.Controller {
|
|
|
13
15
|
[this.CONST.CONTROLS.BUTTONS.GAMEMENU]: this.emitGameMenu,
|
|
14
16
|
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => this.emit(this.EVENTS.INTERFACE.HISTORY_BACK),
|
|
15
17
|
};
|
|
16
|
-
controlsIndex =
|
|
18
|
+
controlsIndex = ZINDEX;
|
|
17
19
|
|
|
18
20
|
subscribe = () => {
|
|
19
21
|
this.on(this.EVENTS.POINT_AND_CLICK.SHOW, this.onShow);
|
|
@@ -22,7 +24,6 @@ export class PointAndClickController extends Module.Controller {
|
|
|
22
24
|
|
|
23
25
|
beforeShow = async () => {
|
|
24
26
|
this.updateState({ ...this.globalState["point-and-click"] });
|
|
25
|
-
this.currentItem = null;
|
|
26
27
|
this.maxCurrentItem = this.state.options.length - 1;
|
|
27
28
|
|
|
28
29
|
await this.emit(this.EVENTS.INTERFACE.HIDE);
|
package/modules/view.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
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 PointAndClickView extends
|
|
5
|
+
export class PointAndClickView extends ModuleView {
|
|
6
6
|
name = "point-and-click.view";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
animationTime = TRANSITION;
|
|
9
9
|
updateEvent = this.EVENTS.POINT_AND_CLICK.UPDATE;
|
|
10
|
+
|
|
11
|
+
renderFunc = render;
|
|
10
12
|
updateHandler = this.onUpdateReactComponent;
|
|
11
13
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.view.coralina.point-and-click",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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,38 +3,48 @@ import ReactDOM from "react-dom";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@bem-react/classname";
|
|
5
5
|
|
|
6
|
+
import { PositionBox, Screen } from "@vnejs/uis.base";
|
|
7
|
+
|
|
6
8
|
import "./index.styl";
|
|
7
9
|
|
|
8
10
|
const b = cn("PointAndClick");
|
|
9
11
|
|
|
12
|
+
export const ZINDEX = 1200;
|
|
13
|
+
export const TRANSITION = 300;
|
|
14
|
+
|
|
10
15
|
class PointAndClick extends React.Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/>
|
|
27
|
-
|
|
16
|
+
state = { isShow: false, isForce: false, options: [] };
|
|
17
|
+
|
|
18
|
+
onClick = (index) => this.props.emit(this.props.EVENTS.POINT_AND_CLICK.OPTION, { index });
|
|
19
|
+
|
|
20
|
+
renderOption = ({ disabled, hided, coords: [x, y], icon }, index) => (
|
|
21
|
+
<PositionBox
|
|
22
|
+
left={`${x}%`}
|
|
23
|
+
top={`${y}%`}
|
|
24
|
+
translateX={"-50%"}
|
|
25
|
+
translateY={"-50%"}
|
|
26
|
+
isNotRender={hided}
|
|
27
|
+
key={index}
|
|
28
|
+
onClick={disabled ? undefined : this.onClick}
|
|
29
|
+
value={index}
|
|
30
|
+
>
|
|
31
|
+
<div className={b("option", { icon, disabled, isCurrent: index === this.state.currentItem, coords: Boolean(x) && Boolean(y) })} />
|
|
32
|
+
</PositionBox>
|
|
33
|
+
);
|
|
28
34
|
|
|
29
35
|
render() {
|
|
30
|
-
const { isShow = false,
|
|
31
|
-
|
|
32
|
-
console.log(99999999999, isShow, options);
|
|
36
|
+
const { isShow = false, isForce = false, options = [] } = this.state;
|
|
33
37
|
|
|
34
38
|
return (
|
|
35
|
-
<
|
|
39
|
+
<Screen
|
|
40
|
+
isShow={isShow}
|
|
41
|
+
isForce={isForce}
|
|
42
|
+
zIndex={ZINDEX}
|
|
43
|
+
transition={TRANSITION}
|
|
44
|
+
isDisableAutoread={isShow}
|
|
45
|
+
>
|
|
36
46
|
{options.map(this.renderOption)}
|
|
37
|
-
</
|
|
47
|
+
</Screen>
|
|
38
48
|
);
|
|
39
49
|
}
|
|
40
50
|
}
|
package/view/index.styl
CHANGED
|
@@ -1,45 +1,17 @@
|
|
|
1
1
|
.PointAndClick
|
|
2
|
-
position: absolute
|
|
3
|
-
top: 0
|
|
4
|
-
right: 0
|
|
5
|
-
bottom: 0
|
|
6
|
-
left: 0
|
|
7
|
-
display: flex
|
|
8
|
-
justify-content: center
|
|
9
|
-
align-items: center
|
|
10
|
-
z-index: 3000
|
|
11
|
-
opacity: 0
|
|
12
|
-
pointer-events: none
|
|
13
|
-
font-family: Montserrat
|
|
14
|
-
|
|
15
|
-
&-options
|
|
16
|
-
display: flex
|
|
17
|
-
flex-direction: column
|
|
18
|
-
justify-content: center
|
|
19
|
-
align-items: center
|
|
20
|
-
height: 100%
|
|
21
|
-
gap: calc(50 / 2160 * 100%)
|
|
22
|
-
|
|
23
2
|
&-option
|
|
24
|
-
transition:
|
|
25
|
-
|
|
26
|
-
width: 3%
|
|
27
|
-
aspect-ratio: 1
|
|
3
|
+
transition: 300ms
|
|
28
4
|
|
|
29
|
-
background:
|
|
30
|
-
|
|
5
|
+
background-repeat: no-repeat
|
|
6
|
+
background-size: contain
|
|
7
|
+
background-position: center
|
|
31
8
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
transform: translate(-50%, -50%)
|
|
9
|
+
position: absolute
|
|
10
|
+
transform: translate(-50%, -50%)
|
|
35
11
|
|
|
36
12
|
&:not(&_disabled):hover,
|
|
37
13
|
&_isCurrent:not(&_disabled)
|
|
38
14
|
opacity: 0.85
|
|
39
|
-
transform: scale(1.25)
|
|
40
|
-
|
|
41
|
-
&_coords:hover:not(&_disabled)
|
|
42
|
-
&_coords&_isCurrent:not(&_disabled)
|
|
43
15
|
transform: translate(-50%, -50%) scale(1.25)
|
|
44
16
|
|
|
45
17
|
&:not(&_disabled)
|
|
@@ -47,10 +19,3 @@
|
|
|
47
19
|
|
|
48
20
|
&_disabled
|
|
49
21
|
opacity: 0.5
|
|
50
|
-
|
|
51
|
-
&_isShow
|
|
52
|
-
opacity: 1
|
|
53
|
-
pointer-events: all
|
|
54
|
-
|
|
55
|
-
&:not(&_isForce)
|
|
56
|
-
transition: opacity 300ms
|