@bildvitta/quasar-ui-asteroid 3.15.0-beta.0 → 3.15.0-beta.2
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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="qas-grabbable relative-position">
|
|
3
3
|
<div
|
|
4
4
|
ref="grabContainer"
|
|
5
|
-
class="flex no-wrap qas-grabbable__container"
|
|
5
|
+
class="flex no-wrap qas-grabbable__container secondary-scroll"
|
|
6
6
|
:class="classes"
|
|
7
7
|
>
|
|
8
8
|
<slot />
|
|
@@ -28,6 +28,7 @@ const grabContainer = ref(null)
|
|
|
28
28
|
const grabPosition = ref(null)
|
|
29
29
|
const isGrabbing = ref(false)
|
|
30
30
|
const scrollOnGrab = ref({})
|
|
31
|
+
const resizeObserver = ref(null)
|
|
31
32
|
|
|
32
33
|
const classes = computed(() => {
|
|
33
34
|
const baseClass = 'qas-grabbable__container'
|
|
@@ -54,7 +55,7 @@ function handleEnableScrollOnGrab () {
|
|
|
54
55
|
return
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
destroyScrollOnGrab()
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
function initScrollOnGrab () {
|
|
@@ -67,7 +68,7 @@ function initScrollOnGrab () {
|
|
|
67
68
|
})
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
function
|
|
71
|
+
function destroyScrollOnGrab () {
|
|
71
72
|
if (!hasScrollOnGrab.value) return
|
|
72
73
|
|
|
73
74
|
scrollOnGrab.value.destroyEvents()
|
|
@@ -109,16 +110,23 @@ function setGrabPosition () {
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
handleEnableScrollOnGrab
|
|
113
|
+
function setResizeObserver () {
|
|
114
|
+
resizeObserver.value = new ResizeObserver(handleEnableScrollOnGrab)
|
|
115
|
+
|
|
116
|
+
resizeObserver.value.observe(grabContainer.value)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function destroyResizeObserver () {
|
|
120
|
+
resizeObserver.value.unobserve(grabContainer.value)
|
|
121
|
+
}
|
|
114
122
|
|
|
115
|
-
|
|
123
|
+
onMounted(() => {
|
|
124
|
+
setResizeObserver()
|
|
116
125
|
})
|
|
117
126
|
|
|
118
127
|
onBeforeUnmount(() => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
disableScrollOnGrab()
|
|
128
|
+
destroyResizeObserver()
|
|
129
|
+
destroyScrollOnGrab()
|
|
122
130
|
})
|
|
123
131
|
</script>
|
|
124
132
|
|
|
@@ -128,25 +136,6 @@ onBeforeUnmount(() => {
|
|
|
128
136
|
-webkit-overflow-scrolling: touch;
|
|
129
137
|
-ms-overflow-style: none;
|
|
130
138
|
overflow-x: auto;
|
|
131
|
-
scrollbar-color: $blue-grey-3 transparent;
|
|
132
|
-
|
|
133
|
-
&::-webkit-scrollbar {
|
|
134
|
-
height: 12px;
|
|
135
|
-
background-color: transparent;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
&::-webkit-scrollbar-track {
|
|
139
|
-
background-color: transparent;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
&::-webkit-scrollbar-thumb {
|
|
143
|
-
background-color: $blue-grey-3;
|
|
144
|
-
border-radius: var(--qas-generic-border-radius);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&::-webkit-scrollbar-thumb:hover {
|
|
148
|
-
background-color: $blue-grey-4;
|
|
149
|
-
}
|
|
150
139
|
|
|
151
140
|
&::before,
|
|
152
141
|
&::after {
|
|
@@ -156,6 +145,7 @@ onBeforeUnmount(() => {
|
|
|
156
145
|
position: absolute;
|
|
157
146
|
top: 0;
|
|
158
147
|
pointer-events: none;
|
|
148
|
+
z-index: 1;
|
|
159
149
|
}
|
|
160
150
|
|
|
161
151
|
&::before {
|
package/src/css/utils/index.scss
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.secondary-scroll {
|
|
2
|
+
scrollbar-color: $blue-grey-3 transparent;
|
|
3
|
+
|
|
4
|
+
&::-webkit-scrollbar {
|
|
5
|
+
height: 12px;
|
|
6
|
+
background-color: transparent;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&::-webkit-scrollbar-track {
|
|
10
|
+
background-color: transparent;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&::-webkit-scrollbar-thumb {
|
|
14
|
+
background-color: $blue-grey-3;
|
|
15
|
+
border-radius: var(--qas-generic-border-radius);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
19
|
+
background-color: $blue-grey-4;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -11,17 +11,18 @@
|
|
|
11
11
|
* @returns {{ element: HTMLElement, destroyEvents: function }}
|
|
12
12
|
*/
|
|
13
13
|
export default function (element, options = {}) {
|
|
14
|
-
setModel()
|
|
15
|
-
|
|
16
14
|
let isDown = false
|
|
17
15
|
let startX
|
|
18
16
|
let scrollLeft
|
|
17
|
+
let isGrabbing = false
|
|
18
|
+
|
|
19
|
+
onGrab()
|
|
19
20
|
|
|
20
21
|
const events = {
|
|
21
22
|
mousedown: onMouseEnter,
|
|
22
|
-
mouseleave:
|
|
23
|
+
mouseleave: onMouseLeave,
|
|
23
24
|
mousemove: onMouseMove,
|
|
24
|
-
mouseup:
|
|
25
|
+
mouseup: onMouseLeave,
|
|
25
26
|
scroll: onScroll,
|
|
26
27
|
touchend: onLeave,
|
|
27
28
|
touchmove: onTouchMove,
|
|
@@ -53,10 +54,16 @@ export default function (element, options = {}) {
|
|
|
53
54
|
|
|
54
55
|
function onLeave () {
|
|
55
56
|
isDown = false
|
|
57
|
+
isGrabbing = false
|
|
56
58
|
|
|
57
59
|
element.classList.remove('active')
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
onGrab()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function onMouseLeave () {
|
|
65
|
+
onLeave()
|
|
66
|
+
blockEvents()
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
function onMouseMove (event) {
|
|
@@ -64,7 +71,10 @@ export default function (element, options = {}) {
|
|
|
64
71
|
|
|
65
72
|
if (!isDown) return
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
isGrabbing = true
|
|
75
|
+
|
|
76
|
+
onGrab()
|
|
77
|
+
blockEvents()
|
|
68
78
|
|
|
69
79
|
const x = event.pageX - element.offsetLeft
|
|
70
80
|
const walk = (x - startX) * 3 // scroll-fast
|
|
@@ -79,7 +89,9 @@ export default function (element, options = {}) {
|
|
|
79
89
|
|
|
80
90
|
if (!isDown) return
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
isGrabbing = true
|
|
93
|
+
|
|
94
|
+
onGrab()
|
|
83
95
|
|
|
84
96
|
options.onMoveFn?.({ element, event })
|
|
85
97
|
}
|
|
@@ -88,17 +100,13 @@ export default function (element, options = {}) {
|
|
|
88
100
|
options.onScrollFn?.({ element, event })
|
|
89
101
|
}
|
|
90
102
|
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
setStyles({ model, isGrabbing })
|
|
103
|
+
function onGrab () {
|
|
104
|
+
element.style.cursor = isGrabbing ? 'grabbing' : 'grab'
|
|
95
105
|
|
|
96
106
|
options.onGrabFn?.({ element, isGrabbing })
|
|
97
107
|
}
|
|
98
108
|
|
|
99
|
-
function
|
|
100
|
-
element.style.cursor = model
|
|
101
|
-
|
|
109
|
+
function blockEvents () {
|
|
102
110
|
Array.from(element.children).forEach(child => {
|
|
103
111
|
child.classList.toggle('no-pointer-events', isGrabbing)
|
|
104
112
|
child.classList.toggle('non-selectable', isGrabbing)
|