@@ -16,7 +16,6 @@ export interface DDDraggableOpt {
1616 revert ?: string | boolean | unknown ; // TODO: not implemented yet
1717 scroll ?: boolean ; // nature support by HTML5 drag drop, can't be switch to off actually
1818 helper ?: string | HTMLElement | ( ( event : Event ) => HTMLElement ) ;
19- basePosition ?: 'fixed' | 'absolute' ;
2019 start ?: ( event : Event , ui : DDUIData ) => void ;
2120 stop ?: ( event : Event ) => void ;
2221 drag ?: ( event : Event , ui : DDUIData ) => void ;
@@ -52,13 +51,11 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
5251 private parentOriginStylePosition : string ;
5352 /** @internal */
5453 private helperContainment : HTMLElement ;
55- /** @internal */
56- private static basePosition : 'fixed' | 'absolute' = 'absolute' ;
5754 /** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */
5855 private static dragEventListenerOption = true ; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;
5956 /** @internal */
6057 private static originStyleProp = [ 'transition' , 'pointerEvents' , 'position' ,
61- 'left' , 'top' , 'opacity' , 'zIndex' , 'width' , 'height' , 'willChange' ] ;
58+ 'left' , 'top' , 'opacity' , 'zIndex' , 'width' , 'height' , 'willChange' , 'min-width' ] ;
6259
6360 constructor ( el : HTMLElement , option : DDDraggableOpt = { } ) {
6461 super ( ) ;
@@ -213,13 +210,14 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
213210
214211 /** @internal */
215212 private _setupHelperStyle ( ) : DDDraggable {
213+ // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
216214 this . helper . style . pointerEvents = 'none' ;
217215 this . helper . style . width = this . dragOffset . width + 'px' ;
218216 this . helper . style . height = this . dragOffset . height + 'px' ;
219217 this . helper . style . willChange = 'left, top' ;
220218 this . helper . style . transition = 'none' ; // show up instantly
221- this . helper . style . position = this . option . basePosition || DDDraggable . basePosition ;
222- this . helper . style . zIndex = '1000' ;
219+ this . helper . style . position = 'fixed' ; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
220+ this . helper . style [ 'min-width' ] = 0 ; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)
223221 setTimeout ( ( ) => {
224222 if ( this . helper ) {
225223 this . helper . style . transition = null ; // recover animation
@@ -232,10 +230,17 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
232230 private _removeHelperStyle ( ) : DDDraggable {
233231 // don't bother restoring styles if we're gonna remove anyway...
234232 let node = this . helper ? ( this . helper as GridItemHTMLElement ) . gridstackNode : undefined ;
235- if ( ! node || ! node . _isAboutToRemove ) {
233+ if ( this . dragElementOriginStyle && ( ! node || ! node . _isAboutToRemove ) ) {
236234 DDDraggable . originStyleProp . forEach ( prop => {
237235 this . helper . style [ prop ] = this . dragElementOriginStyle [ prop ] || null ;
238236 } ) ;
237+ // show up instantly otherwise we animate to off the grid when switching back to 'absolute' from 'fixed'
238+ this . helper . style . transition = 'none' ;
239+ setTimeout ( ( ) => {
240+ if ( this . helper ) {
241+ this . helper . style . transition = this . dragElementOriginStyle [ 'transition' ] ; // recover animation
242+ }
243+ } , 0 ) ;
239244 }
240245 delete this . dragElementOriginStyle ;
241246 return this ;
@@ -262,7 +267,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
262267 /** @internal */
263268 private _setupHelperContainmentStyle ( ) : DDDraggable {
264269 this . helperContainment = this . helper . parentElement ;
265- if ( this . option . basePosition !== 'fixed' ) {
270+ if ( this . helper . style . position !== 'fixed' ) {
266271 this . parentOriginStylePosition = this . helperContainment . style . position ;
267272 if ( window . getComputedStyle ( this . helperContainment ) . position . match ( / s t a t i c / ) ) {
268273 this . helperContainment . style . position = 'relative' ;
@@ -271,10 +276,10 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
271276 return this ;
272277 }
273278
274- /** @internal prevent the default gost image to be created (which has wrongas we move the helper/element instead
279+ /** @internal prevent the default ghost image to be created (which has wrong as we move the helper/element instead
275280 * (legacy jquery UI code updates the top/left of the item).
276281 * TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update
277- * the actual grid-item but move the gost image around (and special case jq version) ?
282+ * the actual grid-item but move the ghost image around (and special case jq version) ?
278283 **/
279284 private _cancelDragGhost ( e : DragEvent ) : DDDraggable {
280285 /* doesn't seem to do anything...
0 commit comments