@@ -30,7 +30,12 @@ function toggleLock() {
3030}
3131
3232const gridSize = 20 ;
33- const items = ref (props .dataset );
33+ const items = ref (props .dataset .map ((item ,i ) => {
34+ return {
35+ ... item,
36+ index: i
37+ }
38+ }));
3439const dragging = ref (null );
3540const resizing = ref (null );
3641const dragStart = ref ({ x: 0 , y: 0 });
@@ -39,6 +44,22 @@ const dashboardContainer = ref(null);
3944const isDragOrResize = ref (false );
4045const changeIndex = ref (null );
4146const isPrinting = ref (false );
47+ const isPaused = ref (false );
48+
49+ function handleInteraction (event ) {
50+ const target = event .target ;
51+ if (target .tagName === " INPUT" && target .type === " range" ) {
52+ isPaused .value = true ;
53+ }
54+ }
55+
56+ function handleInteractionEnd (event ) {
57+ const target = event .target ;
58+ if (target .tagName === " INPUT" && target .type === " range" ) {
59+ isPaused .value = false ;
60+ }
61+ }
62+
4263
4364function generatePdf (){
4465 isPrinting .value = true ;
@@ -127,7 +148,7 @@ function checkDirection(item, deltaX, deltaY) {
127148}
128149
129150function onMouseMove (event ) {
130- if (isLocked .value ) return ;
151+ if (isLocked .value || isPaused . value ) return ;
131152 isDragOrResize .value = true ;
132153 if (dragging .value !== null ) {
133154 const item = items .value [dragging .value ];
@@ -182,7 +203,7 @@ function stopDragResize() {
182203};
183204
184205function onTouchStart (index ) {
185- if (isLocked .value ) return ;
206+ if (isLocked .value || isPaused . value ) return ;
186207 isDragOrResize .value = true ;
187208 changeIndex .value = index;
188209 if (resizing .value === null ) {
@@ -214,7 +235,7 @@ function onTouchResizeMove(event) {
214235};
215236
216237function onTouchMove (event ) {
217- if (isLocked .value ) return ;
238+ if (isLocked .value || isPaused . value ) return ;
218239 isDragOrResize .value = true ;
219240 event .preventDefault ();
220241 if (dragging .value !== null ) {
@@ -280,7 +301,12 @@ defineExpose({
280301 </script >
281302
282303<template >
283- <div >
304+ <div
305+ @mousedown =" handleInteraction"
306+ @mouseup =" handleInteractionEnd"
307+ @touchstart =" handleInteraction"
308+ @touchend =" handleInteractionEnd"
309+ >
284310 <div data-html2canvas-ignore style =" width : 100% ; display :flex ; justify-content : end ;" v-if =" FINAL_CONFIG.allowPrint" >
285311 <button class =" vue-ui-dashboard-button" @click =" generatePdf" :disabled =" isPrinting" style =" margin-top :12px " :style =" `color:${FINAL_CONFIG.style.board.color}`" >
286312 <svg class =" vue-ui-dashboard-print-icon" xmlns =" http://www.w3.org/2000/svg" v-if =" isPrinting" width =" 20" height =" 20" viewBox =" 0 0 24 24" stroke-width =" 1.5" :stroke =" FINAL_CONFIG.style.board.color" fill =" none" stroke-linecap =" round" stroke-linejoin =" round" >
@@ -316,11 +342,11 @@ defineExpose({
316342 top: `${item.top}%`,
317343 cursor: 'move',
318344 boxShadow: changeIndex === index ? '0 6px 12px -3px rgba(0,0,0,0.3)' : '',
319- zIndex: changeIndex === index ? '1' : '0' ,
345+ zIndex: changeIndex === index ? items.length + 1 : item.index ,
320346 backgroundColor: FINAL_CONFIG.style.item.backgroundColor
321347 }"
322348 @mousedown =" startDrag(index)"
323- @touchstart =" onTouchStart(index)"
349+ @touchstart =" onTouchStart(index, item )"
324350 >
325351 <template v-if =" ! isLocked " >
326352 <div
@@ -352,6 +378,7 @@ defineExpose({
352378 @touchend =" onTouchEnd"
353379 ></div >
354380 </template >
381+
355382 <slot name =" content" :item =" item" :index =" index" :left =" item.left" :top =" item.top" :height =" item.height" :width =" item.width" ></slot >
356383 </div >
357384 </div >
0 commit comments