File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,12 +86,17 @@ const makeButtonsWork = (panel) => {
8686}
8787
8888const makeDraggable = ( element ) => {
89+ const rect = element . getBoundingClientRect ( )
90+ const parentRect = element . parentElement . getBoundingClientRect ( )
91+ const initialX = rect . left - parentRect . left
92+ const initialY = rect . top - parentRect . top
93+
8994 let offsetX = 0
9095 let offsetY = 0
91- let targetX = 0
92- let targetY = 0
93- let currentX = 0
94- let currentY = 0
96+ let targetX = initialX
97+ let targetY = initialY
98+ let currentX = initialX
99+ let currentY = initialY
95100 let animationId = null
96101 let isDragging = false
97102 const easing = 0.125
@@ -153,9 +158,9 @@ const makeCollapsible = (element) => {
153158window . addEventListener ( 'DOMContentLoaded' , ( ) => {
154159 const explorePanel = createDOMNodeFromHTML ( template ( ) )
155160 makeButtonsWork ( explorePanel )
156- makeDraggable ( explorePanel )
157161 makeCollapsible ( explorePanel )
158162
159163 const container = query ( '#panels-container' )
160164 container . appendChild ( explorePanel )
161- } )
165+ makeDraggable ( explorePanel )
166+ } )
Original file line number Diff line number Diff line change 2525
2626 .explore-panel {
2727 position : absolute;
28- top : 0 ;
29- left : 0 ;
28+ top : 50 % ;
29+ left : 50 % ;
3030 display : flex;
3131 flex-direction : column;
3232 gap : 0.4em ;
You can’t perform that action at this time.
0 commit comments