1

Is there a simple way to check if a browser supports CSS Snap Points. I've set up a fail safe for a horizontal gallery but I'd like to turn off all the Javascript if the browser already natively supports snap points.

Also, are there any decent polyfills that might do a better job of what I've built here.

Walrus
  • 19,801
  • 35
  • 121
  • 199

1 Answers1

2

Try checking document.body style for "scroll-snap-type" property

  if ("scroll-snap-type" in document.body.style) {
    // do stuff with `scroll-snap-points`
  } else {
    // `scroll-snap-points` not supported
  }
guest271314
  • 1
  • 15
  • 104
  • 177