Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed jumping items on component resize. #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/MoveResize/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}

.stopMove {
transition: none !important;
}
</style>

<div
Expand All @@ -63,7 +67,10 @@
class="svlt-grid-item"
class:svlt-grid-active={active || (trans && rect)}
style="width: {active ? newSize.width : width}px; height:{active ? newSize.height : height}px;
{active ? `transform: translate(${cordDiff.x}px, ${cordDiff.y}px);top:${rect.top}px;left:${rect.left}px;` : trans ? `transform: translate(${cordDiff.x}px, ${cordDiff.y}px); position:absolute; transition: width 0.2s, height 0.2s;` : `transition: transform 0.2s, opacity 0.2s; transform: translate(${left}px, ${top}px); `} ">
{active ? `transform: translate(${cordDiff.x}px, ${cordDiff.y}px);top:${rect.top}px;left:${rect.left}px;`
: trans ? `transform: translate(${cordDiff.x}px, ${cordDiff.y}px); position:absolute; transition: width 0.2s, height 0.2s;`
: `transition: transform 0.2s, opacity 0.2s; transform: translate(${left}px, ${top}px);`} "
class:stopMove={!moveAnimation}>
<slot movePointerDown={pointerdown} {resizePointerDown} />
{#if resizable && !item.customResizer}
<div class="svlt-grid-resizer" on:pointerdown={resizePointerDown} />
Expand All @@ -87,6 +94,7 @@

export let resizable;
export let draggable;
export let moveAnimation;

export let id;
export let container;
Expand Down
8 changes: 6 additions & 2 deletions src/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
draggable={item[getComputedCols] && item[getComputedCols].draggable}
{xPerPx}
{yPerPx}
{moveAnimation}
width={Math.min(getComputedCols, item[getComputedCols] && item[getComputedCols].w) * xPerPx - gapX * 2}
height={(item[getComputedCols] && item[getComputedCols].h) * yPerPx - gapY * 2}
top={(item[getComputedCols] && item[getComputedCols].y) * yPerPx + gapY}
Expand Down Expand Up @@ -57,10 +58,11 @@
export let fastStart = false;
export let throttleUpdate = 100;
export let throttleResize = 100;

export let scroller = undefined;
export let sensor = 20;


let moveAnimation = true;
let getComputedCols;

let container;
Expand Down Expand Up @@ -91,6 +93,8 @@
yPerPx,
width: containerWidth,
});
moveAnimation = false
setTimeout(() => moveAnimation = true, throttleUpdate + 100)
}, throttleUpdate);

onMount(() => {
Expand Down