@bildvitta/quasar-ui-asteroid 3.15.0-beta.0 → 3.15.0-beta.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/package.json
CHANGED
|
@@ -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
|
+
}
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
function destroyResizeObserver () {
|
|
120
|
+
resizeObserver.value.unobserve(grabContainer.value)
|
|
121
|
+
}
|
|
122
|
+
|
|
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
|
|
|
@@ -156,6 +164,7 @@ onBeforeUnmount(() => {
|
|
|
156
164
|
position: absolute;
|
|
157
165
|
top: 0;
|
|
158
166
|
pointer-events: none;
|
|
167
|
+
z-index: 1;
|
|
159
168
|
}
|
|
160
169
|
|
|
161
170
|
&::before {
|
|
@@ -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)
|