diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-01-06 16:59:54 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-01-06 16:59:54 +1100 |
| commit | 50fc47e6e387c3b278526ef773badf63913389d6 (patch) | |
| tree | 71be9fa001ce6848e298bdabe400eb9dbd26848c /src/lib.ts | |
| parent | 559902e0211a06b349c4c2f50b0882a8d314f8b7 (diff) | |
Add settings modal
Add saving, loading, default vals, and device-detection, to store.ts.
Add setting for hiding minor tick labels.
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -5,8 +5,25 @@ import {RBTree} from './rbtree'; export const DEBUG = true; -export let WRITING_MODE_HORZ = true; +// For detecting screen size +export type Breakpoint = 'sm' | 'md' | 'lg'; +export function getBreakpoint(): Breakpoint { + const w = window.innerWidth; + if (w < 768){ + return 'sm'; + } else if (w < 1024){ + return 'md'; + } else { + return 'lg'; + } +} +// For detecting a touch device +export function onTouchDevice(){ + return window.matchMedia('(pointer: coarse)').matches; +} +// For detecting writing-mode // Used with ResizeObserver callbacks, to determine which resized dimensions are width and height +export let WRITING_MODE_HORZ = true; if ('writing-mode' in window.getComputedStyle(document.body)){ // Can be null when testing WRITING_MODE_HORZ = window.getComputedStyle(document.body)['writing-mode' as any].startsWith('horizontal'); } |
