当前位置:网站首页>一文读懂鼠标滚轮事件(wheelEvent)
一文读懂鼠标滚轮事件(wheelEvent)
2022-07-27 14:24:00 【讲礼貌】
https://segmentfault.com/a/1190000017390159?utm_source=tag-newest
<template>
<el-scrollbar
ref="scrollContainer"
:vertical="false"
class="scroll-container"
@wheel.native.prevent="handleScroll"
>
<slot/>
</el-scrollbar>
</template>
<script>
export default {
name: "ScrollPane",
data() {
return {
left: 0
};
},
methods: {
handleScroll(e) {
// wheelDelta:获取滚轮滚动方向,向上120,向下-120,但为常量,与滚轮速率无关
// deltaY:垂直滚动幅度,正值向下滚动。电脑鼠标滚轮垂直行数默认值是3
// wheelDelta只有部分浏览器支持,deltaY几乎所有浏览器都支持
const eventDelta = e.wheelDelta || -e.deltaY * 40;
const $scrollWrapper = this.$refs.scrollContainer.$refs.wrap;
// 0到scrollLeft为滚动区域隐藏部分
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4;
}
}
};
</script>
边栏推荐
- Kubernetes CNI classification / operation mechanism
- Inside router of network equipment hard core technology (10) disassembly of Cisco asr9900 (4)
- Is it safe to open an account on a mobile phone?
- lua学习笔记
- Network equipment hard core technology insider router Chapter 9 Cisco asr9900 disassembly (II)
- 光电隔离电路设计方案(六款基于光耦、AD210AN的光电隔离电路图)
- Zhou Hongyi: if the digital security ability is backward, it will also be beaten
- Leetcode-1737- minimum number of characters to change if one of the three conditions is met
- Design scheme of digital oscilloscope based on stm32
- Singles cup, web:web check in
猜你喜欢

EMC design scheme of CAN bus

IJCAI 2022 outstanding papers were published, and 298 Chinese mainland authors won the first place in two items

谷粒商城配置CorsWebFilter后,报错:Resource sharing error:MultipleAllowOriginValues

Leetcode 190. reverse binary bit operation /easy

What is the breakthrough point of digital transformation in the electronic manufacturing industry? Lean manufacturing is the key

Basic usage of kotlin

Tools - common methods of markdown editor

generic paradigm

STM32 CAN 通信 滤波设置问题

ADB command (install APK package format: ADB install APK address package name on the computer)
随机推荐
3.3-5v conversion
魔塔项目中的问题解决
Several basic uses of tl431-2.5v voltage reference chip
The mobile terminal uses the list component of vantui. When multiple tab items are switched back and forth, the list is loaded many times, resulting in the failure of normal display of data
What is the breakthrough point of digital transformation in the electronic manufacturing industry? Lean manufacturing is the key
Internship: compilation of other configuration classes
Tools - common methods of markdown editor
Leetcode 190. reverse binary bit operation /easy
MySQL interview 40 consecutive questions, interviewer, if you continue to ask, I will turn my face
/dev/loop1占用100%问题
STM32 can -- can ID filter analysis
初探JuiceFS
Notice of Shenzhen Municipal Bureau of human resources and social security on the issuance of employment related subsidies for people out of poverty
STM32F10x_ Hardware I2C read / write EEPROM (standard peripheral library version)
STM32 can communication filter setting problem
Huayun data creates a perfect information technology and innovation talent training system to help the high-quality development of information technology and innovation industry
Unity性能优化------渲染优化(GPU)之LOD(Level of detail)
Notice on printing and distributing the Interim Measures for the administration of green manufacturing pilot demonstration of Shenzhen Bureau of industry and information technology
The reverse order pairs in the "sword finger offer" array
Two stage submission and three stage submission