UNPKG

yyzone

Version:

yyzone vue components and utils

35 lines 1 kB
import PerfectScrollbar from 'perfect-scrollbar' export default { data() { return { scroll: null, container: null, scrollTop: 0 } }, methods: { setContentScroll() { this.container = this.$refs.scrollContent this.scroll = new PerfectScrollbar(this.container, { wheelSpeed: 0.5, wheelPropagation: false, useBothWheelAxes: true, minScrollbarLength: 60, maxScrollbarLength: 300 }) this.container.addEventListener('ps-scroll-y', (e) => { this.scrollTop = e && e.target && e.target.scrollTop }) }, updateScroll() { this.container.scrollTop = 0 this.scroll.update() } }, mounted () { this.setContentScroll(this.$refs.scrollContent) }, activated () { this.container.scrollTop = this.scrollTop } }