Block Transition
vault-hyperiux/block-transitionFreeComponent
Horizontal split-block route transition with row-based stagger and optional content shift blur using GSAP.
Install it
npx shadcn@latest add https://vault.hyperiux.com/r/block-transition.jsonSource
1// Built using Hyperiux Vault: https://vault.hyperiux.com23"use client";45import { TransitionRouter } from "next-transition-router";6import React, { useLayoutEffect, useRef } from "react";7import gsap from "gsap";8import { prefersReducedMotion } from "@/lib/motion";91011const ROWS = 5;12const COLOR = "#000000";1314const STAGGER_DELAY = 0.12;15const COVER_DURATION = 0.72;16const REVEAL_DURATION = 0.68;17const BLOCK_OFFSET_PERCENT = 101;1819const SHIFT_SCALE_OUT = 0.98;20const SHIFT_SCALE_IN = 1.02;21const SHIFT_BLUR = "4px";22const SHIFT_DURATION_OUT = 0.7;23const SHIFT_DURATION_IN = 0.8;242526export default function BlockTransition({27 children,28 enableContentShift = false,29 rows = ROWS,30 color = COLOR,31}) {32 const wrapperRef = useRef(null);33 const rowRefs = useRef([]);3435 const getRows = () => rowRefs.current.filter(Boolean);36373839 const buildRowsAnimation = (timeline, direction) => {40 const rows = getRows();41 const orderedRows = direction === "cover" ? rows : [...rows].reverse();4243 orderedRows.forEach((row, index) => {44 const [leftBlock, rightBlock] = row.children;45 const delay = index * STAGGER_DELAY;4647 if (direction === "cover") {48 timeline.set([leftBlock, rightBlock], { autoAlpha: 1 }, delay);49 timeline.to(50 [leftBlock, rightBlock],51 {52 xPercent: 0,53 duration: COVER_DURATION,54 ease: "power3.inOut",55 },56 delay57 );58 } else {59 timeline.to(60 leftBlock,61 {62 xPercent: -BLOCK_OFFSET_PERCENT,63 duration: REVEAL_DURATION,64 ease: "power3.inOut",65 },66 delay67 );68 timeline.set(leftBlock, { autoAlpha: 0 }, delay + REVEAL_DURATION);6970 timeline.to(71 rightBlock,72 {73 xPercent: BLOCK_OFFSET_PERCENT,74 duration: REVEAL_DURATION,75 ease: "power3.inOut",76 },77 delay78 );79 timeline.set(rightBlock, { autoAlpha: 0 }, delay + REVEAL_DURATION);80 }81 });82 };838485 useLayoutEffect(() => {86 getRows().forEach((row) => {87 const [leftBlock, rightBlock] = row.children;88 if (!leftBlock || !rightBlock) return;8990 gsap.set(leftBlock, {91 xPercent: -BLOCK_OFFSET_PERCENT,92 autoAlpha: 0,93 });9495 gsap.set(rightBlock, {96 xPercent: BLOCK_OFFSET_PERCENT,97 autoAlpha: 0,98 });99 });100 }, []);101102103 return (104 <TransitionRouter105 auto106// … truncated
What it pulls in
npm packages
More from vault-hyperiux
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3D Portfolio Slider3d-portfolio-slider | vault-hyperiux | Components | Free | 3 deps | |
| Animated FAQanimated-faq | vault-hyperiux | Components | Free | 2 deps | |
| Animated Formanimated-form | vault-hyperiux | Components | Free | 1 dep | |
| Animated Modalanimated-modal | vault-hyperiux | Components | Free | 1 dep | |
| Tabsanimated-tabs | vault-hyperiux | Components | Free | 1 dep | |
| Animated Toggleanimated-toggle | vault-hyperiux | Components | Free | no deps | |
| Arrow Fill Buttonarrow-fill-button | vault-hyperiux | Components | Free | 1 dep | |
| Blur Textblur-text | vault-hyperiux | Components | Free | 1 dep |
