comparison src/dad.js @ 9:eee8862be4c7

update text
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 28 Apr 2023 21:07:17 -0600
parents 969d5980b375
children ad2f6525c4c5
comparison
equal deleted inserted replaced
8:969d5980b375 9:eee8862be4c7
21 function isIn(x,y,rect) { 21 function isIn(x,y,rect) {
22 return rect.x <= x && x <= rect.x+rect.width && rect.y <= y && y <= rect.y+rect.height; 22 return rect.x <= x && x <= rect.x+rect.width && rect.y <= y && y <= rect.y+rect.height;
23 } 23 }
24 24
25 function onMouseMove(event) { 25 function onMouseMove(event) {
26 //console.log(event);
27 { 26 {
28 event.preventDefault(); 27 event.preventDefault();
29 let rect = dragging.getBoundingClientRect(); 28 let rect = dragging.getBoundingClientRect();
30 dragging.style.left = `${rect.x+event.movementX}px`; 29 dragging.style.left = `${rect.x+event.movementX}px`;
31 let y = rect.y + event.movementY; 30 let y = rect.y + event.movementY;
84 touchY = y; 83 touchY = y;
85 onMouseMove(event); 84 onMouseMove(event);
86 } 85 }
87 86
88 function onMouseUp(event) { 87 function onMouseUp(event) {
89 //console.log(event);
90 dad.onDrop({ 88 dad.onDrop({
91 original: original, 89 original: original,
92 dragging: dragging, 90 dragging: dragging,
93 dropzone: dropzone, 91 dropzone: dropzone,
94 mouseEvent: event, 92 mouseEvent: event,
116 dropzone = null; 114 dropzone = null;
117 dad.onDropped(droppedEvent); 115 dad.onDropped(droppedEvent);
118 } 116 }
119 117
120 function start(event) { 118 function start(event) {
121 //console.log(event);
122 original = dad.whatToDrag(event.target); 119 original = dad.whatToDrag(event.target);
123 dragging = original.cloneNode(true); 120 dragging = original.cloneNode(true);
124 original.setAttribute('dad-original',''); 121 original.setAttribute('dad-original','');
125 dragging.setAttribute('dad-dragging',''); 122 dragging.setAttribute('dad-dragging','');
126 let rect = original.getBoundingClientRect(); 123 let rect = original.getBoundingClientRect();