本文整理匯總了TypeScript中@interactjs/utils.pointer.getPageXY方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript pointer.getPageXY方法的具體用法?TypeScript pointer.getPageXY怎麽用?TypeScript pointer.getPageXY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@interactjs/utils.pointer
的用法示例。
在下文中一共展示了pointer.getPageXY方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: dropCheckMethod
function dropCheckMethod (
interactable: Interact.Interactable,
dragEvent: InteractEvent,
event: Interact.PointerEventType,
draggable: Interact.Interactable,
draggableElement: Element,
dropElement: Element,
rect: any
) {
let dropped = false
// if the dropzone has no rect (eg. display: none)
// call the custom dropChecker or just return false
if (!(rect = rect || interactable.getRect(dropElement))) {
return (interactable.options.drop.checker
? interactable.options.drop.checker(dragEvent, event, dropped, interactable, dropElement, draggable, draggableElement)
: false)
}
const dropOverlap = interactable.options.drop.overlap
if (dropOverlap === 'pointer') {
const origin = utils.getOriginXY(draggable, draggableElement, 'drag')
const page = utils.pointer.getPageXY(dragEvent)
page.x += origin.x
page.y += origin.y
const horizontal = (page.x > rect.left) && (page.x < rect.right)
const vertical = (page.y > rect.top) && (page.y < rect.bottom)
dropped = horizontal && vertical
}
const dragRect = draggable.getRect(draggableElement)
if (dragRect && dropOverlap === 'center') {
const cx = dragRect.left + dragRect.width / 2
const cy = dragRect.top + dragRect.height / 2
dropped = cx >= rect.left && cx <= rect.right && cy >= rect.top && cy <= rect.bottom
}
if (dragRect && utils.is.number(dropOverlap)) {
const overlapArea = (Math.max(0, Math.min(rect.right, dragRect.right) - Math.max(rect.left, dragRect.left)) *
Math.max(0, Math.min(rect.bottom, dragRect.bottom) - Math.max(rect.top, dragRect.top)))
const overlapRatio = overlapArea / (dragRect.width * dragRect.height)
dropped = overlapRatio >= dropOverlap
}
if (interactable.options.drop.checker) {
dropped = interactable.options.drop.checker(dragEvent, event, dropped, interactable, dropElement, draggable, draggableElement)
}
return dropped
}