-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (61 loc) · 1.76 KB
/
Copy pathscript.js
File metadata and controls
68 lines (61 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 加载动画控制
window.addEventListener('load', function() {
// 隐藏加载动画
gsap.to('.loader', {
opacity: 0,
duration: 0.8,
onComplete: () => document.querySelector('.loader').remove()
});
// 导航栏项动画
gsap.from('nav ul li', {
duration: 1,
opacity: 0,
y: 20,
stagger: 0.2,
ease: 'power4.out'
});
// 主体内容序列动画
gsap.from('main section', {
duration: 1,
opacity: 0,
y: 50,
stagger: 0.3,
ease: 'elastic.out(1, 0.5)',
delay: 0.5
});
});
// 在空闲时段执行非关键任务
window.requestIdleCallback(() => {
initAnalytics();
preloadSecondaryImages();
});
// 视差滚动效果
window.addEventListener('scroll', function () {
const scrolled = window.pageYOffset;
document.querySelectorAll('.parallax').forEach(el => {
const speed = parseFloat(el.dataset.speed) || 0.5;
el.style.transform = `translateY(${scrolled * speed}px)`;
});
});
const features = document.querySelectorAll('.fade-in');
function fadeInFeatures() {
features.forEach(function (feature) {
const rect = feature.getBoundingClientRect();
if (rect.top < window.innerHeight - 100) {
feature.classList.add('visible');
}
});
}
window.addEventListener('scroll', fadeInFeatures);
fadeInFeatures();
setInterval(function () {
var startTime = performance.now();
// 堆代码 duidaima.com
// 设置断点
debugger;
var endTime = performance.now();
// 设置一个阈值,例如100毫秒
if (endTime - startTime > 100) {
window.location.href = 'about:blank';
}
}, 100);