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

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

42 lines 1.5 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 // Chat Bubbles — animate messages into view on scroll
5 function initChatBubbles() {
6 var containers = document.querySelectorAll('.bkbg-chat-container');
7 if (!containers.length) return;
8
9 if (!('IntersectionObserver' in window)) return;
10
11 var obs = new IntersectionObserver(function (entries) {
12 entries.forEach(function (entry) {
13 if (!entry.isIntersecting) return;
14 var messages = entry.target.querySelectorAll('.bkbg-chat-msg');
15 messages.forEach(function (msg, idx) {
16 setTimeout(function () {
17 msg.style.opacity = '1';
18 msg.style.transform = 'translateY(0)';
19 }, idx * 80);
20 });
21 obs.unobserve(entry.target);
22 });
23 }, { threshold: 0.15 });
24
25 containers.forEach(function (container) {
26 var messages = container.querySelectorAll('.bkbg-chat-msg');
27 messages.forEach(function (msg) {
28 msg.style.opacity = '0';
29 msg.style.transform = 'translateY(16px)';
30 msg.style.transition = 'opacity 0.35s ease, transform 0.35s ease';
31 });
32 obs.observe(container);
33 });
34 }
35
36 if (document.readyState === 'loading') {
37 document.addEventListener('DOMContentLoaded', initChatBubbles);
38 } else {
39 initChatBubbles();
40 }
41 }());
42