//监听滚轮时间
gun(e){
let wheelFlag = e.wheelDelta > 0 ? true : false
let oldWidth = this.$refs.mainMap.offsetWidth
let oldHeight = this.$refs.mainMap.offsetHeight
// 分别计算出scaleX,scaleY的倍数
let scaleX = e.offsetX / oldWidth
let scaleY = e.offsetY / oldHeight
if (wheelFlag) {
this.toBig()
} else {
this.toSmall()
}
// 鼠标为中心的开始点,如果去掉这个将会以左上角开始滚动图片
let newWidth = this.$refs.mainMap.offsetWidth
let newHeight = this.$refs.mainMap.offsetHeight
this.$refs.mainMap.style.left = this.$refs.mainMap.offsetLeft - scaleX * (newWidth - oldWidth) + 'px'
this.$refs.mainMap.style.top = this.$refs.mainMap.offsetTop - scaleY * (newHeight - oldHeight) + 'px'
}
根据鼠标位置进行缩放
最新推荐文章于 2023-12-29 14:29:22 发布