Corex.Marquee
(Corex v0.1.0-alpha.33)
View Source
Phoenix implementation of Zag.js Marquee.
Examples
<.marquee
id="logos"
items={[%{name: "Apple", logo: "🍎"}, %{name: "Banana", logo: "🍌"}]}
duration={20}
spacing="2rem"
pause_on_interaction
>
<:item :let={%{item: item}}>
<span>{item.logo}</span>
<span>{item.name}</span>
</:item>
</.marquee>Styling
Target elements via data attributes:
[data-scope="marquee"][data-part="root"] {}
[data-scope="marquee"][data-part="viewport"] {}
[data-scope="marquee"][data-part="content"] {}
[data-scope="marquee"][data-part="item"] {}
[data-scope="marquee"][data-part="edge"] {}If you wish to use the default Corex styling, you can use the class marquee on the component.
This requires to install Mix.Tasks.Corex.Design first and import the component css file.
@import "../corex/main.css";
@import "../corex/tokens/themes/neo/light.css";
@import "../corex/components/marquee.css";You can then use modifiers
<.marquee class="marquee marquee--accent marquee--lg">API Control
Use an id on the component for programmatic control.
Client-side
<.action phx-click={Corex.Marquee.pause("my-marquee")}>Pause</.action>
<.action phx-click={Corex.Marquee.resume("my-marquee")}>Resume</.action>
<.action phx-click={Corex.Marquee.toggle_pause("my-marquee")}>Toggle</.action>Server-side
def handle_event("pause_marquee", _, socket) do
{:noreply, Corex.Marquee.pause(socket, "my-marquee")}
endEvents
on_pause_change/on_pause_change_client- when pause status changes (detail:%{paused: boolean})on_loop_complete/on_loop_complete_client- when one loop completeson_complete/on_complete_client- when all loops complete (finite loops only,loop_count > 0)
Summary
Functions
Pauses the marquee from client-side. Returns a Phoenix.LiveView.JS command.
Pauses the marquee from server-side. Pushes a LiveView event.
Resumes the marquee from client-side. Returns a Phoenix.LiveView.JS command.
Resumes the marquee from server-side. Pushes a LiveView event.
Toggles the pause state from client-side. Returns a Phoenix.LiveView.JS command.
Toggles the pause state from server-side. Pushes a LiveView event.
Components
Attributes
id(:string)aria_label(:string) - Accessible name for the marquee region. Defaults to "Marquee: {id}" when omitted. Defaults tonil.items(:list) (required) - List of maps for each marquee item.duration(:integer) (required) - Animation duration in seconds.side(:string) - Defaults to"end". Must be one of"start","end","top", or"bottom".speed(:integer) - Defaults to50.spacing(:string) - Defaults to"1rem".auto_fill(:boolean) - Defaults totrue.pause_on_interaction(:boolean) - Defaults tofalse.default_paused(:boolean) - Defaults tofalse.delay(:integer) - Defaults to0.loop_count(:integer) - Defaults to0.reverse(:boolean) - Defaults tofalse.respect_reduced_motion(:boolean) - When false, animation runs even when user has prefers-reduced-motion. Defaults totrue.dir(:string) - Defaults tonil.Must be one ofnil,"ltr", or"rtl".on_pause_change(:string) - Server event when pause status changes. Defaults tonil.on_pause_change_client(:string) - Client event when pause status changes. Defaults tonil.on_loop_complete(:string) - Server event when one loop completes. Defaults tonil.on_loop_complete_client(:string) - Client event when one loop completes. Defaults tonil.on_complete(:string) - Server event when all loops complete (finite loops only). Defaults tonil.on_complete_client(:string) - Client event when all loops complete (finite loops only). Defaults tonil.- Global attributes are accepted.
Slots
item(required) - Accepts attributes:class(:string)
edge_start- Accepts attributes:class(:string)
edge_end- Accepts attributes:class(:string)
Functions
Pauses the marquee from client-side. Returns a Phoenix.LiveView.JS command.
Pauses the marquee from server-side. Pushes a LiveView event.
Resumes the marquee from client-side. Returns a Phoenix.LiveView.JS command.
Resumes the marquee from server-side. Pushes a LiveView event.
Toggles the pause state from client-side. Returns a Phoenix.LiveView.JS command.
Toggles the pause state from server-side. Pushes a LiveView event.