From 4bbdd295701caf0a1fa8775edd80124bfa912b3d Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Thu, 31 Oct 2024 20:25:50 -0700 Subject: [PATCH] Fix hotspot move on preview click Signed-off-by: Justin Georgi --- modules/glmv.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/glmv.js b/modules/glmv.js index 9d49db9..f921184 100644 --- a/modules/glmv.js +++ b/modules/glmv.js @@ -1,5 +1,4 @@ let slideShowInterval = null -let grabHotspotTimer = null let grabHotspotStart = null /** @@ -199,7 +198,10 @@ grabAnnotation = function(e) { * @param {MouseEvent} event */ moveAnnotation = function(e) { - e.target.style['transform'] = `translate(${e.x - grabHotspotStart.x}px, ${e.y - grabHotspotStart.y}px) scale(1.1,1.1)` + if (grabHotspotStart) { + grabHotspotStart.move = true + e.target.style['transform'] = `translate(${e.x - grabHotspotStart.x}px, ${e.y - grabHotspotStart.y}px) scale(1.1,1.1)` + } } /** @@ -208,9 +210,8 @@ moveAnnotation = function(e) { * @param {MouseEvent} event */ releaseAnnotation = function(e) { - if (grabHotspotStart) { + if (grabHotspotStart.move) { e.target.style['transform']='' - grabHotspotStart = null const contEl = $('.glmv-container')[0] contEl.removeEventListener('mousemove', moveAnnotation) const mvEl = $('model-viewer')[0] @@ -239,6 +240,7 @@ releaseAnnotation = function(e) { const newText = currentText.replace(/(.*?
)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
         $('#wpTextbox1').val(newText)
     }
+    grabHotspotStart = null
 }
 
 /**