javascript - jQuery 监控链接以查看它们是否悬停,如果它们上升 3 个父级并添加 css/class
问题描述
我的页面上有很多链接,其 HTML 格式为:
<div class="heading-column">
<div class="heading-container">
<h2 class="heading-item">
<a href="/find/">Find</h2>
</div>
</div>
</div>
目前我们有一些动画在它们悬停在heading-column
元素上时发生,但它们实际上应该只在悬停在a
超链接上时发生。
我试图弄清楚如何创建一些 jQuery 来监视所有超链接,如果一个具有类的超链接.heading-item a
悬停在它上面以.heading-column
通过添加 css 来更新其父级 3 更高(),pointer-events: auto;
但只要鼠标停止悬停,应删除此 CSS 规则,以便pointer-events: none;
停止.heading-column
动画/悬停发生
我非常感谢一些帮助
解决方案
看看这是否有帮助 -
const tl = gsap.timeline({paused: true});
tl.from(
".gsap-swipe",
{
y: 20,
x: 20,
rotate: -40,
duration: 3,
transformOrigin: '30% 80%',
ease: Elastic.easeOut.config(1, 0.5),
}, 0
)
.fromTo(
".swipe",
{
xPercent: -100
},
{
duration: 1,
xPercent: 100,
ease: Sine.easeInOut,
stagger: {
each: 0.15
}
}, 0
)
.from(
".maskSwipe",
{
xPercent: -100,
ease: Sine.easeInOut
},
0.4
)
.from(
"#hello",
{
duration: 1.5,
drawSVG: "0%"
},
1
)
.from(
".swoop",
{
duration: 2,
drawSVG: "0%"
},
1
)
.from(
".line",
{
drawSVG: "0%",
duration: 0.5,
stagger: {
each: 0.2
}
},
1
)
.from(
".shape",
{
scale: 0,
duration: 1.3,
transformOrigin: "50% 50%",
rotate: '+=random(-60, 60)',
ease: Elastic.easeOut.config(1, 0.8),
stagger: {
each: 0.2
}
},
0.2
);
// ScrubGSAPTimeline(tl);
let hover = document.querySelector('.js-hover');
hover.addEventListener('mouseover', playTl);
hover.addEventListener('mouseout', resetTl);
function playTl(){
tl.timeScale(1.25).restart();
}
function resetTl(){
tl.progress(0).pause();
}
推荐阅读
- java - java.lang.IllegalStateException:应为 BEGIN_ARRAY 但为 BEGIN_OBJECT Android 错误
- react-native - React 原生多列 FlatList 插入横幅
- r - 如何重塑数据框并将新变量添加到数据框中
- html - 动画 CSS 渐变仅在文本不换行时才有效
- php - Laravel 对所有模型的自定义验证
- reactjs - 如何改变页面,只改变一个组件,而不是整个html
- java - 尝试通过 JSTL 表单标签提交表单时收到错误“bean 类的无效属性 'xxx'”
- python - 每次元素更改时如何获取新列表(该元素是元组列表中每个元组的某个索引)
- google-cloud-datastore - 是否应该编写实体以确保不重用自动分配的 ID?
- javascript - 渲染后如何根据状态切换子组件?