@@ -53,7 +53,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
53
53
protected helperContainment : HTMLElement ;
54
54
/** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */
55
55
protected static dragEventListenerOption = true ; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;
56
- /** @internal */
56
+ /** @internal properties we change during dragging, and restore back */
57
57
protected static originStyleProp = [ 'transition' , 'pointerEvents' , 'position' ,
58
58
'left' , 'top' , 'opacity' , 'zIndex' , 'width' , 'height' , 'willChange' , 'min-width' ] ;
59
59
@@ -232,19 +232,15 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
232
232
233
233
/** @internal */
234
234
protected _removeHelperStyle ( ) : DDDraggable {
235
+ let node = ( this . helper as GridItemHTMLElement ) ?. gridstackNode ;
235
236
// don't bother restoring styles if we're gonna remove anyway...
236
- let node = this . helper ? ( this . helper as GridItemHTMLElement ) . gridstackNode : undefined ;
237
237
if ( this . dragElementOriginStyle && ( ! node || ! node . _isAboutToRemove ) ) {
238
- DDDraggable . originStyleProp . forEach ( prop => {
239
- this . helper . style [ prop ] = this . dragElementOriginStyle [ prop ] || null ;
240
- } ) ;
238
+ let helper = this . helper ;
239
+ DDDraggable . originStyleProp . forEach ( prop => helper . style [ prop ] = this . dragElementOriginStyle [ prop ] || null ) ;
241
240
// show up instantly otherwise we animate to off the grid when switching back to 'absolute' from 'fixed'
242
- this . helper . style . transition = 'none' ;
243
- setTimeout ( ( ) => {
244
- if ( this . helper ) {
245
- this . helper . style . transition = this . dragElementOriginStyle [ 'transition' ] ; // recover animation
246
- }
247
- } , 0 ) ;
241
+ helper . style . transition = 'none' ;
242
+ let transition = this . dragElementOriginStyle [ 'transition' ] || null ;
243
+ setTimeout ( ( ) => helper . style . transition = transition , 0 ) ; // recover animation from saved vars
248
244
}
249
245
delete this . dragElementOriginStyle ;
250
246
return this ;
0 commit comments