Motion Controls for Gutenberg Blocks

19

Block Motion is a Gutenberg plugin that adds animation controls to selected blocks, injecting data attributes into the HTML for smooth frontend rendering. It supports text animations, box/appear effects, parallax scrolling, and sticky positioning across core blocks like headings, columns, groups, and images. The lightweight implementation keeps markup clean while delivering dynamic animations through minimal CSS and a frontend JavaScript runtime.

Block Motion:

  • adds motion-related controls for selected blocks in the Gutenberg editor (via editor scripts)
  • injects corresponding data-* attributes into the rendered HTML output
  • loads minimal CSS + a frontend JS runtime to apply animations on the site
  • supports per-block options like:
    • text animation modes for headings
    • box/appear animations with delays
    • parallax animation with adjustable speed
    • sticky/fixed style flags
    • optional background/text color values as data attributes

The plugin is built to keep markup clean and implementation predictable: the block output remains standard HTML, and the motion behavior is driven by attributes.


Supported blocks (from the code)

Block Motion hooks into the render pipeline of these blocks and injects data attributes when the matching block attributes are present:

  • core/heading
  • core/column
  • core/group
  • core/image
  • core/columns
  • cb/wide (custom block name referenced in config)

Render-time attribute injection

For supported blocks, the plugin maps block attributes to HTML data-* attributes, for example:

  • Heading:
    • textAnimdata-text-anim
    • parallaxdata-parallax-anim
    • speeddata-parallax-speed
  • Column / Group:
    • boxAnimdata-box-anim
    • delaydata-box-anim-delay
    • bgColordata-bg-color
    • textColordata-text-color
    • parallaxdata-parallax-anim
    • speeddata-parallax-speed
    • (Column only) fixeddata-fixed
  • Columns:
    • appeardata-box-anim
    • stickydata-sticky

This approach allows the frontend script to apply effects without altering block structure or relying on additional wrappers.


Special heading handling (baseline mode)

When a Heading block has textAnim = baseline, the plugin wraps the heading text inside a <span>:

  • <h2>Title</h2> becomes <h2><span>Title</span></h2>

This is typically used for text animation techniques that require a dedicated inline wrapper.


Assets loaded

Editor (Block Editor)

The plugin loads block editor scripts that provide motion settings for blocks:

  • js/text-admin.js
  • js/box-admin.js
  • js/parallax-admin.js

Frontend

The plugin loads the required styles and runtime script:

  • css/box-anim.css
  • css/text-anim.css
  • css/parallax-anim.css
  • js/anim.js

There are no reviews yet.

Be the first to review “Motion Controls for Gutenberg Blocks”

Your email address will not be published. Required fields are marked *