vue-snap icon indicating copy to clipboard operation
vue-snap copied to clipboard

Safari scroll behavior isn't patched on SSR

Open jonathanmelville opened this issue 3 years ago • 2 comments

When using vue-snap with SSR in a Nuxt app, I noticed that the scroll behavior of Safari isn't smooth when using the arrow buttons. After doing some digging I see where the seamless-scroll-pollyfill is being included to pollyfill Safari, but it's being excluded from the SSR.

This makes sense as the pollyfill looks for the window object which won't exist on the server, but it raises the question what is the recommended way of patching Safari if you're using SSR? Would the right approach be to include the polyfill in the mounted() hook on the client side?

jonathanmelville avatar Jul 22 '21 12:07 jonathanmelville

If anybody else encounters this, this is how I resolved it:

<script lang="ts">

import Vue from 'vue'
import { elementScrollToPolyfill } from 'seamless-scroll-polyfill'

export default Vue.extend({
  mounted() {
    if (!('scrollBehavior' in document.documentElement.style)) {
      elementScrollToPolyfill()
    }
  },
})
</script>

jonathanmelville avatar Jul 22 '21 18:07 jonathanmelville

Is this plugin still under active development?

jonathanmelville avatar Aug 03 '21 14:08 jonathanmelville