Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleDragOver = (dragEvent) => {
- if (libraryManager.currentLibrary.isWritable) {
- // Would use dragEvent.dataTransfer here, but can't access that in dragOver events
- const validDropTargets = this.dropTargets && this.dropTargets[dragManager.dragType] || [];
- // Get the offsetTop for the library contents node
- const offsetTop = this.libraryContents.getBoundingClientRect() && this.libraryContents.getBoundingClientRect().top;
- const draggedY = dragEvent.clientY - offsetTop + this._scrollTop;
- const draggedX = dragEvent.clientX;
- // Find the dropTarget we are dragging over
- // TODO: This needs to be optimized. Slow for a lot of elements.
- const activeDropTarget = validDropTargets.find(dropTarget => {
- const isInYBounds = draggedY >= dropTarget.y && draggedY <= dropTarget.y + dropTarget.height;
- const isInXBounds = draggedX >= dropTarget.x && draggedX <= dropTarget.x + dropTarget.width;
- return isInYBounds && isInXBounds;
- });
- // Set or reset the drag manager drop target
- dragManager.setActiveDropTarget(activeDropTarget);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement