Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
hover-seconds-do
Advanced tools
Readme
在某些场景,我们希望鼠标移到某个元素上,悬停几秒后能执行一些操作,但是鼠标稍微移动一下,时间重置,状态回退如初。在鼠标离开当前绑定的元素时,我们的页面回退如初。这个工具函数一定能帮到你。
播放器一个很重要的功能:**鼠标悬停在视频播放界面时,在一定时间后鼠标会消失,视频下方的控制栏也会隐藏,呈现视频的最大可视化。但是鼠标稍微一动,一切恢复如初。**用一张简单的 gif 图来说明的话,是下面这样子的:
npm install --save hover-seconds-do
const hoversd = new window.HoverSD(element, secondsLaterDoFn, seconds, reNormalFn);
hoversd.secondsHoverEX();
// ...
// other code here
// ...
hoversd.removeElemEventListener();
在终端一步一步执行:
git clone git@github.com:vortesnail/hover-seconds-do.git
npm install -g http-server
npm run example
即可查看样例
我们拿上面的 gif 做例子:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>example</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="box">我是视频
<div class="test-box">我是视频控制栏</div>
</div>
<script src="./index.js"></script>
</body>
</html>
index.css
.box {
width: 400px;
height: 200px;
background-color: lightskyblue;
text-align: center;
line-height: 200px;
color: #fff;
position: relative;
/* cursor: none; */
}
.box .test-box {
position: absolute;
width: 100%;
height: 30px;
left: 0;
bottom: 0;
background-color:lightgray;
text-align: center;
line-height: 30px;
}
index.js
let box = document.querySelector('.box');
function hiddenTestBox() {
let textBox = document.querySelector('.test-box');
textBox.style.display = 'none';
box.style.cursor = 'none';
}
function showTestBox() {
let textBox = document.querySelector('.test-box');
textBox.style.display = 'block';
box.style.cursor = 'default';
}
let hoversd = new window.HoverSD(box, hiddenTestBox, 2000, showTestBox);
hoversd.secondsHoverEX();
// hoversd.removeElemEventListener();
MIT
FAQs
Perform an action after an element has hovered for a few seconds
We found that hover-seconds-do demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).