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 / skills / frontend.js

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

55 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 'use strict';
3
4 function animateSkills() {
5 var wraps = document.querySelectorAll('.bkbg-skills[data-animate="1"]');
6 if (!wraps.length) return;
7
8 /* -- bars -- */
9 var bars = document.querySelectorAll('.bkbg-skills[data-animate="1"] .bkbg-skills-fill');
10 bars.forEach(function (el) { el.style.width = '0%'; });
11
12 /* -- circles -- */
13 var arcs = document.querySelectorAll('.bkbg-skills[data-animate="1"] .bkbg-skills-arc');
14 arcs.forEach(function (el) {
15 var circ = parseFloat(el.getAttribute('data-circ')) || 0;
16 el.style.strokeDashoffset = circ;
17 });
18
19 var io = new IntersectionObserver(function (entries) {
20 entries.forEach(function (entry) {
21 if (!entry.isIntersecting) return;
22 var wrap = entry.target;
23
24 /* animate bars within this wrap */
25 var wrapBars = wrap.querySelectorAll('.bkbg-skills-fill');
26 wrapBars.forEach(function (fill) {
27 var pct = parseFloat(fill.getAttribute('data-pct')) || 0;
28 fill.style.transition = 'width 0.9s ease';
29 fill.style.width = pct + '%';
30 });
31
32 /* animate circle arcs within this wrap */
33 var wrapArcs = wrap.querySelectorAll('.bkbg-skills-arc');
34 wrapArcs.forEach(function (arc) {
35 var pct = parseFloat(arc.getAttribute('data-pct')) || 0;
36 var circ = parseFloat(arc.getAttribute('data-circ')) || 0;
37 var target = circ - (pct / 100) * circ;
38 arc.style.transition = 'stroke-dashoffset 1.2s ease';
39 arc.style.strokeDashoffset = target;
40 });
41
42 io.unobserve(wrap);
43 });
44 }, { threshold: 0.2 });
45
46 wraps.forEach(function (wrap) { io.observe(wrap); });
47 }
48
49 if (document.readyState === 'loading') {
50 document.addEventListener('DOMContentLoaded', animateSkills);
51 } else {
52 animateSkills();
53 }
54 }());
55