-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
84 lines (75 loc) · 3.21 KB
/
Copy pathscript.js
File metadata and controls
84 lines (75 loc) · 3.21 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* FlowAnchor Project Website - StyleAlign Style
*/
document.addEventListener('DOMContentLoaded', () => {
console.log('✅ FlowAnchor loaded');
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const href = this.getAttribute('href');
if (href !== '#' && href.length > 1) {
e.preventDefault();
const target = document.querySelector(href);
if (target) {
window.scrollTo({
top: target.offsetTop - 20,
behavior: 'smooth'
});
}
}
});
});
// BibTeX copy functionality
const bibtexBox = document.querySelector('.bibtex-box');
if (bibtexBox) {
bibtexBox.title = 'Click to copy BibTeX';
bibtexBox.addEventListener('click', () => {
const text = bibtexBox.querySelector('code').textContent;
navigator.clipboard.writeText(text).then(() => {
const originalBorder = bibtexBox.style.borderColor;
bibtexBox.style.borderColor = '#333';
bibtexBox.style.boxShadow = '0 0 0 2px rgba(0, 0, 0, 0.2)';
setTimeout(() => {
bibtexBox.style.borderColor = originalBorder;
bibtexBox.style.boxShadow = '';
}, 500);
}).catch(err => {
console.error('Copy failed:', err);
});
});
}
// Video comparison slider
const videoContainers = document.querySelectorAll('.video-compare-container');
videoContainers.forEach(container => {
const slider = container.querySelector('.video-slider');
const wrapper = container.querySelector('.video-foreground-wrapper');
const videoSrc = container.querySelector('.video-background');
const videoEdit = container.querySelector('.video-foreground');
const labels = container.querySelector('.video-labels');
const sourceLabel = labels.querySelector('.label-left');
const flowAnchorLabel = labels.querySelector('.label-right');
// Keep each label on the same visual layer as the video it describes.
wrapper.appendChild(sourceLabel);
container.insertBefore(flowAnchorLabel, wrapper);
labels.remove();
// The foreground is clipped by its wrapper, but must retain the full
// container width so the source video is never stretched while sliding.
const sizeForeground = () => {
videoEdit.style.width = container.clientWidth + 'px';
};
sizeForeground();
new ResizeObserver(sizeForeground).observe(container);
// Sync videos
const syncVideos = () => {
if (Math.abs(videoSrc.currentTime - videoEdit.currentTime) > 0.1) {
videoEdit.currentTime = videoSrc.currentTime;
}
};
videoSrc.addEventListener('timeupdate', syncVideos);
// Slider control
slider.addEventListener('input', (e) => {
const value = e.target.value;
wrapper.style.width = value + '%';
});
});
});