Skip to content

Commit

Permalink
Make generic
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 4, 2024
1 parent b90a9d0 commit c08cafc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function ZoomOutSeparator( {
ease: [ 0.6, 0, 0.4, 1 ],
} }
className="block-editor-block-list__zoom-out-separator"
data-is-zoom-out-separator="true"
data-is-insertion-point="true"
></motion.div>
) }
</AnimatePresence>
Expand Down
17 changes: 9 additions & 8 deletions packages/compose/src/hooks/use-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function useDropZone( {
*/
function isElementInZone( targetToCheck ) {
const { defaultView } = ownerDocument;

if (
! targetToCheck ||
! defaultView ||
Expand All @@ -108,18 +109,18 @@ export default function useDropZone( {
}

/**
* Checks if the given element is a zoom out separator.
* Checks if the given element is an insertion point.
*
* @param {EventTarget|null} targetToCheck - The element to check.
* @return {boolean} True if the element is a zoom out separator, false otherwise.
* @return {boolean} True if the element is a insertion point, false otherwise.
*/
function isZoomOutSeparator( targetToCheck ) {
function isInsertionPoint( targetToCheck ) {
const { defaultView } = ownerDocument;

return !! (
defaultView &&
targetToCheck instanceof defaultView.HTMLElement &&
targetToCheck.dataset.isZoomOutSeparator
targetToCheck.dataset.isInsertionPoint
);
}

Expand Down Expand Up @@ -186,13 +187,13 @@ export default function useDropZone( {
return;
}

// If we're moving in/out of a ZoomOutSeparator, don't trigger
// If we're moving in/out of an insertion point then don't trigger
// the onDragLeave event. This is to prevent the dropzone from
// being hidden when the user is dragging a block in/over/around
// a block and the separator.
// a block and a nearby insertion point.
if (
isZoomOutSeparator( event.relatedTarget ) ||
isZoomOutSeparator( event.target )
isInsertionPoint( event.relatedTarget ) ||
isInsertionPoint( event.target )
) {
return;
}
Expand Down

0 comments on commit c08cafc

Please sign in to comment.