Skip to content

Commit be9ee98

Browse files
committed
dragging clipp fix part II
* #1902 change caused a flicker when item goes posision:fixed, so make sure we position on screen during init as well.
1 parent d6df3d2 commit be9ee98

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/h5/dd-draggable.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,20 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
211211
/** @internal */
212212
private _setupHelperStyle(): DDDraggable {
213213
// TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
214-
this.helper.style.pointerEvents = 'none';
215-
this.helper.style.width = this.dragOffset.width + 'px';
216-
this.helper.style.height = this.dragOffset.height + 'px';
217-
this.helper.style.willChange = 'left, top';
218-
this.helper.style.transition = 'none'; // show up instantly
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 %)
214+
const rec = this.helper.getBoundingClientRect();
215+
const style = this.helper.style;
216+
style.pointerEvents = 'none';
217+
style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)
218+
style.width = this.dragOffset.width + 'px';
219+
style.height = this.dragOffset.height + 'px';
220+
style.willChange = 'left, top';
221+
style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
222+
style.left = rec.left + 'px';
223+
style.top = rec.top + 'px';
224+
style.transition = 'none'; // show up instantly
221225
setTimeout(() => {
222226
if (this.helper) {
223-
this.helper.style.transition = null; // recover animation
227+
style.transition = null; // recover animation
224228
}
225229
}, 0);
226230
return this;

0 commit comments

Comments
 (0)