muigui 0.0.2 → 0.0.4
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/package.json +5 -4
- package/src/controllers/create-controller.js +6 -0
- package/src/libs/touch.js +15 -9
- package/src/styles/muigui.css.js +13 -2
- package/src/views/ColorChooserView.js +1 -0
- package/src/views/DirectionView.js +1 -1
- package/src/views/RadioGridView.js +1 -1
- package/src/views/SliderView.js +1 -0
- package/src/views/Vec2View.js +1 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muigui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A Simple GUI",
|
|
5
5
|
"main": "muigui.js",
|
|
6
6
|
"module": "src/muigui.js",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build": "npm run build-
|
|
9
|
+
"build": "npm run build-normal",
|
|
9
10
|
"build-normal": "rollup -c",
|
|
10
11
|
"build-min": "rollup -c",
|
|
11
12
|
"eslint": "eslint \"**/*.js\"",
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
36
37
|
"@rollup/plugin-terser": "^0.4.0",
|
|
37
38
|
"eslint": "^8.20.0",
|
|
38
|
-
"eslint-plugin-html": "^
|
|
39
|
+
"eslint-plugin-html": "^7.1.0",
|
|
39
40
|
"eslint-plugin-optional-comma-spacing": "0.0.4",
|
|
40
41
|
"eslint-plugin-require-trailing-comma": "0.0.1",
|
|
41
|
-
"rollup": "^
|
|
42
|
+
"rollup": "^3.20.2"
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -28,6 +28,12 @@ export function createController(object, property, ...args) {
|
|
|
28
28
|
const t = typeof object[property];
|
|
29
29
|
switch (t) {
|
|
30
30
|
case 'number':
|
|
31
|
+
if (typeof args[0] === 'number' && typeof args[1] === 'number') {
|
|
32
|
+
const min = args[0];
|
|
33
|
+
const max = args[1];
|
|
34
|
+
const step = args[2];
|
|
35
|
+
return new Range(object, property, {min, max, ...(step && {step})});
|
|
36
|
+
}
|
|
31
37
|
return args.length === 0
|
|
32
38
|
? new TextNumber(object, property, ...args)
|
|
33
39
|
: new Range(object, property, ...args);
|
package/src/libs/touch.js
CHANGED
|
@@ -17,7 +17,7 @@ export function computeRelativePosition(elem, event, start) {
|
|
|
17
17
|
|
|
18
18
|
export function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}) {
|
|
19
19
|
let start;
|
|
20
|
-
const
|
|
20
|
+
const pointerMove = function(event) {
|
|
21
21
|
const e = {
|
|
22
22
|
type: 'move',
|
|
23
23
|
...computeRelativePosition(elem, event, start),
|
|
@@ -25,15 +25,21 @@ export function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}
|
|
|
25
25
|
onMove(e);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const pointerUp = function(event) {
|
|
29
|
+
elem.releasePointerCapture(event.pointerId);
|
|
30
|
+
elem.removeEventListener('pointermove', pointerMove);
|
|
31
|
+
elem.removeEventListener('pointerup', pointerUp);
|
|
32
|
+
|
|
33
|
+
document.body.style.backgroundColor = '';
|
|
34
|
+
|
|
31
35
|
onUp('up');
|
|
32
36
|
};
|
|
33
37
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const pointerDown = function(event) {
|
|
39
|
+
elem.addEventListener('pointermove', pointerMove);
|
|
40
|
+
elem.addEventListener('pointerup', pointerUp);
|
|
41
|
+
elem.setPointerCapture(event.pointerId);
|
|
42
|
+
|
|
37
43
|
const rel = computeRelativePosition(elem, event);
|
|
38
44
|
start = [rel.x, rel.y];
|
|
39
45
|
onDown({
|
|
@@ -42,9 +48,9 @@ export function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}
|
|
|
42
48
|
});
|
|
43
49
|
};
|
|
44
50
|
|
|
45
|
-
elem.addEventListener('
|
|
51
|
+
elem.addEventListener('pointerdown', pointerDown);
|
|
46
52
|
|
|
47
53
|
return function() {
|
|
48
|
-
elem.removeEventListener('
|
|
54
|
+
elem.removeEventListener('pointerdown', pointerDown);
|
|
49
55
|
};
|
|
50
56
|
}
|
package/src/styles/muigui.css.js
CHANGED
|
@@ -2,6 +2,7 @@ const css = `
|
|
|
2
2
|
.muigui {
|
|
3
3
|
--width: 250px;
|
|
4
4
|
--label-width: 45%;
|
|
5
|
+
--number-width: 40%;
|
|
5
6
|
|
|
6
7
|
--bg-color: #222222;
|
|
7
8
|
--color: #dddddd;
|
|
@@ -40,6 +41,16 @@ const css = `
|
|
|
40
41
|
box-sizing: inherit;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
.muigui-no-scroll {
|
|
45
|
+
touch-action: none;
|
|
46
|
+
}
|
|
47
|
+
.muigui-no-h-scroll {
|
|
48
|
+
touch-action: pan-y;
|
|
49
|
+
}
|
|
50
|
+
.muigui-no-v-scroll {
|
|
51
|
+
touch-action: pan-x;
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
.muigui-invalid-value {
|
|
44
55
|
background-color: red !important;
|
|
45
56
|
color: white !important;
|
|
@@ -182,10 +193,10 @@ const css = `
|
|
|
182
193
|
min-width: 0;
|
|
183
194
|
}
|
|
184
195
|
.muigui-value>*:nth-child(1) {
|
|
185
|
-
flex: 1 1
|
|
196
|
+
flex: 1 1 calc(100% - var(--number-width));
|
|
186
197
|
}
|
|
187
198
|
.muigui-value>*:nth-child(2) {
|
|
188
|
-
flex: 1 1
|
|
199
|
+
flex: 1 1 var(--number-width);
|
|
189
200
|
margin-left: 0.2em;
|
|
190
201
|
}
|
|
191
202
|
|
|
@@ -59,6 +59,7 @@ export default class ColorChooserView extends EditView {
|
|
|
59
59
|
constructor(setter) {
|
|
60
60
|
super(createElem('div', {
|
|
61
61
|
innerHTML: svg,
|
|
62
|
+
className: 'muigui-no-scroll',
|
|
62
63
|
}));
|
|
63
64
|
this.#satLevelElem = this.domElement.children[0];
|
|
64
65
|
this.#hueUIElem = this.domElement.children[1];
|
|
@@ -63,7 +63,7 @@ export default class DirectionView extends EditView {
|
|
|
63
63
|
constructor(setter, options = {}) {
|
|
64
64
|
const wheelHelper = createWheelHelper();
|
|
65
65
|
super(createElem('div', {
|
|
66
|
-
className: 'muigui-direction',
|
|
66
|
+
className: 'muigui-direction muigui-no-scroll',
|
|
67
67
|
innerHTML: svg,
|
|
68
68
|
onWheel: e => {
|
|
69
69
|
e.preventDefault();
|
package/src/views/SliderView.js
CHANGED
|
@@ -102,6 +102,7 @@ export default class SliderView extends EditView {
|
|
|
102
102
|
const wheelHelper = createWheelHelper();
|
|
103
103
|
super(createElem('div', {
|
|
104
104
|
innerHTML: svg,
|
|
105
|
+
className: 'muigui-no-v-scroll',
|
|
105
106
|
onWheel: e => {
|
|
106
107
|
e.preventDefault();
|
|
107
108
|
const {min, max, step} = this.#options;
|
package/src/views/Vec2View.js
CHANGED