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.


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

AttributeTypeDefaultDescription
alertTextstring"Run for the hills!"The text that scrolls.
seperatorstring"-"Text between copies of the alert text. The stored key is spelled seperator, as is the panel label.
speednumber25Scroll speed, 0–100, clamped on render. Printed as data-speed; the view script turns it into pixels per second.
linkobject—{ url, opensInNewTab } from MethodLinkToolbar. With a url the wrapper is an <a> instead of a <div>.
textColorstring—Text color, on the wrapper and on the inner element.
bgColorstring—Background color of the inner element.
bgGradientstring—Background gradient of the inner element.
linkColorstring—Declared in block.json but offered by no control and read by no CSS map — stored only.
bgShadeColorstring—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.
bgShadeGradientstring—As above.
responsiveSettingsobject{"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 (MethodTypographyControls writes appearance as fontStyle + fontWeight).

Control Sets

ComponentPanelBreakpointsNotes
Block panel: Alert OptionsAlert OptionsbaseAlert Text, Seperator (TextControls), Scroll Speed (RangeControl, 0–100).
MethodLinkToolbarBlock toolbarbaseWrites link.
MethodSpacingControlsSpacingbase + mobile / tablet / wideinclude={['padding', 'margin']}, top and bottom of each.
MethodBorderControlsBorderbase + mobile / tablet / wideBorder and radius.
MethodTypographyControlsTypographybase + mobile / tablet / wideinclude={['fontFamily', 'fontAppearance', 'fontSize', 'textTransform', 'letterSpacing']}
MethodColorControlsColor Settingsbaseinclude={['textColor', 'bgColor']}, with bgShadeColor added while a link is set.
MethodResponsiveTabsMobile / Tablet / Ultrawidemobile, tablet, wideSpacing, border and typography per tier.
MethodStyleTag—allMirrors $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) and getDurationSeconds( 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-hidden so a translateX(-50%) animation loops seamlessly, and sets --method-alert-duration on 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-inner is overflow: hidden with contain: inline-size so the very wide track can never feed back into the measured width; .method-looping-alert-track animates with method-looping-alert-scroll once it has is-ready, and is-paused (speed 0) or prefers-reduced-motion: reduce removes the animation. Each unit is padded 1em on both sides.
  • Responsive CSS: method_get_block_responsive_styles() and method_collect_css() under #method-{id}; the link URL is esc_url()ed and the text esc_html()ed.

Frontend Rendering

What PHP prints (an unlinked block; with a link the outer div is an a with href and target):

HTML
<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:

HTML
<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

VersionDescription
2.0.0-beta17Introduced as “Method Marquee” (6da784d, on the foundation in 8db7ce9).
2.0.0-beta22Retitled “Marquee (Method)” and given the method keyword (93e1fcf).
2.0.0-beta31An SVG icon of its own (a ticker band) in place of the flag Dashicon, declared in index.js rather than block.json (cd6f63f).