Workshop › Angry Birds-style Slingshot › Step 22 of 47
While the sling is held, moving the pointer changes the aim. Letting go launches the bird, unless the pull is tiny, so that a stray tap does not waste a bird.
```js
canvas.addEventListener('pointermove', (event) => {
if (dragging) pull(toCanvas(event))
})
document.addEventListener('pointerup', () => {
if (!dragging) return
dragging = false
if (aim.pull >= 15) launch()
})
```pointermove fires as the pointer moves; while dragging, the aim follows it.pointerup is listened to on the whole document, so letting go outside the canvas still counts.Write both listeners above function draw() {.
Skills: Keyboard and mouse input
← Grab the sling Wood and stone →