Skip to content

Commit

Permalink
Merge commit '9f4f930d8f46b8966efb04d70433f19953b6ab84'
Browse files Browse the repository at this point in the history
  • Loading branch information
MechMel committed Oct 18, 2024
2 parents 7e178e9 + f49ac4e commit aeb7c4b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/CorkBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { Box } from "./miwi";
import { useProp, exists, ReadonlyProp, useFormula } from "./utils";
import { observeElement } from "./Box/BoxUtils";
import { numOpenModals } from "./Modal";
import { CorkBoardPin } from "./CorkBoardPin";
const elementsBeingSorted = useProp<HTMLElement[]>([]);

/** Contents can be sorted by long pressing. */
export function CorkBoard(props: {
onSort: (props: { from: number; x: number; y: number;}) => void;
onSort: (props: { from: number; to: number }) => void;
onPickUp?: () => void;
children: any;
sortingZIndex?: number;
Expand Down Expand Up @@ -57,9 +56,6 @@ export function CorkBoard(props: {
// SECTION: Handle Drag
function handleDrag(clickTarget: HTMLElement, startMousePos: { x: number; y: number }) {
props.onPickUp?.();

console.log("CorkBoard needs some work on line 103. What we really need to do is access the mufasa doc.");

const sourceElement = (() => {
let sourceElement = clickTarget;
while (sourceElement.parentNode !== boxElement) {
Expand Down Expand Up @@ -98,11 +94,6 @@ export function CorkBoard(props: {
}

const { mousePos, stopWatchingMousePos } = watchMousePos(startMousePos);

//TODO - Find a better way to get the index of the element
const fromIndex = Array.from(boxElement!.children).indexOf(sourceElement);


// Create a floating container and attach to the body
const dragElement = document.createElement("div");
dragElement.style.position = "fixed";
Expand Down Expand Up @@ -186,15 +177,12 @@ export function CorkBoard(props: {
sourceElement.style.left = `${endX}px`;
sourceElement.style.top = `${endY}px`;
sourceElement.style.pointerEvents = "auto"; // re-enable pointer events

boxElement!.appendChild(sourceElement);

props.onSort({ from: fromIndex , x: endX, y: endY });

elementsBeingSorted.value = elementsBeingSorted.value.filter(
element => element !== sourceElement,
);

document.removeEventListener("mousemove", preventScrollOnMouseMove);
document.removeEventListener("touchmove", preventScrollOnMouseMove);
document.removeEventListener("mouseup", endDrag);
Expand Down

0 comments on commit aeb7c4b

Please sign in to comment.