# Marquee

Konten apa pun yang bergulir tanpa henti secara horizontal atau vertikal, dengan tepi memudar, arah terbalik, dan jeda saat hover atau fokus.

- Kategori: Animasi
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/marquee.json
- CLI: `npx markasui@latest add marquee`

## Kapan dipakai

Menampilkan logo, testimoni, tag, atau feed sebagai konten dekoratif yang terus bergerak.

- Isi item untuk satu putaran saja; komponen menggandakannya
- Beri marquee vertikal tinggi yang tetap
- Jangan menaruh satu-satunya salinan informasi penting di marquee
- Blade butuh Alpine.js

## Kode

### Blade

Simpan di `resources/views/components/markas/marquee.blade.php`. Dependensi: alpinejs.

```blade
@props([
    'vertical' => false,
    'reverse' => false,
    'duration' => 20,
    'pauseOnHover' => true,
    'fade' => true,
])

@php
    $root = 'flex overflow-hidden';
    $copy = 'flex shrink-0 justify-around gap-4';
    $orientations = [
        'horizontal' => ['root' => 'flex-row', 'copy' => 'min-w-full flex-row pr-4'],
        'vertical' => ['root' => 'flex-col', 'copy' => 'min-h-full flex-col pb-4'],
    ];
    $fades = [
        'horizontal' => 'mask-x-from-85%',
        'vertical' => 'mask-y-from-85%',
    ];

    $orientation = $vertical ? 'vertical' : 'horizontal';
@endphp

<div
    x-data="{
        animations: [],
        observer: null,
        hover: false,
        focus: false,
        hidden: false,
        {{-- Geser setiap salinan sejauh lebarnya sendiri tanpa henti. --}}
        init() {
            if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return;
            const axis = @js($vertical ? 'Y' : 'X');
            this.animations = Array.from(this.$el.children).flatMap((child) => child.animate?.(
                [{ transform: `translate${axis}(0)` }, { transform: `translate${axis}(-100%)` }],
                { duration: @js((float) $duration) * 1000, iterations: Infinity, direction: @js($reverse ? 'reverse' : 'normal') },
            ) ?? []);
            if (typeof IntersectionObserver === 'undefined') return;
            this.observer = new IntersectionObserver((entries) => {
                this.hidden = ! entries.some((entry) => entry.isIntersecting);
                this.sync();
            });
            this.observer.observe(this.$el);
        },
        {{-- Berhenti saat kursor di atas, fokus di dalam, atau marquee di luar layar. --}}
        sync() {
            const paused = (@js((bool) $pauseOnHover) && this.hover) || this.focus || this.hidden;
            this.animations.forEach((animation) => (paused ? animation.pause() : animation.play()));
        },
        destroy() {
            this.observer?.disconnect();
            this.animations.forEach((animation) => animation.cancel());
        },
    }"
    @mouseenter="hover = true; sync()"
    @mouseleave="hover = false; sync()"
    @focusin="focus = true; sync()"
    @focusout="focus = false; sync()"
    {{ $attributes->class([$root, $orientations[$orientation]['root'], $fades[$orientation] => $fade]) }}
>
    <div class="{{ $copy }} {{ $orientations[$orientation]['copy'] }}">{{ $slot }}</div>
    <div aria-hidden="true" inert class="{{ $copy }} {{ $orientations[$orientation]['copy'] }}">{{ $slot }}</div>
</div>
```

```blade
<x-markas.marquee :duration="25">
    @foreach ($logos as $logo)
        <img src="{{ $logo['src'] }}" alt="{{ $logo['name'] }}" class="h-8" />
    @endforeach
</x-markas.marquee>

<x-markas.marquee vertical reverse class="h-64">...</x-markas.marquee>
```

### React

Simpan di `src/components/markas/Marquee.tsx`. Tanpa dependensi tambahan.

```tsx
"use client";

import { useEffect, useRef, type ComponentProps } from "react";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const COPIES = [0, 1];
const MS_PER_SECOND = 1000;

const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

/**
 * Geser setiap salinan sejauh lebarnya sendiri tanpa henti. Berhenti saat kursor di atas, fokus di dalam,
 * atau marquee di luar layar. Mengembalikan fungsi pelepas.
 */
function startMarquee(
  element: HTMLElement,
  options: {
    vertical: boolean;
    reverse: boolean;
    duration: number;
    pauseOnHover: boolean;
  },
) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

export type MarqueeProps = ComponentProps<"div"> & {
  vertical?: boolean;
  reverse?: boolean;
  duration?: number;
  pauseOnHover?: boolean;
  fade?: boolean;
};

export function Marquee({
  vertical = false,
  reverse = false,
  duration = 20,
  pauseOnHover = true,
  fade = true,
  className,
  children,
  ...props
}: MarqueeProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  const orientation = vertical ? "vertical" : "horizontal";

  useEffect(() => {
    const element = rootRef.current;
    if (!element || reducedMotion()) return;
    return startMarquee(element, { vertical, reverse, duration, pauseOnHover });
  }, [vertical, reverse, duration, pauseOnHover]);

  return (
    <div
      ref={rootRef}
      {...props}
      className={cx(
        root,
        orientations[orientation].root,
        fade && fades[orientation],
        className,
      )}
    >
      {COPIES.map((index) => (
        <div
          key={index}
          aria-hidden={index > 0 ? true : undefined}
          inert={index > 0}
          className={cx(copy, orientations[orientation].copy)}
        >
          {children}
        </div>
      ))}
    </div>
  );
}
```

```tsx
import { Marquee } from "@/components/markas/Marquee";

<Marquee duration={25}>
  {logos.map((logo) => (
    <img key={logo.name} src={logo.src} alt={logo.name} className="h-8" />
  ))}
</Marquee>

<Marquee vertical reverse className="h-64">...</Marquee>
```

### Vue

Simpan di `src/components/markas/Marquee.vue`. Tanpa dependensi tambahan.

```vue
<script setup lang="ts">
import { onBeforeUnmount, onMounted, useTemplateRef, watch } from "vue";

const props = withDefaults(
  defineProps<{
    vertical?: boolean;
    reverse?: boolean;
    duration?: number;
    pauseOnHover?: boolean;
    fade?: boolean;
  }>(),
  {
    vertical: false,
    reverse: false,
    duration: 20,
    pauseOnHover: true,
    fade: true,
  },
);

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const COPIES = [0, 1];
const MS_PER_SECOND = 1000;

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

/**
 * Geser setiap salinan sejauh lebarnya sendiri tanpa henti. Berhenti saat kursor di atas, fokus di dalam,
 * atau marquee di luar layar. Mengembalikan fungsi pelepas.
 */
function startMarquee(
  element: HTMLElement,
  options: {
    vertical: boolean;
    reverse: boolean;
    duration: number;
    pauseOnHover: boolean;
  },
) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

const rootEl = useTemplateRef<HTMLDivElement>("rootRef");
let stop = () => {};

function start() {
  stop();
  stop = () => {};
  const element = rootEl.value;
  if (!element || reducedMotion()) return;
  stop = startMarquee(element, {
    vertical: props.vertical,
    reverse: props.reverse,
    duration: props.duration,
    pauseOnHover: props.pauseOnHover,
  });
}

const orientation = () => (props.vertical ? "vertical" : "horizontal");

onMounted(start);
watch(
  () => [props.vertical, props.reverse, props.duration, props.pauseOnHover],
  start,
  { flush: "post" },
);
onBeforeUnmount(() => stop());
</script>

<template>
  <div
    ref="rootRef"
    :class="[
      root,
      orientations[orientation()].root,
      props.fade && fades[orientation()],
    ]"
  >
    <div
      v-for="index in COPIES"
      :key="index"
      :aria-hidden="index > 0 ? 'true' : undefined"
      :inert="index > 0 ? true : undefined"
      :class="[copy, orientations[orientation()].copy]"
    >
      <slot />
    </div>
  </div>
</template>
```

```vue
<template>
  <Marquee :duration="25">
    <img
      v-for="logo in logos"
      :key="logo.name"
      :src="logo.src"
      :alt="logo.name"
      class="h-8"
    />
  </Marquee>

  <Marquee vertical reverse class="h-64">...</Marquee>
</template>
```

### Svelte

Simpan di `src/lib/components/markas/Marquee.svelte`. Tanpa dependensi tambahan.

```svelte
<script lang="ts">
  import type { Snippet } from "svelte";
  import type { HTMLAttributes } from "svelte/elements";

  const root = "flex overflow-hidden";
  const copy = "flex shrink-0 justify-around gap-4";
  const orientations = {
    horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
    vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
  };
  const fades = {
    horizontal: "mask-x-from-85%",
    vertical: "mask-y-from-85%",
  };
  const COPIES = [0, 1];
  const MS_PER_SECOND = 1000;

  const reducedMotion = () =>
    typeof matchMedia === "function" &&
    matchMedia("(prefers-reduced-motion: reduce)").matches;

  /**
   * Moves every copy by its own size, forever. Pauses while hovered, while focus is inside,
   * or while the marquee is off screen. Returns a cleanup function.
   */
  function startMarquee(
    element: HTMLElement,
    options: {
      vertical: boolean;
      reverse: boolean;
      duration: number;
      pauseOnHover: boolean;
    },
  ) {
    const axis = options.vertical ? "Y" : "X";
    const animations = Array.from(element.children).flatMap(
      (child) =>
        child.animate?.(
          [
            { transform: `translate${axis}(0)` },
            { transform: `translate${axis}(-100%)` },
          ],
          {
            duration: options.duration * MS_PER_SECOND,
            iterations: Infinity,
            direction: options.reverse ? "reverse" : "normal",
          },
        ) ?? [],
    );
    const state = { hover: false, focus: false, hidden: false };
    const sync = () => {
      const paused =
        (options.pauseOnHover && state.hover) || state.focus || state.hidden;
      for (const animation of animations)
        if (paused) animation.pause();
        else animation.play();
    };
    const listeners: [string, () => void][] = [
      ["mouseenter", () => ((state.hover = true), sync())],
      ["mouseleave", () => ((state.hover = false), sync())],
      ["focusin", () => ((state.focus = true), sync())],
      ["focusout", () => ((state.focus = false), sync())],
    ];
    for (const [type, listener] of listeners)
      element.addEventListener(type, listener);
    const observer =
      typeof IntersectionObserver === "undefined"
        ? undefined
        : new IntersectionObserver((entries) => {
            state.hidden = !entries.some((entry) => entry.isIntersecting);
            sync();
          });
    observer?.observe(element);

    return () => {
      observer?.disconnect();
      for (const [type, listener] of listeners)
        element.removeEventListener(type, listener);
      for (const animation of animations) animation.cancel();
    };
  }

  type Props = HTMLAttributes<HTMLDivElement> & {
    vertical?: boolean;
    reverse?: boolean;
    /** Seconds for one full loop. */
    duration?: number;
    pauseOnHover?: boolean;
    fade?: boolean;
    children?: Snippet;
  };

  let {
    vertical = false,
    reverse = false,
    duration = 20,
    pauseOnHover = true,
    fade = true,
    class: className,
    children,
    ...rest
  }: Props = $props();

  let element = $state<HTMLDivElement>();
  const orientation = $derived(vertical ? "vertical" : "horizontal");

  $effect(() => {
    const options = { vertical, reverse, duration, pauseOnHover };
    if (!element || reducedMotion()) return;
    return startMarquee(element, options);
  });
</script>

<div
  bind:this={element}
  {...rest}
  class={[
    root,
    orientations[orientation].root,
    fade && fades[orientation],
    className,
  ]}
>
  {#each COPIES as index (index)}
    <div
      aria-hidden={index > 0 ? "true" : undefined}
      inert={index > 0}
      class={[copy, orientations[orientation].copy]}
    >
      {@render children?.()}
    </div>
  {/each}
</div>
```

```svelte
<script lang="ts">
  import Marquee from "$lib/components/markas/Marquee.svelte";
</script>

<Marquee duration={25}>
  {#each logos as logo (logo.name)}
    <img src={logo.src} alt={logo.name} class="h-8" />
  {/each}
</Marquee>

<Marquee vertical reverse class="h-64">...</Marquee>
```

### Astro

Simpan di `src/components/markas/Marquee.astro`. Tanpa dependensi tambahan.

```astro
---
import type { HTMLAttributes } from "astro/types";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};

type Props = HTMLAttributes<"div"> & {
  vertical?: boolean;
  reverse?: boolean;
  /** Seconds for one full loop. */
  duration?: number;
  pauseOnHover?: boolean;
  fade?: boolean;
};

const {
  vertical = false,
  reverse = false,
  duration = 20,
  pauseOnHover = true,
  fade = true,
  class: className,
  ...rest
} = Astro.props;
const orientation = vertical ? "vertical" : "horizontal";
// A slot renders once, so the same HTML fills the visible copy and the hidden one.
const content = await Astro.slots.render("default");
---

<markas-marquee
  class="contents"
  data-vertical={vertical ? "" : undefined}
  data-reverse={reverse ? "" : undefined}
  data-duration={duration}
  data-pause-on-hover={pauseOnHover ? "" : undefined}
>
  <div
    {...rest}
    class:list={[
      root,
      orientations[orientation].root,
      fade && fades[orientation],
      className,
    ]}
  >
    <div class:list={[copy, orientations[orientation].copy]}>
      <Fragment set:html={content} />
    </div>
    <div aria-hidden="true" inert class:list={[copy, orientations[orientation].copy]}>
      <Fragment set:html={content} />
    </div>
  </div>
</markas-marquee>

<script>
  const MS_PER_SECOND = 1000;

  // One element per marquee: setup runs for markup added later and after view transitions.
  class MarkasMarquee extends HTMLElement {
    private cleanup = () => {};

    connectedCallback() {
      const element = this.firstElementChild as HTMLElement | null;
      if (!element || matchMedia("(prefers-reduced-motion: reduce)").matches)
        return;
      const axis = this.hasAttribute("data-vertical") ? "Y" : "X";
      const pauseOnHover = this.hasAttribute("data-pause-on-hover");
      // Move every copy by its own size, forever.
      const animations = Array.from(element.children).flatMap(
        (child) =>
          child.animate?.(
            [
              { transform: `translate${axis}(0)` },
              { transform: `translate${axis}(-100%)` },
            ],
            {
              duration: Number(this.dataset.duration) * MS_PER_SECOND,
              iterations: Infinity,
              direction: this.hasAttribute("data-reverse") ? "reverse" : "normal",
            },
          ) ?? [],
      );
      // Pause while hovered, while focus is inside, or while off screen.
      const state = { hover: false, focus: false, hidden: false };
      const sync = () => {
        const paused = (pauseOnHover && state.hover) || state.focus || state.hidden;
        for (const animation of animations)
          if (paused) animation.pause();
          else animation.play();
      };
      const listeners: [string, () => void][] = [
        ["mouseenter", () => ((state.hover = true), sync())],
        ["mouseleave", () => ((state.hover = false), sync())],
        ["focusin", () => ((state.focus = true), sync())],
        ["focusout", () => ((state.focus = false), sync())],
      ];
      for (const [type, listener] of listeners)
        element.addEventListener(type, listener);
      const observer = new IntersectionObserver((entries) => {
        state.hidden = !entries.some((entry) => entry.isIntersecting);
        sync();
      });
      observer.observe(element);
      this.cleanup = () => {
        observer.disconnect();
        for (const [type, listener] of listeners)
          element.removeEventListener(type, listener);
        for (const animation of animations) animation.cancel();
      };
    }

    disconnectedCallback() {
      this.cleanup();
    }
  }

  if (!customElements.get("markas-marquee"))
    customElements.define("markas-marquee", MarkasMarquee);
</script>
```

```astro
---
import Marquee from "@/components/markas/Marquee.astro";
---

<Marquee duration={25}>
  {logos.map((logo) => <img src={logo.src} alt={logo.name} class="h-8" />)}
</Marquee>
```

### Angular

Simpan di `src/app/markas/marquee.component.ts`. Tanpa dependensi tambahan.

```ts
import {
  afterNextRender,
  afterRenderEffect,
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  computed,
  ElementRef,
  inject,
  input,
  numberAttribute,
  viewChild,
} from "@angular/core";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const MS_PER_SECOND = 1000;

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

type MarqueeOptions = {
  vertical: boolean;
  reverse: boolean;
  duration: number;
  pauseOnHover: boolean;
};

/**
 * Moves every copy by its own size, forever. Pauses while hovered, while focus is inside,
 * or while the marquee is off screen. Returns a cleanup function.
 */
function startMarquee(element: HTMLElement, options: MarqueeOptions) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

/**
 * Attribute selector on the root div. ng-content projects once, so the hidden copy is a clone
 * of the visible one made after the first render.
 */
@Component({
  selector: "div[markas-marquee]",
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: { "[class]": "classes()" },
  template: `
    <div #firstEl [class]="copyClasses()"><ng-content /></div>
    <div #cloneEl aria-hidden="true" inert [class]="copyClasses()"></div>
  `,
})
export class Marquee {
  readonly vertical = input(false, { transform: booleanAttribute });
  readonly reverse = input(false, { transform: booleanAttribute });
  /** Seconds for one full loop. */
  readonly duration = input(20, { transform: numberAttribute });
  readonly pauseOnHover = input(true, { transform: booleanAttribute });
  readonly fade = input(true, { transform: booleanAttribute });

  private readonly orientation = computed(() =>
    this.vertical() ? "vertical" : "horizontal",
  );
  protected readonly classes = computed(() =>
    [
      root,
      orientations[this.orientation()].root,
      this.fade() && fades[this.orientation()],
    ]
      .filter(Boolean)
      .join(" "),
  );
  protected readonly copyClasses = computed(
    () => `${copy} ${orientations[this.orientation()].copy}`,
  );
  private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
  private readonly first =
    viewChild.required<ElementRef<HTMLElement>>("firstEl");
  private readonly clone =
    viewChild.required<ElementRef<HTMLElement>>("cloneEl");

  constructor() {
    afterNextRender(() =>
      this.clone().nativeElement.replaceChildren(
        ...[...this.first().nativeElement.childNodes].map((node) =>
          node.cloneNode(true),
        ),
      ),
    );
    afterRenderEffect((onCleanup) => {
      const options = {
        vertical: this.vertical(),
        reverse: this.reverse(),
        duration: this.duration(),
        pauseOnHover: this.pauseOnHover(),
      };
      if (reducedMotion()) return;
      onCleanup(startMarquee(this.host.nativeElement, options));
    });
  }
}
```

```ts
import { Component } from "@angular/core";
import { Marquee } from "./markas/marquee.component";

@Component({
  selector: "app-logos",
  imports: [Marquee],
  template: `
    <div markas-marquee duration="25">
      @for (logo of logos; track logo.name) {
        <img [src]="logo.src" [alt]="logo.name" class="h-8" />
      }
    </div>
  `,
})
export class Logos {
  logos = [{ name: "Laravel", src: "/laravel.svg" }];
}
```

## Props

| Nama | Tipe | Default | Keterangan |
| --- | --- | --- | --- |
| `vertical` | `boolean` | false | Bergulir dari bawah ke atas. Beri tinggi pada marquee, misalnya h-64. |
| `reverse` | `boolean` | false | Bergulir ke arah sebaliknya. |
| `duration` | `number` | 20 | Detik untuk satu putaran penuh. Makin besar makin lambat. |
| `pauseOnHover` | `boolean` | true | Berhenti selama kursor berada di atas marquee. Fokus di dalam selalu menghentikannya. |
| `fade` | `boolean` | true | Pudarkan konten di kedua tepi dengan CSS mask. |
| `children / slot` | `ReactNode / slot` | - | Item satu putaran, disusun dalam baris (atau kolom) dengan jarak 16px. |

## Aksesibilitas

- Konten dirender dua kali agar putaran mulus; salinan kedua memakai aria-hidden dan inert, jadi screen reader dan tombol Tab hanya mencapai setiap item sekali.
- Animasi berhenti saat hover, saat fokus berada di dalam, dan saat marquee di luar layar.
- Dengan reduced motion, tidak ada yang bergerak dan item pertama tetap terlihat.
- Konten bergerak lebih dari 5 detik perlu cara untuk menghentikannya (WCAG 2.2.2): jangan taruh informasi penting hanya di marquee.

## Catatan

- Isi item untuk satu putaran. Komponen merendernya dua kali; salinannya memakai `aria-hidden` dan `inert`.
- Setiap salinan minimal selebar marquee, jadi daftar pendek tetap berputar tanpa celah.
- Gerakan memakai Web Animations API dan berhenti saat hover, saat fokus di dalam, dan saat di luar layar. Versi Blade butuh Alpine.js.
- Di Angular, `ng-content` hanya diproyeksikan sekali, jadi salinan tersembunyi adalah klon item yang dibuat setelah render pertama. Perubahan item setelah itu tidak ikut tersalin.
- Dengan reduced motion, tidak ada yang bergerak. Jangan taruh informasi yang dibutuhkan pengguna hanya di dalam marquee.
