Reference · Rules, tiles and records
keepInReachfunction
Kept within reach: some of the area always on the screen, so a pan can never lose the crossword. A quarter of the screen or two tiles, whichever is less, stays in view on every side.
Import it
import { keepInReach } from "@johnmorrisdotca/kumimoji";
Definition
function keepInReach(view: View, area: Area, width: number, height: number): View
Parameters
| Name | Type | Description |
|---|---|---|
view | View | The current tile size and pixel translation. |
area | Area | The occupied table bounds. |
width | number | The available viewport width in pixels. |
height | number | The available viewport height in pixels. |
Returns
View
Kept within reach: some of the area always on the screen, so a pan can never lose the crossword. A quarter of the screen or two tiles, whichever is less, stays in view on every side.
Examples
import { keepInReach } from "@johnmorrisdotca/kumimoji";
const area = {top:0,left:0,rows:1,cols:3};
const view = {tile:40,x:100,y:100};
console.log(keepInReach(view,area,640,480));{ tile: 40, x: 100, y: 100 }What it prints (run when this page was built)