Skip to content

feat: add Embla initialization hooks#145

Open
sunmorgn wants to merge 1 commit into
rtCamp:developfrom
sunmorgn:codex/embla-init-filters
Open

feat: add Embla initialization hooks#145
sunmorgn wants to merge 1 commit into
rtCamp:developfrom
sunmorgn:codex/embla-init-filters

Conversation

@sunmorgn
Copy link
Copy Markdown

@sunmorgn sunmorgn commented May 19, 2026

Summary

Adds stable JavaScript hooks around rtCarousel's Embla initialization so projects can adjust Embla options, append Embla plugins, and access the initialized Embla API for methods and events without forking the plugin.

Type of change

  • Bug fix
  • New feature
  • Enhancement/refactor
  • Documentation update
  • Test update
  • Build/CI/tooling

Related issue(s)

Closes #144

What changed

  • Added rtcamp.carouselKit.emblaOptions to filter the options passed to EmblaCarousel.
  • Added rtcamp.carouselKit.emblaPlugins to filter the Embla plugin array after the built-in Autoplay plugin is configured.
  • Added rtcamp.carouselKit.emblaInit so integrations can call Embla methods or subscribe to Embla events after initialization.
  • Added API documentation and unit test coverage for the extension hooks.

Breaking changes

Does this introduce a breaking change? If yes, describe the impact and migration path below.

  • Yes — migration path:
  • No

Testing

Describe how this was tested.

  • Unit tests
  • Manual testing - tested numerous previously unavailable options and all official and up-to-date third-party plugins.
  • Cross-browser testing (if UI changes)

Test details:

  • npm run lint:js
  • npm run lint:js:types
  • npm run test:js -- --runTestsByPath src/blocks/carousel/__tests__/view.test.ts
  • npm run build
  • Manually tested in a local WordPress install by adding site-level filters/actions for Embla options, plugins, methods, and events, including Auto Height, Auto Scroll, Class Names, Fade, Wheel Gestures, and A11y.

Screenshots / recordings

Not applicable; this change exposes developer extension hooks and does not alter saved markup or default carousel behavior.

Checklist

  • I have self-reviewed this PR
  • I have added/updated tests where needed
  • I have updated docs where needed
  • I have checked for breaking changes

@sunmorgn sunmorgn marked this pull request as ready for review May 19, 2026 17:16
@sunmorgn sunmorgn force-pushed the codex/embla-init-filters branch from 2d40494 to 1a0dd9c Compare May 19, 2026 17:28
@sunmorgn sunmorgn changed the title feat: add Embla initialization filters feat: add Embla initialization hooks May 19, 2026
@sunmorgn
Copy link
Copy Markdown
Author

Additional local manual test after adding rtcamp.carouselKit.emblaInit:

  • Updated a local WordPress test install to use the PR build.
  • Registered a site-level addAction( "rtcamp.carouselKit.emblaInit", ... ) listener from the active theme.
  • Confirmed the action fired for 15 carousel initializations on a page containing multiple carousel variants.
  • Confirmed the callback receives the Embla API instance plus the expected context object, and can call methods such as selectedScrollSnap(), canScrollPrev(), and canScrollNext().
  • No browser console errors were reported during the test.

@sunmorgn
Copy link
Copy Markdown
Author

Additional local test using WordPress block-style classes:

  • Switched the local theme integration from temporary has-embla-* classes to is-style-* block style classes.
  • Confirmed is-style-auto-height triggers the theme-level rtcamp.carouselKit.emblaPlugins filter and loads the autoHeight Embla plugin.
  • Confirmed the Auto Height carousel container updates height between slides (201px to 267px) after navigation.
  • Confirmed no old has-embla-* classes remain on the test page and no browser console errors were reported.

This keeps the PR API compatible with normal WordPress block style workflows.

@sunmorgn sunmorgn force-pushed the codex/embla-init-filters branch from a55530e to 1a0dd9c Compare May 20, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add filters for extending Embla Carousel options and plugins

1 participant