import Vue from 'vue'
function handleStopScroll (e) {
let el = e.currentTarget
let scrollTop = el.scrollTop
let scrollHeight = el.scrollHeight
let height = el.clientHeight
let delta = (e.wheelDelta) ? e.wheelDelta : -(e.detail || 0)
console.log(scrollTop, scrollHeight, height, delta)
if ((delta > 0 && scrollTop <= delta) ||
(delta < 0 && scrollHeight - height - scrollTop <= -1 * delta)) {
el.scrollTop = delta > 0 ? 0 : scrollHeight
event.preventDefault()
}
}
let eventType = 'mousewheel'
if (window.document.mozHidden !== undefined) {
eventType = 'DOMMouseScroll'
}
Vue.directive('stop-scroll', {
bind () {
this.el.addEventListener(eventType, handleStopScroll, false)
},
unbind () {
this.el.removeEventListener(eventType, handleStopScroll)
}
})