Workshop › 15 Puzzle › Step 20 of 27
A tile that jumps to its new square is hard to follow. To make it slide, we first remember which tile is moving, from
where to where, and how far the animation is: slide.
```js
const SLIDE_FRAMES = 8
let slide // the tile sliding right now: { tile, from, to, frame }, or null
slide = null
slide = { tile: tiles[i], from: i, to: gap, frame: 0 }
```SLIDE_FRAMES = 8 frames (about 0.13 seconds).slide is null when nothing slides: null means "nothing, on purpose".move fills it in before changing the board: the tile's number, its old square, its new square (the gap), frame 0.const TOP = 60 write const SLIDE_FRAMES = 8.let moves write let slide ....reset write slide = null.move, under the neighbour check, write the slide = { ... } line. Press Run.Skills: Game states
← Is it solved? Count the frames →