@afeefa/vue-app 0.0.250 → 0.0.251
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.
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.251
|
package/package.json
CHANGED
@@ -22,14 +22,19 @@
|
|
22
22
|
</template>
|
23
23
|
|
24
24
|
<v-card v-if="modal">
|
25
|
-
<v-card-title
|
25
|
+
<v-card-title
|
26
|
+
v-if="title"
|
27
|
+
:style="{ cursor: draggable ? 'move' : 'default' }"
|
28
|
+
@mousedown="startDrag"
|
29
|
+
>
|
26
30
|
<v-icon
|
27
31
|
v-if="icon"
|
28
32
|
:color="icon.color"
|
29
33
|
class="mr-2"
|
30
34
|
size="1.5rem"
|
31
|
-
|
32
|
-
|
35
|
+
>
|
36
|
+
{{ icon.icon }}
|
37
|
+
</v-icon>
|
33
38
|
|
34
39
|
{{ title }}
|
35
40
|
</v-card-title>
|
@@ -51,7 +56,7 @@ import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
|
|
51
56
|
import { CancelOnEscMixin } from '@a-vue/services/escape/CancelOnEscMixin'
|
52
57
|
|
53
58
|
@Component({
|
54
|
-
props: ['show', 'icon', 'title', 'beforeClose', 'anchorPosition', 'screenCentered']
|
59
|
+
props: ['show', 'icon', 'title', 'beforeClose', 'anchorPosition', 'screenCentered', {draggable: true}]
|
55
60
|
})
|
56
61
|
export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentWidthMixin, CancelOnEscMixin) {
|
57
62
|
modalId = randomCssClass(10)
|
@@ -59,6 +64,11 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
|
|
59
64
|
modal = false
|
60
65
|
position = null
|
61
66
|
|
67
|
+
dragStartX = 0
|
68
|
+
dragStartY = 0
|
69
|
+
initialLeft = 0
|
70
|
+
initialTop = 0
|
71
|
+
|
62
72
|
cwm_maxWidth_ = 1000
|
63
73
|
|
64
74
|
created () {
|
@@ -95,6 +105,42 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
|
|
95
105
|
}, true) // capture phase, stop event before v-dialog receives it
|
96
106
|
}
|
97
107
|
|
108
|
+
startDrag (event) {
|
109
|
+
if (!this.draggable) {
|
110
|
+
return
|
111
|
+
}
|
112
|
+
|
113
|
+
this.dragStartX = event.clientX
|
114
|
+
this.dragStartY = event.clientY
|
115
|
+
|
116
|
+
const dialog = document.querySelector('.' + this.modalId)
|
117
|
+
const rect = dialog.getBoundingClientRect()
|
118
|
+
this.initialLeft = rect.left
|
119
|
+
this.initialTop = rect.top
|
120
|
+
|
121
|
+
document.addEventListener('mousemove', this.onDrag)
|
122
|
+
document.addEventListener('mouseup', this.stopDrag)
|
123
|
+
}
|
124
|
+
|
125
|
+
onDrag (event) {
|
126
|
+
const deltaX = event.clientX - this.dragStartX
|
127
|
+
const deltaY = event.clientY - this.dragStartY
|
128
|
+
|
129
|
+
const dialog = document.querySelector('.' + this.modalId)
|
130
|
+
if (dialog) {
|
131
|
+
dialog.style.left = `${this.initialLeft + deltaX}px`
|
132
|
+
dialog.style.top = `${this.initialTop + deltaY}px`
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
stopDrag () {
|
137
|
+
document.removeEventListener('mousemove', this.onDrag)
|
138
|
+
document.removeEventListener('mouseup', this.stopDrag)
|
139
|
+
|
140
|
+
// remove from position watching if has been dragged once
|
141
|
+
this.urp_unregisterPositionWatchers()
|
142
|
+
}
|
143
|
+
|
98
144
|
coe_cancelOnEsc () {
|
99
145
|
this.cancel()
|
100
146
|
return false // stop esc propagation
|
@@ -201,7 +247,6 @@ export default class ADialog extends Mixins(UsesPositionServiceMixin, ComponentW
|
|
201
247
|
}
|
202
248
|
</script>
|
203
249
|
|
204
|
-
|
205
250
|
<style lang="scss" scoped>
|
206
251
|
.v-card__title {
|
207
252
|
padding: .8rem 1rem !important;
|