Change annotation edit grabbing to ctrl-click

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-01 10:38:55 -07:00
parent 4bbdd29570
commit df11f0c54b

View File

@@ -1,5 +1,5 @@
let slideShowInterval = null let slideShowInterval = null
let grabHotspotStart = null let grabHotspot = null
/** /**
* Sets listener and attributes on model-viewer to * Sets listener and attributes on model-viewer to
@@ -185,10 +185,16 @@ toggleAnnotations = function(mView) {
* @param {MouseEvent} event * @param {MouseEvent} event
*/ */
grabAnnotation = function(e) { grabAnnotation = function(e) {
if (!grabHotspotStart) { if (e.ctrlKey) {
grabHotspotStart = {x: e.x, y: e.y} grabHotspot = {x: e.x, y: e.y}
const contEl = $('.glmv-container')[0] const contEl = $('.glmv-container')[0]
contEl.addEventListener('mousemove', moveAnnotation) contEl.addEventListener('mousemove', moveAnnotation)
const mvEl = $('model-viewer')[0]
console.log(contEl)
console.log(e)
console.log(mvEl.queryHotspot(e.target.slot))
} else {
grabHotspot = null
} }
} }
@@ -198,9 +204,9 @@ grabAnnotation = function(e) {
* @param {MouseEvent} event * @param {MouseEvent} event
*/ */
moveAnnotation = function(e) { moveAnnotation = function(e) {
if (grabHotspotStart) { if (grabHotspot) {
grabHotspotStart.move = true grabHotspot.move = true
e.target.style['transform'] = `translate(${e.x - grabHotspotStart.x}px, ${e.y - grabHotspotStart.y}px) scale(1.1,1.1)` e.target.style['transform'] = `translate(${e.x - grabHotspot.x}px, ${e.y - grabHotspot.y}px) scale(1.1,1.1)`
} }
} }
@@ -210,7 +216,8 @@ moveAnnotation = function(e) {
* @param {MouseEvent} event * @param {MouseEvent} event
*/ */
releaseAnnotation = function(e) { releaseAnnotation = function(e) {
if (grabHotspotStart.move) { if (grabHotspot.move) {
console.log(e.target)
e.target.style['transform']='' e.target.style['transform']=''
const contEl = $('.glmv-container')[0] const contEl = $('.glmv-container')[0]
contEl.removeEventListener('mousemove', moveAnnotation) contEl.removeEventListener('mousemove', moveAnnotation)
@@ -240,7 +247,7 @@ releaseAnnotation = function(e) {
const newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`) const newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
$('#wpTextbox1').val(newText) $('#wpTextbox1').val(newText)
} }
grabHotspotStart = null grabHotspot = null
} }
/** /**