]> git.r.bdr.sh - rbdr/canvas/blame - src/lib/stores/canvas.js
Render cases when the boundary crosses the viewport
[rbdr/canvas] / src / lib / stores / canvas.js
CommitLineData
d7cea969
RBR
1import { browser } from '$app/env';
2import { derived, writable } from 'svelte/store';
3
4export const canvas = writable({x: 0, y: 0});
5
6export const topLeft = derived(canvas, ($canvas) => {
7 if (browser) {
8 return {
9 x: $canvas.x - window.screen.width/2,
10 y: $canvas.y - window.screen.height/2
11 };
12 }
13 return {x: 0, y: 0}
14});
15
16export const bottomRight = derived(canvas, ($canvas) => {
17 if (browser) {
18 return {
19 x: $canvas.x + window.screen.width/2,
20 y: $canvas.y + window.screen.height/2
21 };
22 }
23 return {x: 0, y: 0}
24});