@qtoggle/qui 1.20.0-beta.1 → 1.20.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/js/widgets/widgets.js +41 -0
- package/less/icon-label-view.less +21 -9
- package/package.json +1 -1
- package/pyproject.toml +1 -1
package/js/widgets/widgets.js
CHANGED
|
@@ -29,6 +29,46 @@ function initButtons() {
|
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function initLongPress() {
|
|
33
|
+
/* A touch press held long enough to become a long press ends without a click, so the release looked like a
|
|
34
|
+
* tap that did nothing. Treat that release as a click, except in text fields and links, which have their own
|
|
35
|
+
* long-press menus. */
|
|
36
|
+
let longPressTarget = null
|
|
37
|
+
|
|
38
|
+
document.addEventListener('contextmenu', function (e) {
|
|
39
|
+
let ownMenu = e.target.closest('input, textarea, select, [contenteditable], a[href]')
|
|
40
|
+
longPressTarget = (e.pointerType === 'touch' && !ownMenu) ? e.target : null
|
|
41
|
+
if (longPressTarget) {
|
|
42
|
+
e.preventDefault()
|
|
43
|
+
}
|
|
44
|
+
}, {capture: true})
|
|
45
|
+
|
|
46
|
+
document.addEventListener('pointerup', function (e) {
|
|
47
|
+
let target = longPressTarget
|
|
48
|
+
longPressTarget = null
|
|
49
|
+
if (!target || e.pointerType !== 'touch') {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Touch pointers stay captured by the pressed element, so find where the finger actually left. Like a real
|
|
54
|
+
* click, the target is the closest element holding both the press and the release. */
|
|
55
|
+
let released = document.elementFromPoint(e.clientX, e.clientY)
|
|
56
|
+
while (target && !target.contains(released)) {
|
|
57
|
+
target = target.parentElement
|
|
58
|
+
}
|
|
59
|
+
if (!target || target === document.body || target === document.documentElement) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Let the release finish first, like a real click does */
|
|
64
|
+
setTimeout(() => target.click())
|
|
65
|
+
}, {capture: true, passive: true})
|
|
66
|
+
|
|
67
|
+
document.addEventListener('pointercancel', function () {
|
|
68
|
+
longPressTarget = null
|
|
69
|
+
}, {capture: true, passive: true})
|
|
70
|
+
}
|
|
71
|
+
|
|
32
72
|
/**
|
|
33
73
|
* Create a caption made of an icon and a text.
|
|
34
74
|
* @alias qui.widgets.makeIconTextCaption
|
|
@@ -54,4 +94,5 @@ export function makeIconTextCaption(icon, text) {
|
|
|
54
94
|
|
|
55
95
|
export function init() {
|
|
56
96
|
initButtons()
|
|
97
|
+
initLongPress()
|
|
57
98
|
}
|
|
@@ -57,38 +57,50 @@ div.qui-icon-label-view {
|
|
|
57
57
|
&.qui-base-button {
|
|
58
58
|
background: @background-color;
|
|
59
59
|
color: @interactive-color;
|
|
60
|
+
transition: color @transition-duration ease,
|
|
61
|
+
opacity @transition-duration ease;
|
|
60
62
|
|
|
61
|
-
/* The pressed shade
|
|
62
|
-
*
|
|
63
|
+
/* The selected fill and the pressed shade are overlays faded by opacity, which the compositor animates without
|
|
64
|
+
* repainting the row. Chrome sometimes shows a background transition's first frame again once it ends. */
|
|
63
65
|
position: relative;
|
|
66
|
+
z-index: 0;
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
/* Negative z-index keeps both overlays above the row's background but below its content */
|
|
69
|
+
&::before,
|
|
70
|
+
&::after {
|
|
66
71
|
content: '';
|
|
67
72
|
position: absolute;
|
|
68
73
|
top: 0;
|
|
69
74
|
right: 0;
|
|
70
75
|
bottom: 0;
|
|
71
76
|
left: 0;
|
|
72
|
-
background: @background-active-color;
|
|
73
77
|
opacity: 0;
|
|
74
78
|
transition: opacity @transition-duration ease;
|
|
75
79
|
pointer-events: none;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
&::before {
|
|
83
|
+
background: @interactive-color;
|
|
84
|
+
z-index: -2;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&::after {
|
|
88
|
+
background: @background-active-color;
|
|
89
|
+
z-index: -1;
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
&.active::
|
|
92
|
+
&.active::after {
|
|
84
93
|
opacity: 1;
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
&.selected {
|
|
88
|
-
background: @interactive-color;
|
|
89
97
|
color: @background-color;
|
|
90
98
|
|
|
91
99
|
&::before {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&::after {
|
|
92
104
|
background: @interactive-active-color;
|
|
93
105
|
}
|
|
94
106
|
|
package/package.json
CHANGED