@@ -11,7 +11,6 @@ function dragElement(elmnt) {
1111
1212 elmnt . onmousedown = dragMouseDown ;
1313
14-
1514 function dragMouseDown ( e ) {
1615 e = e || window . event ;
1716 e . preventDefault ( ) ;
@@ -80,6 +79,73 @@ function dragElement(elmnt) {
8079}
8180
8281
82+ function dragElement2 ( elmnt ) {
83+ var pos1 = 0 , pos2 = 0 , pos3 = 0 , pos4 = 0 ;
84+
85+ elmnt . onmousedown = dragMouseDown ;
86+
87+ function dragMouseDown ( e ) {
88+ e = e || window . event ;
89+ e . preventDefault ( ) ;
90+
91+ console . log ( ) ;
92+ const rect = elmnt . getBoundingClientRect ( ) ;
93+
94+ offsetX = e . clientX - rect . left
95+ offsetY = e . clientY - rect . top ;
96+
97+ // get the mouse cursor position at startup:
98+ pos3 = e . clientX ;
99+ pos4 = e . clientY ;
100+ document . onmouseup = closeDragElement ;
101+ // call a function whenever the cursor moves:
102+ document . onmousemove = elementDrag ;
103+ }
104+
105+ function elementDrag ( e ) {
106+ e = e || window . event ;
107+ e . preventDefault ( ) ;
108+ // calculate the new cursor position:
109+ pos1 = pos3 - e . clientX ;
110+ pos2 = pos4 - e . clientY ;
111+ pos3 = e . clientX ;
112+ pos4 = e . clientY ;
113+
114+ // set the element's new position:
115+ elmnt . style . position = "absolute" ;
116+
117+ let tcords = elmnt . parentElement . getBoundingClientRect ( ) ;
118+
119+ elmnt . style . left =
120+ ( ( e . pageX - offsetX ) - tcords . x ) + "px" ;
121+
122+ elmnt . style . top =
123+ ( ( e . pageY - offsetY + 50 ) - 50 ) + "px" ;
124+
125+ // elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
126+ // elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
127+
128+ }
129+
130+ function closeDragElement ( e ) {
131+ // stop moving when mouse button is released:
132+ elmnt . style . position = "" ;
133+ elmnt . style . top = ""
134+ elmnt . style . left = ""
135+ document . onmouseup = null ;
136+ document . onmousemove = null ;
137+ dragging = false
138+
139+
140+ if ( e . target . matches ( "#paletteDetails" ) ) {
141+
142+ }
143+
144+
145+ }
146+ }
147+
148+
83149function dropPalette ( e , elmnt ) {
84150
85151 if ( e . target . matches ( "#paletteCont" ) || e . target . matches ( ".paletteMark" ) || e . target . matches ( ".paletteMarks" ) ) {
0 commit comments