当前位置:网站首页>Local page floating animation is realized with the help of scroll wheel
Local page floating animation is realized with the help of scroll wheel
2022-06-30 01:44:00 【qq_ thirty-nine million six hundred and seventy thousand and tw】
float.css
.show-float {
opacity: 0.5;
position:relative;
margin-top: 80px;
}
.show-animate {
animation: showanimate 2s forwards;
}
@keyframes showanimate {
100% {
opacity: 1;
/* margin-top: 0px; */
}
from {bottom:0px;}
to {bottom:50px;}
}
.hide-animate {
/* margin-top: 0px; */
opacity: 1;
margin-top: 80px;
/* animation: hideanimate 2s forwards; */
}
@keyframes hideanimate {
100% {
opacity: 0.5;
margin-top: 50px;
}
}float.js
(function (global) {
"use strict";
let w_height = window.innerHeight;
$(document).on("mousewheel DOMMouseScroll", onMouseScroll);
function onMouseScroll(e) {
e.preventDefault();
var wheel = e.originalEvent.wheelDelta || -e.originalEvent.detail;
var delta = Math.max(-1, Math.min(1, wheel));
let t = document.documentElement.scrollTop;
let dis_height_t = w_height + t;
if (delta < 0) {
// Scroll down
$(".show-float").each(function (index, element) {
let t_h = $(element).offset().top;
if (t_h < dis_height_t + w_height / 4) {
// debugger;
$(element).removeClass("hide-animate");
$(element).addClass("show-animate");
}
});
} else {
// Scroll up
$(".show-float").each(function (index, element) {
let t_h = $(element).offset().top;
if (t_h > dis_height_t - w_height / 2) {
$(element).removeClass("show-animate");
$(element).addClass("hide-animate");
}
});
}
}
})(this);
After importing resources , add to 'show-float' class
<div class="product-section product-features show-float" id="huodong"></div>边栏推荐
- Internal class usage scenarios, syntax and principle explanations
- C语言 说反话
- ctfshow 大赛原题 680-695
- js内容混淆,返回内容加密
- win10子系统 WSL如果root和其他用户的密码都忘记的修复方法
- 假离婚变成真离婚,财产怎么办
- JS prototype and prototype chain (Lantern Festival meal)
- AI landing manufacturing: intelligent robots should have these four abilities
- Mobaihe cm201-2-ch-hi3798mv300-300h-emmc and NAND_ Infrared Bluetooth voice_ Brush firmware package
- Derivation of univariate polynomial in C language
猜你喜欢

首届·技术播客月开播在即

Want to change careers, but don't know what you want to do?

ctfshow 大赛原题 680-695

Conjecture of prime pairs in C language

C language continues (3n+1) conjecture
![[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network](/img/5f/b23b64eed7f28ffd92c122b6859e2d.png)
[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network

Cub school learning: manual query and ADC in-depth use

Chiffrement des cookies 8

Is the processor the main factor in buying a mobile phone?

Ansible ad-hoc 临时命令
随机推荐
Cookie encryption 8
Want to change careers, but don't know what you want to do?
当大学毕业感到迷茫怎么办?
What should I do when I feel confused after graduation from university?
Seata 与三大平台携手编程之夏,百万奖金等你来拿
Ctfshow competition original title 680-695
Geotools: common tools for mutual conversion of wkt, geojason, feature and featurecollection
Module import reload method
JS reverse request parameter encryption:
js Array.from()的5个便捷应用
Pytorch中transforms的用法整理
How to deal with occasional bugs?
JS prototype and prototype chain (Lantern Festival meal)
What should be paid attention to in the design and production of the Urban Planning Museum
C语言 数素数
What is idempotency? Detailed explanation of four interface idempotence schemes!
Cookie encryption 15 login encryption
js返回内容被unicode编码
cookie加密8
[graph neural network] summary of graph classification study [3]: evaluation of graph classification methods and future research directions