PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.11
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.11
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 / portfolio-grid / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.11, at blocks/portfolio-grid/frontend.js

47 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 wp.domReady(function () {
2 /* ── Filter ─────────────────────────────────────────────────────────────── */
3 document.querySelectorAll('.bkbg-pg-wrapper').forEach(function (wrapper) {
4 var filterBtns = wrapper.querySelectorAll('.bkbg-pg-filter-btn');
5 var cards = wrapper.querySelectorAll('.bkbg-pg-card');
6
7 filterBtns.forEach(function (btn) {
8 btn.addEventListener('click', function () {
9 var filter = btn.getAttribute('data-filter');
10
11 filterBtns.forEach(function (b) { b.classList.remove('is-active'); });
12 btn.classList.add('is-active');
13
14 cards.forEach(function (card) {
15 if (filter === '*') {
16 card.classList.remove('bkbg-pg-hidden');
17 } else {
18 var cat = card.getAttribute('data-category') || '';
19 if (cat === filter) {
20 card.classList.remove('bkbg-pg-hidden');
21 } else {
22 card.classList.add('bkbg-pg-hidden');
23 }
24 }
25 });
26 });
27 });
28
29 /* ── Animate on scroll ──────────────────────────────────────────────── */
30 var animCards = wrapper.querySelectorAll('.bkbg-pg-anim');
31 if (!animCards.length) return;
32
33 var io = new IntersectionObserver(function (entries) {
34 entries.forEach(function (entry, idx) {
35 if (entry.isIntersecting) {
36 setTimeout(function () {
37 entry.target.classList.add('bkbg-pg-visible');
38 }, idx * 80);
39 io.unobserve(entry.target);
40 }
41 });
42 }, { threshold: 0.1 });
43
44 animCards.forEach(function (card) { io.observe(card); });
45 });
46 });
47