本文整理汇总了TypeScript中@interactjs/utils.arr.find方法的典型用法代码示例。如果您正苦于以下问题:TypeScript arr.find方法的具体用法?TypeScript arr.find怎么用?TypeScript arr.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@interactjs/utils.arr
的用法示例。
在下文中一共展示了arr.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reflow
function reflow (interactable: Interactable, action: ActionProps, scope: Scope): Promise<Interactable> {
const elements = is.string(interactable.target)
? arr.from(interactable._context.querySelectorAll(interactable.target))
: [interactable.target]
// tslint:disable-next-line variable-name
const Promise = (win.window as any).Promise
const promises: Array<Promise<null>> | null = Promise ? [] : null
for (const element of elements) {
const rect = interactable.getRect(element)
if (!rect) { break }
const runningInteraction = arr.find(
scope.interactions.list,
(interaction: Interaction) => {
return interaction.interacting() &&
interaction.interactable === interactable &&
interaction.element === element &&
interaction.prepared.name === action.name
})
let reflowPromise: Promise<null>
if (runningInteraction) {
runningInteraction.move()
if (promises) {
reflowPromise = runningInteraction._reflowPromise || new Promise((resolve: any) => {
runningInteraction._reflowResolve = resolve
})
}
}
else {
const xywh = rectUtils.tlbrToXywh(rect)
const coords = {
page : { x: xywh.x, y: xywh.y },
client : { x: xywh.x, y: xywh.y },
timeStamp: scope.now(),
}
const event = pointerUtils.coordsToEvent(coords)
reflowPromise = startReflow(scope, interactable, element, action, event)
}
if (promises) {
promises.push(reflowPromise)
}
}
return promises && Promise.all(promises).then(() => interactable)
}