Marquee
Overview
A horizontally scrolling text ticker: one line of text, repeated with a separator between the copies, scrolling continuously across the block at a constant speed. Called “Looping Alert” during development, which the block name and directory keep; the inserter calls it Marquee.
- Block name:
method/looping-alert - Title: Marquee (Method)
- Category:
method-component-blocks - Supports:
align(wide, full);htmloff - Render type: Dynamic (PHP
render_callback:render_method_looping_alert_block()) - Inner blocks: No
- Scripts:
editorScript(index.js) andviewScript(frontend.js) - Source: lib/blocks/method-looping-alert/method-looping-alert.php, lib/blocks/method-looping-alert/src/edit.js, lib/blocks/method-looping-alert/src/frontend.js, lib/blocks/method-looping-alert/src/marquee.js
Usage
Set the Alert Text, the Seperator that sits between copies, and a Scroll Speed from 0 to 100. Speed is a rate, not a duration: each unit is 3px per second (the default 25 is 75px/s, 100 is 300px/s), so the scroll looks the same however long the text or wide the block; 0 pauses the marquee. The block toolbar’s link control wraps the whole marquee in a link (with open-in-new-tab). Typography — font family, appearance, size, letter case, letter spacing — plus top/bottom padding and margin, border and radius, are all per breakpoint.
The editor preview and the page share the same measuring and timing code (src/marquee.js), so what the canvas shows is what scrolls. Under prefers-reduced-motion: reduce the animation is switched off and the text stands still.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
alertText | string | "Run for the hills!" | The text that scrolls. |
seperator | string | "-" | Text between copies of the alert text. The stored key is spelled seperator, as is the panel label. |
speed | number | 25 | Scroll speed, 0–100, clamped on render. Printed as data-speed; the view script turns it into pixels per second. |
link | object | — | { url, opensInNewTab } from MethodLinkToolbar. With a url the wrapper is an <a> instead of a <div>. |
textColor | string | — | Text color, on the wrapper and on the inner element. |
bgColor | string | — | Background color of the inner element. |
bgGradient | string | — | Background gradient of the inner element. |
linkColor | string | — | Declared in block.json but offered by no control and read by no CSS map — stored only. |
bgShadeColor | string | — | Offered as Background Shade once a link is set, but the render callback’s CSS map does not read it and the markup has no shade element, so it has no effect on the page today. |
bgShadeGradient | string | — | As above. |
responsiveSettings | object | {"base":{"enabled":true},…} | Per-tier spacing, border and typography; see below. New blocks seed customBg: false in the mobile, tablet and wide tiers. |
responsiveSettings Structure
Per-tier settings live under responsiveSettings.base, mobile, tablet and wide. A tier is only read while its enabled flag is true; base is always on. The keys this block’s CSS map reads:
margin.top,margin.bottom— on the wrapper.padding.top,padding.bottom— on.method-looping-alert-inner.border,borderRadius— on.method-looping-alert-inner.fontFamily,fontSize,fontStyle,fontWeight,textTransform,letterSpacing— on.method-looping-alert-inner(MethodTypographyControlswrites appearance asfontStyle+fontWeight).
Control Sets
| Component | Panel | Breakpoints | Notes |
|---|---|---|---|
| Block panel: Alert Options | Alert Options | base | Alert Text, Seperator (TextControls), Scroll Speed (RangeControl, 0–100). |
MethodLinkToolbar | Block toolbar | base | Writes link. |
MethodSpacingControls | Spacing | base + mobile / tablet / wide | include={['padding', 'margin']}, top and bottom of each. |
MethodBorderControls | Border | base + mobile / tablet / wide | Border and radius. |
MethodTypographyControls | Typography | base + mobile / tablet / wide | include={['fontFamily', 'fontAppearance', 'fontSize', 'textTransform', 'letterSpacing']} |
MethodColorControls | Color Settings | base | include={['textColor', 'bgColor']}, with bgShadeColor added while a link is set. |
MethodResponsiveTabs | Mobile / Tablet / Ultrawide | mobile, tablet, wide | Spacing, border and typography per tier. |
MethodStyleTag | — | all | Mirrors $cssargs; when the block is linked it also colors a#block-{clientId}. |
Data & Dependencies
src/marquee.js— the shared math:PX_PER_SECOND_PER_UNIT = 3,clampSpeed(),getPxPerSecond(),getRepeatCount( unitWidth, containerWidth )(enough copies to fill the container, plus one so the seam is never visible) andgetDurationSeconds( groupWidth, speed ). Used by the view script and by the editor preview (src/LoopingAlertMarquee.js).- View script (lib/blocks/method-looping-alert/src/frontend.js) — PHP prints one text + separator unit inside one group. The script measures the unit against the visible container, clones it to fill the width, then duplicates the whole group with
aria-hiddenso atranslateX(-50%)animation loops seamlessly, and sets--method-alert-durationon the track from the speed. It re-runs on container resize (ResizeObserver, with a cheap width check first) and once web fonts finish loading (document.fonts.ready). - Styles (assets/scss/global.scss) —
.method-looping-alert-innerisoverflow: hiddenwithcontain: inline-sizeso the very wide track can never feed back into the measured width;.method-looping-alert-trackanimates withmethod-looping-alert-scrollonce it hasis-ready, andis-paused(speed 0) orprefers-reduced-motion: reduceremoves the animation. Each unit is padded1emon both sides. - Responsive CSS:
method_get_block_responsive_styles()andmethod_collect_css()under#method-{id}; the link URL isesc_url()ed and the textesc_html()ed.
Frontend Rendering
What PHP prints (an unlinked block; with a link the outer div is an a with href and target):
<div class="wp-block-method-looping-alert method-looping-alert" id="method-68f1b2c3a4d5e" data-speed="25">
<div class="method-looping-alert-inner">
<p class="method-looping-alert-track">
<span class="method-looping-alert-group">
<span class="method-looping-alert-unit">
<span class="method-looping-alert-item">Run for the hills!</span>
<span class="method-looping-alert-sep">-</span>
</span>
</span>
</p>
</div>
</div>
What the view script makes of it:
<p class="method-looping-alert-track is-ready" style="--method-alert-duration: 12.4s;">
<span class="method-looping-alert-group">
<span class="method-looping-alert-unit">…</span>
<span class="method-looping-alert-unit">…</span>
<span class="method-looping-alert-unit">…</span> <!-- enough to fill the width, plus one -->
</span>
<span class="method-looping-alert-group" aria-hidden="true">
…identical copy…
</span>
</p>
Generated CSS (per instance): #method-{id} → margins and textColor; … > .method-looping-alert-inner → text and background color, radius, border, top/bottom padding and the typography properties.
Filters
This block exposes no PHP filters.
Changelog
| Version | Description |
|---|---|
| 2.0.0-beta17 | Introduced as “Method Marquee” (6da784d, on the foundation in 8db7ce9). |
| 2.0.0-beta22 | Retitled “Marquee (Method)” and given the method keyword (93e1fcf). |
| 2.0.0-beta31 | An SVG icon of its own (a ticker band) in place of the flag Dashicon, declared in index.js rather than block.json (cd6f63f). |