PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.6
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.6
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / timeline / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.6, at blocks/timeline/frontend.js

61 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Timeline Block Frontend
3 * Handles scroll animations
4 */
5 (function() {
6 'use strict';
7
8 function initTimeline() {
9 var timelines = document.querySelectorAll('.bkbg-tl-wrap[data-animate="1"]');
10
11 if (!timelines.length) return;
12
13 // Check if IntersectionObserver is supported
14 if (!('IntersectionObserver' in window)) {
15 // Fallback: show all items immediately
16 timelines.forEach(function(timeline) {
17 var items = timeline.querySelectorAll('.bkbg-tl-item');
18 items.forEach(function(item) {
19 item.classList.add('is-visible');
20 });
21 });
22 return;
23 }
24
25 timelines.forEach(function(timeline) {
26 var items = timeline.querySelectorAll('.bkbg-tl-item');
27
28 var observer = new IntersectionObserver(function(entries) {
29 entries.forEach(function(entry) {
30 if (entry.isIntersecting) {
31 // Add staggered delay based on item index
32 var item = entry.target;
33 var index = Array.from(items).indexOf(item);
34
35 setTimeout(function() {
36 item.classList.add('is-visible');
37 }, index * 150);
38
39 // Stop observing once visible
40 observer.unobserve(item);
41 }
42 });
43 }, {
44 threshold: 0.2,
45 rootMargin: '0px 0px -50px 0px'
46 });
47
48 items.forEach(function(item) {
49 observer.observe(item);
50 });
51 });
52 }
53
54 // Initialize on DOM ready
55 if (document.readyState === 'loading') {
56 document.addEventListener('DOMContentLoaded', initTimeline);
57 } else {
58 initTimeline();
59 }
60 })();
61