Skip to content

Commit

Permalink
Merge pull request #59 from sunwrobert/robert/patch
Browse files Browse the repository at this point in the history
chore: add more defensive checks on global usage
  • Loading branch information
barvian authored Nov 12, 2024
2 parents 3f7418a + 13a66fb commit d4e4302
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/tasty-cycles-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'number-flow': patch
'@number-flow/react': patch
'@number-flow/svelte': patch
'@number-flow/vue': patch
---

More defensive checks on browser globals (see #58)
10 changes: 7 additions & 3 deletions packages/number-flow/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { BROWSER } from './util/env'
import { css } from './util/css'

export const supportsLinear =
BROWSER && typeof CSS !== 'undefined' && CSS.supports('animation-timing-function', 'linear(1,2)')
BROWSER &&
typeof CSS !== 'undefined' &&
CSS.supports &&
CSS.supports('animation-timing-function', 'linear(1,2)')

export const supportsMod =
BROWSER && typeof CSS !== 'undefined' && CSS.supports('line-height', 'mod(1,1)')
BROWSER && typeof CSS !== 'undefined' && CSS.supports && CSS.supports('line-height', 'mod(1,1)')

export const prefersReducedMotion = BROWSER ? matchMedia('(prefers-reduced-motion: reduce)') : null
export const prefersReducedMotion =
BROWSER && matchMedia ? matchMedia('(prefers-reduced-motion: reduce)') : null

// Register animated vars:
export const opacityDeltaVar = '--_number-flow-d-opacity'
Expand Down

0 comments on commit d4e4302

Please sign in to comment.