From 50fc47e6e387c3b278526ef773badf63913389d6 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Fri, 6 Jan 2023 16:59:54 +1100 Subject: Add settings modal Add saving, loading, default vals, and device-detection, to store.ts. Add setting for hiding minor tick labels. --- src/lib.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/lib.ts') diff --git a/src/lib.ts b/src/lib.ts index d26c8df..3b0bc68 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -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'); } -- cgit v1.2.3