PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
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 / funnel-chart / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/funnel-chart/frontend.js

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 function animateFunnel(wrap) {
3 var stages = wrap.querySelectorAll('.bkbg-fn-stage-bar');
4 stages.forEach(function (stage) {
5 var targetWidth = stage.dataset.targetWidth;
6 if (!targetWidth) return;
7 stage.style.width = '0%';
8 stage.style.opacity = '0';
9 stage.style.transition = 'none';
10 requestAnimationFrame(function () {
11 requestAnimationFrame(function () {
12 stage.style.transition = 'width 0.55s cubic-bezier(0.25,0.8,0.25,1), opacity 0.3s';
13 stage.style.width = targetWidth;
14 stage.style.opacity = '1';
15 });
16 });
17 });
18 }
19
20 function init() {
21 var wraps = document.querySelectorAll('.bkbg-fn-card');
22 if (!wraps.length) return;
23
24 var observer = new IntersectionObserver(function (entries) {
25 entries.forEach(function (entry) {
26 if (!entry.isIntersecting) return;
27 animateFunnel(entry.target);
28 observer.unobserve(entry.target);
29 });
30 }, { threshold: 0.15 });
31
32 wraps.forEach(function (wrap) {
33 /* Prepare target widths from inline style, then reset to 0 for animation */
34 var stages = wrap.querySelectorAll('.bkbg-fn-stage-bar');
35 stages.forEach(function (stage) {
36 var currentW = stage.style.width || '100%';
37 stage.dataset.targetWidth = currentW;
38 stage.style.width = '0%';
39 stage.style.opacity = '0';
40 });
41 observer.observe(wrap);
42 });
43 }
44
45 if (document.readyState === 'loading') {
46 document.addEventListener('DOMContentLoaded', init);
47 } else {
48 init();
49 }
50 })();
51