From 82236eabbba9ec860ee7970cac4485795de0b88c Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 25 六月 2024 16:45:40 +0800 Subject: [PATCH] 拖拽提优化 --- src/components/dragQuestion/index.vue | 25 ++++++++++++++++--------- src/books/artAndDrama/view/components/index.vue | 6 +++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/books/artAndDrama/view/components/index.vue b/src/books/artAndDrama/view/components/index.vue index 289799e..0dc4326 100644 --- a/src/books/artAndDrama/view/components/index.vue +++ b/src/books/artAndDrama/view/components/index.vue @@ -155,8 +155,8 @@ }, 500); // 娴嬭瘯椤甸潰璺宠浆 - //setTimeout(() => { - //this.gotoPage(3,16); + setTimeout(() => { + this.gotoPage(3,16); // setTimeout(() => { // this.renderSign("Highlight", { // id: "2ACA9359", @@ -184,7 +184,7 @@ // txt: " 杩愬姩绯荤粺鏄敱楠ㄣ�侀杩炵粨鍜岄楠艰倢涓夐儴鍒嗙粍鎴愮殑銆傚叏韬殑楠ㄩ�氳繃楠ㄨ繛缁撶粍鎴愪汉浣撻楠硷紙瑙佸浘1-1锛夈�傞楠兼槸浜轰綋鐨勬敮鏋讹紝鍏锋湁淇濇姢鍐呰剰鍣ㄥ畼銆佷緵鑲岃倝闄勭潃鍜屼綔涓鸿倢鑲夎繍鍔ㄧ殑鏉犳潌绛変綔鐢ㄣ�傚湪绁炵粡绯荤粺鐨勬敮閰嶄笅锛岃倢鑲夋敹缂╃壍鍔ㄦ墍闄勭潃鐨勯缁曠潃鍏宠妭杞姩锛屼娇韬綋浜х敓鍚勭鍔ㄤ綔銆傛墍浠ワ紝杩愬姩绯荤粺鍏锋湁杩愬姩銆佹敮鎸佸拰淇濇姢绛夊姛鑳斤紝骞煎勾鏃舵湡鐨勯楠艰繕鍏锋湁閫犺鍔熻兘銆� ", // txtIndex: 57 // }); - //}, 500); + }, 500); }, methods: { // setZoom1() { diff --git a/src/components/dragQuestion/index.vue b/src/components/dragQuestion/index.vue index 5c6624f..22787e6 100644 --- a/src/components/dragQuestion/index.vue +++ b/src/components/dragQuestion/index.vue @@ -194,6 +194,7 @@ maxY: null, spaceList: [], submitState:false, + isLift:false }; }, mounted() { @@ -206,6 +207,7 @@ mousedown(e) { e.preventDefault(); if(this.submitState) return false + this.isLift = false console.log("榧犳爣鎸変笅", e); this.moveDom = e.toElement; this.parentDom = this.getParentWithClass(e.toElement, "question-box"); @@ -238,6 +240,7 @@ e.y >= item.minY && e.y <= item.maxY ) { + if(!this.isLift) return false this.$set( this.drageQuestion[this.questionIndex].userAnswer, index, @@ -247,6 +250,7 @@ } ); this.moveDom.style.display = "none"; + this.moveDom = null; } } } @@ -255,8 +259,11 @@ // 榧犳爣鎶捣 mouseup(e) { if (this.moveDom) { - this.moveDom = null; + // this.moveDom = null; + } + this.isLift = true + }, // 鑾峰彇棰樼洰绌烘牸鍧愭爣 getSpaceInfo(parentDom) { @@ -265,10 +272,10 @@ for (let index = 0; index < list.length; index++) { const itemInfo = list[index].getBoundingClientRect(); arr.push({ - minX: itemInfo.x, - maxX: itemInfo.x + itemInfo.width, - minY: itemInfo.y, - maxY: itemInfo.y + itemInfo.height, + minX: itemInfo.x -10, + maxX: itemInfo.x + itemInfo.width + 10, + minY: itemInfo.y -10 , + maxY: itemInfo.y + itemInfo.height + 10, }); } this.spaceList = arr; @@ -309,7 +316,7 @@ let citem = item.userAnswer[cindex]; arr[cindex] = citem.value } - item.isRight = arr == item.answer + item.isRight = JSON.stringify(arr) == JSON.stringify(item.answer) item.isComplete = true } console.log(arr,this.drageQuestion[0]); @@ -412,6 +419,7 @@ } .drag-bottom-btn { width: 100%; + margin-top: 40px; display: flex; flex-wrap: wrap; justify-content: center; @@ -423,7 +431,7 @@ } .analysis { margin: 20px 0; - width: 94%; + width: 100%; // margin-left: 12px; } .judge-icon { @@ -466,9 +474,8 @@ text-align: left; display: flex; span:nth-child(1) { - display: inline-block; text-indent: 0; - width: 82px; + width: 100px; } } .correctBox { -- Gitblit v1.9.1