本文整理汇总了TypeScript中@interactjs/utils.pointer.setCoordVelocity方法的典型用法代码示例。如果您正苦于以下问题:TypeScript pointer.setCoordVelocity方法的具体用法?TypeScript pointer.setCoordVelocity怎么用?TypeScript pointer.setCoordVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@interactjs/utils.pointer
的用法示例。
在下文中一共展示了pointer.setCoordVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: inertiaTick
function inertiaTick (interaction: Interact.Interaction) {
updateInertiaCoords(interaction)
utils.pointer.setCoordDeltas(interaction.coords.delta, interaction.coords.prev, interaction.coords.cur)
utils.pointer.setCoordVelocity(interaction.coords.velocity, interaction.coords.delta)
const state = interaction.inertia
const options = getOptions(interaction)
const lambda = options.resistance
const t = interaction._now() / 1000 - state.t0
if (t < state.te) {
const progress = 1 - (Math.exp(-lambda * t) - state.lambda_v0) / state.one_ve_v0
if (state.modifiedXe === state.xe && state.modifiedYe === state.ye) {
state.sx = state.xe * progress
state.sy = state.ye * progress
}
else {
const quadPoint = utils.getQuadraticCurvePoint(
0, 0,
state.xe, state.ye,
state.modifiedXe, state.modifiedYe,
progress)
state.sx = quadPoint.x
state.sy = quadPoint.y
}
interaction.move()
state.timeout = raf.request(() => inertiaTick(interaction))
}
else {
state.sx = state.modifiedXe
state.sy = state.modifiedYe
interaction.move()
interaction.end(state.startEvent)
state.active = false
interaction.simulation = null
}
utils.pointer.copyCoords(interaction.coords.prev, interaction.coords.cur)
}