mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Thank you @vbelolapotkov for pointing out the flaws here: https://github.com/Human-Connection/Human-Connection/pull/1756#discussion_r329361572 So here is my attempt to fix it: * Install `vue-scrollto` which relies on `requestAnimationFrame` - apparently this is better on Safari and IE? 🤔 - Mocking out entire modules is easier in jest: https://jestjs.io/docs/en/bypassing-module-mocks * Require `checkAnchor` to be implemented on the component
21 lines
431 B
JavaScript
21 lines
431 B
JavaScript
import { scrollTo } from 'vue-scrollto'
|
|
|
|
export default {
|
|
watch: {
|
|
$route(to, from) {
|
|
const anchor = to && to.hash
|
|
if (!this.checkAnchor(anchor)) return
|
|
setTimeout(() => {
|
|
scrollTo(anchor, 1000)
|
|
}, 250)
|
|
},
|
|
},
|
|
mounted() {
|
|
const anchor = this.$route && this.$route.hash
|
|
if (!this.checkAnchor(anchor)) return
|
|
setTimeout(() => {
|
|
scrollTo(anchor, 1000)
|
|
}, 250)
|
|
},
|
|
}
|