Entrances JS behaviour

Curtain reveal

A two-panel loading curtain with a wordmark and a percentage counter; at one hundred the panels part sideways and the page content staggers in — replay and a speed slider included, parked off screen, instant open under reduced motion.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

The house opens, the page enters

Two curtain panels carry the wordmark and an eased percentage counter; at one hundred the panels part to the sides and every block of the launch page beneath arrives on a stagger. Drag the speed slider or replay the whole overture.

eased count → panels part on --nx-spring-gentle → items stagger at 95ms

Important props

Important props
Prop Type Default What it does
duration ms 2400 The whole count; a slider from 0.8 to 5 seconds, retunable even mid-run.
curve easing '--nx-spring-gentle' The repo’s standard spring for the parting panels (900ms) and the item entrances (550ms).
stagger ms 95 The step between content items once the curtain opens; the first waits 360ms.
threshold ratio 0.25 The IntersectionObserver threshold; the count starts once the stage is in view.

Snippet

<div class="curt-stage" x-data="{
        open: false, pct: 0, speed: 2.4, raf: 0, io: null,
        init() {
            this.io = new IntersectionObserver((e) => { if (e[0].isIntersecting) this.tick(); });
            this.io.observe(this.$el);
        },
        destroy() { this.io?.disconnect(); cancelAnimationFrame(this.raf); },
        tick() {
            const t0 = performance.now(), dur = this.speed * 1000;
            const loop = (n) => {
                this.pct = Math.round(Math.min(1, (n - t0) / dur) * 100);
                if (this.pct < 100) this.raf = requestAnimationFrame(loop);
                else { this.open = true; }
            };
            this.raf = requestAnimationFrame(loop);
        },
    }" :data-open="open">
    <nav class="curt-in" style="--i: 0"><b>NORTHLIGHT</b></nav>
    <h2 class="curt-in" style="--i: 2">The curtain rises on your next interface</h2>
    <div class="curt-in" style="--i: 4"><button>Start building</button></div>
    <div class="curt-mark">NORTHLIGHT <b><span x-text="pct"></span>%</b></div>
    <i class="curt-panel curt-l"></i><i class="curt-panel curt-r"></i>
</div>

<style>
.curt-stage { position: relative; overflow: clip; border-radius: 1.25rem; display: grid; gap: 1rem;
              align-content: center; padding: 2rem; min-block-size: 20rem; background: #fffdf9; }
.curt-in { opacity: 0; translate: 0 18px; filter: blur(7px);
           transition: opacity .55s var(--nx-spring-gentle), translate .55s var(--nx-spring-gentle),
                       filter .55s var(--nx-spring-gentle); }
.curt-stage[data-open='true'] .curt-in { opacity: 1; translate: 0 0; filter: none;
           transition-delay: calc(360ms + var(--i) * 95ms); }
.curt-panel { position: absolute; inset-block: 0; inline-size: 50.5%; background: #1c1917;
              transition: translate .9s var(--nx-spring-gentle); }
.curt-l { inset-inline-start: 0; } .curt-r { inset-inline-end: 0; }
.curt-stage[data-open='true'] .curt-l { translate: -102% 0; }
.curt-stage[data-open='true'] .curt-r { translate: 102% 0; }
.curt-mark { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center;
             justify-items: center; gap: .6rem; color: #f5f0e8; transition: opacity .4s, scale .4s; }
.curt-stage[data-open='true'] .curt-mark { opacity: 0; scale: .92; }
</style>
// app/Pages/Launch.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import CurtainReveal from '@/components/CurtainReveal';

export default function Launch() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <CurtainReveal speed={2.4} />
      </main>
    </NabuXUIProvider>
  );
}
// CurtainReveal.jsx — a two-panel loading curtain with a percentage counter
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';

export default function CurtainReveal({ speed = 2.4 }) {
  const [open, setOpen] = useState(false);
  const [pct, setPct] = useState(0);
  const stageRef = useRef(null);
  const rafRef = useRef(0);

  // One count per mount: starts when the stage is 25% in view,
  // opens the house at one hundred, cleans itself up on unmount.
  useEffect(() => {
    let done = false;
    const io = new IntersectionObserver(([e]) => {
      if (!e.isIntersecting || done) return;
      done = true;
      io.disconnect();
      const t0 = performance.now();
      const loop = (n) => {
        const p = Math.min(1, (n - t0) / (speed * 1000));
        setPct(Math.round((1 - Math.pow(1 - p, 3)) * 100));
        if (p < 1) rafRef.current = requestAnimationFrame(loop);
        else setOpen(true);
      };
      rafRef.current = requestAnimationFrame(loop);
    }, { threshold: 0.25 });
    io.observe(stageRef.current);
    return () => { io.disconnect(); cancelAnimationFrame(rafRef.current); };
  }, [speed]);

  return (
    <>
      <style>{`
        .curt-stage { position: relative; overflow: clip; border-radius: 1.25rem; display: grid; gap: 1rem;
                      align-content: center; padding: 2rem; min-block-size: 20rem; background: #fffdf9; }
        .curt-in { opacity: 0; translate: 0 18px; filter: blur(7px);
                   transition: opacity .55s var(--nx-spring-gentle), translate .55s var(--nx-spring-gentle),
                               filter .55s var(--nx-spring-gentle); }
        .curt-stage[data-open='true'] .curt-in { opacity: 1; translate: 0 0; filter: none;
                   transition-delay: calc(360ms + var(--i) * 95ms); }
        .curt-panel { position: absolute; inset-block: 0; inline-size: 50.5%; background: #1c1917;
                      transition: translate .9s var(--nx-spring-gentle); }
        .curt-l { inset-inline-start: 0; } .curt-r { inset-inline-end: 0; }
        .curt-stage[data-open='true'] .curt-l { translate: -102% 0; }
        .curt-stage[data-open='true'] .curt-r { translate: 102% 0; }
        .curt-mark { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center;
                     justify-items: center; gap: .6rem; color: #f5f0e8; transition: opacity .4s, scale .4s; }
        .curt-stage[data-open='true'] .curt-mark { opacity: 0; scale: .92; }
      `}</style>
      <div className="curt-stage" data-open={open} ref={stageRef}>
        <nav className="curt-in" style={{ '--i': 0 }}><b>NORTHLIGHT</b></nav>
        <h2 className="curt-in" style={{ '--i': 2 }}>The curtain rises on your next interface</h2>
        <div className="curt-in" style={{ '--i': 4 }}><button type="button">Start building</button></div>
        <div className="curt-mark" aria-hidden="true">NORTHLIGHT <b>{pct}%</b></div>
        <i className="curt-panel curt-l" aria-hidden="true" />
        <i className="curt-panel curt-r" aria-hidden="true" />
      </div>
    </>
  );
}
<!-- CurtainReveal.vue — a two-panel loading curtain with a percentage counter -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';

const props = defineProps<{ speed?: number }>();
const open = ref(false);
const pct = ref(0);
let io: IntersectionObserver | null = null;
let raf = 0;

onMounted(() => {
  const el = stage.value;
  io = new IntersectionObserver(([e]) => {
    if (!e.isIntersecting || open.value) return;
    io?.disconnect();
    const t0 = performance.now();
    const loop = (n: number) => {
      const p = Math.min(1, (n - t0) / ((props.speed ?? 2.4) * 1000));
      pct.value = Math.round((1 - Math.pow(1 - p, 3)) * 100);
      if (p < 1) raf = requestAnimationFrame(loop);
      else open.value = true;
    };
    raf = requestAnimationFrame(loop);
  }, { threshold: 0.25 });
  io.observe(el);
});
onBeforeUnmount(() => { io?.disconnect(); cancelAnimationFrame(raf); });
const stage = ref<HTMLElement | null>(null);
</script>

<template>
  <div ref="stage" class="curt-stage" :data-open="open">
    <nav class="curt-in" style="--i: 0"><b>NORTHLIGHT</b></nav>
    <h2 class="curt-in" style="--i: 2">The curtain rises on your next interface</h2>
    <div class="curt-in" style="--i: 4"><button type="button">Start building</button></div>
    <div class="curt-mark" aria-hidden="true">NORTHLIGHT <b>{{ pct }}%</b></div>
    <i class="curt-panel curt-l" aria-hidden="true"></i>
    <i class="curt-panel curt-r" aria-hidden="true"></i>
  </div>
</template>

<style scoped>
.curt-stage { position: relative; overflow: clip; border-radius: 1.25rem; display: grid; gap: 1rem;
              align-content: center; padding: 2rem; min-block-size: 20rem; background: #fffdf9; }
.curt-in { opacity: 0; translate: 0 18px; filter: blur(7px);
           transition: opacity .55s var(--nx-spring-gentle), translate .55s var(--nx-spring-gentle),
                       filter .55s var(--nx-spring-gentle); }
.curt-stage[data-open='true'] .curt-in { opacity: 1; translate: 0 0; filter: none;
           transition-delay: calc(360ms + var(--i) * 95ms); }
.curt-panel { position: absolute; inset-block: 0; inline-size: 50.5%; background: #1c1917;
              transition: translate .9s var(--nx-spring-gentle); }
.curt-l { inset-inline-start: 0; } .curt-r { inset-inline-end: 0; }
.curt-stage[data-open='true'] .curt-l { translate: -102% 0; }
.curt-stage[data-open='true'] .curt-r { translate: 102% 0; }
.curt-mark { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center;
             justify-items: center; gap: .6rem; color: #f5f0e8; transition: opacity .4s, scale .4s; }
.curt-stage[data-open='true'] .curt-mark { opacity: 0; scale: .92; }
</style>
<!-- CurtainReveal.svelte — a two-panel loading curtain with a percentage counter -->
<script lang="ts">
  import { onMount } from 'svelte';
  import '@nabuxai/ui-core/css';

  let { speed = 2.4 } = $props();
  let open = $state(false);
  let pct = $state(0);
  let stage: HTMLElement;
  let io: IntersectionObserver | null = null;
  let raf = 0;

  onMount(() => {
    io = new IntersectionObserver(([e]) => {
      if (!e.isIntersecting || open) return;
      io?.disconnect();
      const t0 = performance.now();
      const loop = (n: number) => {
        const p = Math.min(1, (n - t0) / (speed * 1000));
        pct = Math.round((1 - Math.pow(1 - p, 3)) * 100);
        if (p < 1) raf = requestAnimationFrame(loop);
        else open = true;
      };
      raf = requestAnimationFrame(loop);
    }, { threshold: 0.25 });
    io.observe(stage);
    return () => { io?.disconnect(); cancelAnimationFrame(raf); };
  });
</script>

<div bind:this={stage} class="curt-stage" data-open={open}>
  <nav class="curt-in" style="--i: 0"><b>NORTHLIGHT</b></nav>
  <h2 class="curt-in" style="--i: 2">The curtain rises on your next interface</h2>
  <div class="curt-in" style="--i: 4"><button type="button">Start building</button></div>
  <div class="curt-mark" aria-hidden="true">NORTHLIGHT <b>{pct}%</b></div>
  <i class="curt-panel curt-l" aria-hidden="true"></i>
  <i class="curt-panel curt-r" aria-hidden="true"></i>
</div>

<style>
.curt-stage { position: relative; overflow: clip; border-radius: 1.25rem; display: grid; gap: 1rem;
              align-content: center; padding: 2rem; min-block-size: 20rem; background: #fffdf9; }
.curt-in { opacity: 0; translate: 0 18px; filter: blur(7px);
           transition: opacity .55s var(--nx-spring-gentle), translate .55s var(--nx-spring-gentle),
                       filter .55s var(--nx-spring-gentle); }
.curt-stage[data-open='true'] .curt-in { opacity: 1; translate: 0 0; filter: none;
           transition-delay: calc(360ms + var(--i) * 95ms); }
.curt-panel { position: absolute; inset-block: 0; inline-size: 50.5%; background: #1c1917;
              transition: translate .9s var(--nx-spring-gentle); }
.curt-l { inset-inline-start: 0; } .curt-r { inset-inline-end: 0; }
.curt-stage[data-open='true'] .curt-l { translate: -102% 0; }
.curt-stage[data-open='true'] .curt-r { translate: 102% 0; }
.curt-mark { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center;
             justify-items: center; gap: .6rem; color: #f5f0e8; transition: opacity .4s, scale .4s; }
.curt-stage[data-open='true'] .curt-mark { opacity: 0; scale: .92; }
</style>