File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2030,16 +2030,35 @@ export class GridStack {
20302030 // vars shared across all methods
20312031 let cellHeight : number , cellWidth : number ;
20322032
2033+ // creates a reference element for tracking the right position after scaling
2034+ const testEl = document . createElement ( 'div' ) ;
2035+ Utils . addElStyles ( testEl , {
2036+ opacity : '0' ,
2037+ position : 'fixed' ,
2038+ top : 0 + 'px' ,
2039+ left : 0 + 'px' ,
2040+ width : '1px' ,
2041+ height : '1px' ,
2042+ zIndex : '-999999' ,
2043+ } ) ;
2044+
20332045 let onDrag = ( event : DragEvent , el : GridItemHTMLElement , helper : GridItemHTMLElement ) => {
20342046 let node = el . gridstackNode ;
20352047 if ( ! node ) return ;
20362048
20372049 helper = helper || el ;
2050+ helper . appendChild ( testEl ) ;
2051+ const testElPosition = testEl . getBoundingClientRect ( ) ;
2052+ helper . removeChild ( testEl ) ;
2053+ const dragScale = {
2054+ x : 1 / testElPosition . width ,
2055+ y : 1 / testElPosition . height ,
2056+ }
20382057 let parent = this . el . getBoundingClientRect ( ) ;
20392058 let { top, left} = helper . getBoundingClientRect ( ) ;
20402059 left -= parent . left ;
20412060 top -= parent . top ;
2042- let ui : DDUIData = { position : { top, left} } ;
2061+ let ui : DDUIData = { position : { top : top * dragScale . y , left : left * dragScale . x } } ;
20432062
20442063 if ( node . _temporaryRemoved ) {
20452064 node . x = Math . max ( 0 , Math . round ( left / cellWidth ) ) ;
You can’t perform that action at this time.
0 commit comments