adding dropzone measurement

This commit is contained in:
Caleb Owens 2024-07-01 13:40:49 +02:00
parent 9aac60b1e4
commit 5a806ef71e
No known key found for this signature in database
2 changed files with 24 additions and 1 deletions

View File

@ -22,6 +22,7 @@
} from '$lib/vbranches/contexts';
import { BaseBranch, Branch } from '$lib/vbranches/types';
import { goto } from '$app/navigation';
import ja from 'date-fns/locale/ja';
export let isUnapplied: boolean;
@ -92,12 +93,28 @@
if (isLast) return 0;
return 0;
}
let currentlyDraggedCommitId: string | undefined;
function handleDragStart(commit: string) {
currentlyDraggedCommitId = commit;
}
function handleDragEnd() {
currentlyDraggedCommitId = undefined;
}
</script>
{#snippet reorderDropzone(dropzone: ReorderDropzone, yOffsetPx: number)}
<Dropzone accepts={dropzone.accepts.bind(dropzone)} ondrop={dropzone.onDrop.bind(dropzone)}>
{#snippet overlay({ hovered, activated })}
<LineOverlay {hovered} {activated} {yOffsetPx} />
<LineOverlay
{hovered}
{activated}
{yOffsetPx}
isNeighbour={!!currentlyDraggedCommitId &&
dropzone.distanceToOtherCommit(currentlyDraggedCommitId) === 0}
/>
{/snippet}
</Dropzone>
{/snippet}
@ -116,6 +133,8 @@
last={idx === $remoteCommits.length - 1}
commitUrl={$baseBranch?.commitUrl(commit.id)}
isHeadCommit={commit.id === headCommit?.id}
ondragstart={() => handleDragStart(commit.id)}
ondragend={() => handleDragEnd()}
>
{#snippet lines(topHeightPx)}
<LineGroup lineGroup={lineManager.get(commit.id)} {topHeightPx} />

View File

@ -10,6 +10,10 @@ export class ReorderDropzone {
private entry: Entry
) {}
distanceToOtherCommit(commitSha: string): number {
return this.entry.distanceToOtherCommit(commitSha);
}
accepts(data: any) {
if (!(data instanceof DraggableCommit)) return false;
if (data.branchId !== this.branch.id) return false;