Skip to content

Commit

Permalink
Adds a pointer capture on component drag
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland committed Oct 2, 2024
1 parent 55f14e3 commit 2d8a98f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions v3/src/components/container/free-tile-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export const FreeTileComponent = observer(function FreeTileComponent({ row, tile
activeDrag => {
const dragTileId = getDragTileId(activeDrag)
if (dragTileId) {
const draggedElement = document.getElementById(dragTileId)
if (draggedElement) {
// Capture pointer events for the dragged tile
// draggedElement.addEventListener('pointerdown', (event) => {
// draggedElement.setPointerCapture(event.pointerId)
// })
draggedElement.addEventListener('pointermove', (event) => {
draggedElement.setPointerCapture(event.pointerId)
})

draggedElement.addEventListener('pointerup', (event) => {
draggedElement.releasePointerCapture(event.pointerId)
})
}

if (isFreeTileRow(row)) {
const allowBringToFront = dragTileId === tile.id ? tile.content.allowBringToFront : true
row.moveTileToTop(dragTileId, allowBringToFront)
Expand Down

0 comments on commit 2d8a98f

Please sign in to comment.