# blockenberg/2.0.7/blocks/text-highlight/frontend.js

Blockenberg — 600+ Advanced Gutenberg Blocks &amp; AI Agent for WordPress Block Editor, version 2.0.7. 74 lines.

- Page: https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/text-highlight/frontend.js
- Raw: https://pluginprobe.com/plugins/blockenberg/2.0.7/raw/blocks/text-highlight/frontend.js
- Modified: 2026-03-06T12:32:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/text-highlight/frontend.js#L10-L20`.

```javascript
(function () {
    'use strict';

    function reducedMotion() {
        return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    }

    function revealMarks(marks) {
        marks.forEach(function (mark, i) {
            // Delay staggered by index using CSS-custom-property delay set inline
            var delay = parseFloat(mark.dataset.bkthI || 0) * parseFloat(getComputedStyle(mark.closest('[data-threshold]') || document.documentElement).getPropertyValue('--bkth-hl-delay') || 80);
            setTimeout(function () {
                mark.classList.add('bkth-revealed');
            }, delay);
        });
    }

    function hideMarks(marks) {
        marks.forEach(function (mark) {
            mark.classList.remove('bkth-revealed');
        });
    }

    function initBlock(wrap) {
        if (wrap.dataset.animate !== '1') {
            // Static: reveal immediately
            wrap.querySelectorAll('.bkth-hl.bkth-animate').forEach(function (m) {
                m.classList.add('bkth-revealed');
            });
            return;
        }

        var marks = Array.prototype.slice.call(wrap.querySelectorAll('.bkth-hl.bkth-animate'));
        if (!marks.length) return;

        if (reducedMotion()) {
            marks.forEach(function (m) { m.classList.add('bkth-revealed'); });
            return;
        }

        var threshold = parseFloat(wrap.dataset.threshold) || 0.2;
        var repeat    = wrap.dataset.repeat === '1';

        var observer = new IntersectionObserver(function (entries) {
            entries.forEach(function (entry) {
                if (entry.isIntersecting) {
                    revealMarks(marks);
                    if (!repeat) observer.unobserve(wrap);
                } else if (repeat) {
                    hideMarks(marks);
                }
            });
        }, { threshold: threshold });

        observer.observe(wrap);
    }

    function init() {
        document.querySelectorAll('.bkth-wrap').forEach(initBlock);
    }

    if (typeof IntersectionObserver === 'undefined') {
        document.querySelectorAll('.bkth-hl').forEach(function (m) { m.classList.add('bkth-revealed'); });
        return;
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }

}());

```
