add cards & tracks
This commit is contained in:
@@ -130,7 +130,7 @@ onMounted(() => {
|
||||
const down = (ev: PointerEvent) => {
|
||||
ev.preventDefault()
|
||||
dragging = true
|
||||
scene.value?.setPointerCapture(ev.pointerId)
|
||||
box.value?.setPointerCapture(ev.pointerId)
|
||||
lastPointer = { x: ev.clientX, y: ev.clientY, time: performance.now() }
|
||||
velocity = { x: 0, y: 0 }
|
||||
if (raf) { cancelAnimationFrame(raf); raf = null }
|
||||
@@ -158,17 +158,17 @@ onMounted(() => {
|
||||
const end = (ev: PointerEvent) => {
|
||||
if (!dragging) return
|
||||
dragging = false
|
||||
try { scene.value?.releasePointerCapture(ev.pointerId) } catch { }
|
||||
try { box.value?.releasePointerCapture(ev.pointerId) } catch { }
|
||||
if (enableInertia && (Math.abs(velocity.x) > minVelocity || Math.abs(velocity.y) > minVelocity)) {
|
||||
if (!raf) raf = requestAnimationFrame(tickInertia)
|
||||
}
|
||||
}
|
||||
|
||||
scene.value?.addEventListener('pointerdown', down)
|
||||
scene.value?.addEventListener('pointermove', move)
|
||||
scene.value?.addEventListener('pointerup', end)
|
||||
scene.value?.addEventListener('pointercancel', end)
|
||||
scene.value?.addEventListener('pointerleave', end)
|
||||
box.value?.addEventListener('pointerdown', down)
|
||||
box.value?.addEventListener('pointermove', move)
|
||||
box.value?.addEventListener('pointerup', end)
|
||||
box.value?.addEventListener('pointercancel', end)
|
||||
box.value?.addEventListener('pointerleave', end)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cancelAnimationFrame(raf!)
|
||||
|
||||
Reference in New Issue
Block a user