本文整理匯總了TypeScript中@interactjs/core/scope.Scope.now方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Scope.now方法的具體用法?TypeScript Scope.now怎麽用?TypeScript Scope.now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@interactjs/core/scope.Scope
的用法示例。
在下文中一共展示了Scope.now方法的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)
}