Repository: solidjs-community/solid-transition-group
Branch: main
Commit: 17bb3f4d83de
Files: 24
Total size: 42.5 KB
Directory structure:
gitextract_g0bh3662/
├── .github/
│ └── workflows/
│ └── tests.yml
├── .gitignore
├── .prettierrc
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── LICENSE
├── README.md
├── astro.config.ts
├── dev/
│ ├── env.d.ts
│ ├── group.tsx
│ ├── kitchen-sink.tsx
│ ├── layout.astro
│ ├── pages/
│ │ ├── group.astro
│ │ └── index.astro
│ └── styles.css
├── netlify.toml
├── package.json
├── src/
│ └── index.ts
├── tailwind.config.cjs
├── test/
│ ├── index.test.tsx
│ └── server.test.tsx
├── tsconfig.build.json
├── tsconfig.json
└── vitest.config.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/tests.yml
================================================
name: Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Build
run: pnpm run build
env:
CI: true
- name: Test
run: pnpm run test
================================================
FILE: .gitignore
================================================
node_modules/
dist/
lib/
coverage/
types/
*.tsbuildinfo
================================================
FILE: .prettierrc
================================================
{
"trailingComma": "all",
"tabWidth": 2,
"printWidth": 100,
"semi": true,
"singleQuote": false,
"useTabs": false,
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"plugins": []
}
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"esbenp.prettier-vscode",
"astro-build.astro-vscode",
"bradlc.vscode-tailwindcss"
]
}
================================================
FILE: .vscode/settings.json
================================================
{
"cSpell.words": ["astrojs", "outin"],
"css.validate": false
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020-2021 Ryan Carniato
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Solid Transition Group
[](https://pnpm.io/)
[](https://www.npmjs.com/package/solid-transition-group)
[](https://www.npmjs.com/package/solid-transition-group)
Components for applying animations when children elements enter or leave the DOM. Influenced by React Transition Group and Vue Transitions for the SolidJS library.
## Installation
```bash
npm install solid-transition-group
# or
yarn add solid-transition-group
# or
pnpm add solid-transition-group
```
## Transition
`` serve as transition effects for single element/component. The `` only applies the transition behavior to the wrapped content inside; it doesn't render an extra DOM element, or show up in the inspected component hierarchy.
All props besides `children` are optional.
### Using with CSS
Usage with CSS is straightforward. Just add the `name` prop and the CSS classes will be automatically generated for you. The `name` prop is used as a prefix for the generated CSS classes. For example, if you use `name="slide-fade"`, the generated CSS classes will be `.slide-fade-enter`, `.slide-fade-enter-active`, etc.
The exitting element will be removed from the DOM when the first transition ends. You can override this behavior by providing a `done` callback to the `onExit` prop.
```tsx
import { Transition } from "solid-transition-group"
const [isVisible, setVisible] = createSignal(true)
Hello
setVisible(false) // triggers exit transition
```
Example CSS transition:
```css
.slide-fade-enter-active,
.slide-fade-exit-active {
transition: opacity 0.3s, transform 0.3s;
}
.slide-fade-enter,
.slide-fade-exit-to {
transform: translateX(10px);
opacity: 0;
}
.slide-fade-enter {
transform: translateX(-10px);
}
```
Props for customizing the CSS classes applied by ``:
| Name | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | Used to automatically generate transition CSS class names. e.g. `name: 'fade'` will auto expand to `.fade-enter`, `.fade-enter-active`, etc. Defaults to `"s"`. |
| `enterClass` | CSS class applied to the entering element at the start of the enter transition, and removed the frame after. Defaults to `"s-enter"`. |
| `enterToClass` | CSS class applied to the entering element after the enter transition starts. Defaults to `"s-enter-to"`. |
| `enterActiveClass` | CSS class applied to the entering element for the entire duration of the enter transition. Defaults to `"s-enter-active"`. |
| `exitClass` | CSS class applied to the exiting element at the start of the exit transition, and removed the frame after. Defaults to `"s-exit"`. |
| `exitToClass` | CSS class applied to the exiting element after the exit transition starts. Defaults to `"s-exit-to"`. |
| `exitActiveClass` | CSS class applied to the exiting element for the entire duration of the exit transition. Defaults to `"s-exit-active"`. |
### Using with JavaScript
You can also use JavaScript to animate the transition. The `` component provides several events that you can use to hook into the transition lifecycle. The `onEnter` and `onExit` events are called when the transition starts, and the `onBeforeEnter` and `onBeforeExit` events are called before the transition starts. The `onAfterEnter` and `onAfterExit` events are called after the transition ends.
```jsx
{
const a = el.animate([{ opacity: 0 }, { opacity: 1 }], {
duration: 600
});
a.finished.then(done);
}}
onExit={(el, done) => {
const a = el.animate([{ opacity: 1 }, { opacity: 0 }], {
duration: 600
});
a.finished.then(done);
}}
>
{show() &&
Hello
}
```
**Events** proved by `` for animating elements with JavaScript:
| Name | Parameters | Description |
| --------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `onBeforeEnter` | `element: Element` | Function called before the enter transition starts. The `element` is not yet rendered. |
| `onEnter` | `element: Element, done: () => void` | Function called when the enter transition starts. The `element` is rendered to the DOM. Call `done` to end the transition - removes the enter classes, and calls `onAfterEnter`. If the parameter for `done` is not provided, it will be called on `transitionend` or `animationend`. |
| `onAfterEnter` | `element: Element` | Function called after the enter transition ends. The `element` is removed from the DOM. |
| `onBeforeExit` | `element: Element` | Function called before the exit transition starts. The `element` is still rendered, exit classes are not yet applied. |
| `onExit` | `element: Element, done: () => void` | Function called when the exit transition starts, after the exit classes are applied (`enterToClass` and `exitActiveClass`). The `element` is still rendered. Call `done` to end the transition - removes exit classes, calls `onAfterExit` and removes the element from the DOM. If the parameter for `done` is not provided, it will be called on `transitionend` or `animationend`. |
| `onAfterExit` | `element: Element` | Function called after the exit transition ends. The `element` is removed from the DOM. |
### Changing Transition Mode
By default, `` will apply the transition effect to both entering and exiting elements simultaneously. You can change this behavior by setting the `mode` prop to `"outin"` or `"inout"`. The `"outin"` mode will wait for the exiting element to finish before applying the transition to the entering element. The `"inout"` mode will wait for the entering element to finish before applying the transition to the exiting element.
By default the transition won't be applied on initial render. You can change this behavior by setting the `appear` prop to `true`.
> **Warning:** When using `appear` with SSR, the initial transition will be applied on the client-side, which might cause a flash of unstyled content.
> You need to handle applying the initial transition on the server-side yourself.
## TransitionGroup
### Props
- `moveClass` - CSS class applied to the moving elements for the entire duration of the move transition. Defaults to `"s-move"`.
- exposes the same props as `` except `mode`.
### Usage
`` serve as transition effects for multiple elements/components.
`` supports moving transitions via CSS transform. When a child's position on screen has changed after an update, it will get applied a moving CSS class (auto generated from the name attribute or configured with the move-class attribute). If the CSS transform property is "transition-able" when the moving class is applied, the element will be smoothly animated to its destination using the FLIP technique.
```jsx
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris facilisis enim libero,
at lacinia diam fermentum id. Pellentesque habitant morbi tristique senectus et netus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris facilisis enim libero,
at lacinia diam fermentum id. Pellentesque habitant morbi tristique senectus et netus.
)}
Animation:
{show() && (
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris facilisis enim libero,
at lacinia diam fermentum id. Pellentesque habitant morbi tristique senectus et netus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris facilisis enim libero,
at lacinia diam fermentum id. Pellentesque habitant morbi tristique senectus et netus.
================================================
FILE: dev/pages/group.astro
================================================
---
import Layout from "../layout.astro";
import Exmaple from "../group";
---
================================================
FILE: dev/pages/index.astro
================================================
---
import Layout from "../layout.astro";
import Example from "../kitchen-sink";
---
================================================
FILE: dev/styles.css
================================================
body {
background-color: #1e1e1e;
color: #fff;
font-family: "Roboto", sans-serif;
}
main {
width: 100%;
max-width: 600px;
margin: 10vh auto;
}
h1 {
font-size: 2rem;
font-weight: 500;
}
h2 {
font-size: 1.5rem;
font-weight: 500;
}
h3 {
font-size: 1.25rem;
font-weight: 500;
}
h4 {
font-size: 1rem;
font-weight: 500;
}
h5 {
font-size: 0.875rem;
font-weight: 500;
}
h6 {
font-size: 0.75rem;
font-weight: 500;
}
button {
@apply bg-blue-600 text-white font-medium py-1 px-2 rounded;
@apply hover:bg-blue-700;
@apply focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-opacity-50;
@apply transition ease-in-out;
}
.container {
position: relative;
}
.fade-enter-active,
.fade-exit-active {
transition: opacity 0.5s;
}
.fade-enter,
.fade-exit-to {
opacity: 0;
}
.slide-fade-enter-active {
transition: all 0.3s ease;
}
.slide-fade-exit-active {
transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-exit-to {
transform: translateX(10px);
opacity: 0;
}
.bounce-enter-active {
animation: bounce-in 0.5s;
}
.bounce-exit-active {
animation: bounce-in 0.5s reverse;
}
@keyframes bounce-in {
0% {
transform: scale(0);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
.collapse-exit-active,
.collapse-enter-active {
overflow: hidden;
}
.group-item {
transition: all 0.5s;
}
.group-item-enter,
.group-item-exit-to {
opacity: 0;
transform: translateY(30px);
}
.group-item-exit-active {
position: absolute;
}
================================================
FILE: netlify.toml
================================================
[build]
base = "/"
publish = "dev/dist/"
command = "pnpm run build:site"
================================================
FILE: package.json
================================================
{
"name": "solid-transition-group",
"description": "Components to manage animations for SolidJS",
"author": "Ryan Carniato",
"license": "MIT",
"version": "0.3.0",
"homepage": "https://github.com/solidjs/solid-transition-group#readme",
"repository": {
"type": "git",
"url": "https://github.com/solidjs/solid-transition-group"
},
"sideEffects": false,
"private": false,
"type": "module",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist"
],
"scripts": {
"dev": "astro dev",
"build:site": "astro build",
"build": "tsc -b tsconfig.build.json",
"test:client": "vitest",
"test:ssr": "pnpm run test:client --mode ssr",
"test": "concurrently pnpm:test:*",
"format": "prettier -w **/*.{js,ts,json,css,tsx,jsx} --ignore-path .gitignore",
"prepublishOnly": "pnpm build"
},
"devDependencies": {
"@astrojs/solid-js": "^2.2.0",
"@astrojs/tailwind": "^4.0.0",
"astro": "^2.10.1",
"concurrently": "^9.1.2",
"jsdom": "^26.0.0",
"prettier": "^3.4.2",
"solid-js": "^1.9.4",
"tailwindcss": "^3.3.3",
"typescript": "^5.7.3",
"vite-plugin-solid": "^2.11.0",
"vitest": "^2.1.8"
},
"dependencies": {
"@solid-primitives/refs": "^1.1.0",
"@solid-primitives/transition-group": "^1.1.0"
},
"peerDependencies": {
"solid-js": "^1.6.12"
},
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">=20.0.0",
"pnpm": ">=9.0.0"
}
}
================================================
FILE: src/index.ts
================================================
import { createMemo, type FlowComponent, type JSX } from "solid-js";
import { createSwitchTransition, createListTransition } from "@solid-primitives/transition-group";
import { resolveFirst, resolveElements } from "@solid-primitives/refs";
function createClassnames(props: TransitionProps & TransitionGroupProps) {
return createMemo(() => {
const name = props.name || "s";
return {
enterActive: (props.enterActiveClass || name + "-enter-active").split(" "),
enter: (props.enterClass || name + "-enter").split(" "),
enterTo: (props.enterToClass || name + "-enter-to").split(" "),
exitActive: (props.exitActiveClass || name + "-exit-active").split(" "),
exit: (props.exitClass || name + "-exit").split(" "),
exitTo: (props.exitToClass || name + "-exit-to").split(" "),
move: (props.moveClass || name + "-move").split(" "),
};
});
}
// https://github.com/solidjs-community/solid-transition-group/issues/12
// for the css transition be triggered properly on firefox
// we need to wait for two frames before changeing classes
function nextFrame(fn: () => void) {
requestAnimationFrame(() => requestAnimationFrame(fn));
}
/**
* Run an enter transition on an element - common for both Transition and TransitionGroup
*/
function enterTransition(
classes: ReturnType>,
events: TransitionEvents,
el: Element,
done?: VoidFunction,
) {
const { onBeforeEnter, onEnter, onAfterEnter } = events;
// before the elements are added to the DOM
onBeforeEnter?.(el);
el.classList.add(...classes.enter);
el.classList.add(...classes.enterActive);
// after the microtask the elements will be added to the DOM
// and onEnter will be called in the same frame
queueMicrotask(() => {
// Don't animate element if it's not in the DOM
// This can happen when elements are changed under Suspense
if (!el.parentNode) return done?.();
onEnter?.(el, () => endTransition());
});
nextFrame(() => {
el.classList.remove(...classes.enter);
el.classList.add(...classes.enterTo);
if (!onEnter || onEnter.length < 2) {
el.addEventListener("transitionend", endTransition);
el.addEventListener("animationend", endTransition);
}
});
function endTransition(e?: Event) {
if (!e || e.target === el) {
done?.(); // starts exit transition in "in-out" mode
el.removeEventListener("transitionend", endTransition);
el.removeEventListener("animationend", endTransition);
el.classList.remove(...classes.enterActive);
el.classList.remove(...classes.enterTo);
onAfterEnter?.(el);
}
}
}
/**
* @private
*
* Run an exit transition on an element - common for both Transition and TransitionGroup
*/
export function exitTransition(
classes: ReturnType>,
events: TransitionEvents,
el: Element,
done?: VoidFunction,
) {
const { onBeforeExit, onExit, onAfterExit } = events;
// Don't animate element if it's not in the DOM
// This can happen when elements are changed under Suspense
if (!el.parentNode) return done?.();
onBeforeExit?.(el);
el.classList.add(...classes.exit);
el.classList.add(...classes.exitActive);
onExit?.(el, () => endTransition());
nextFrame(() => {
el.classList.remove(...classes.exit);
el.classList.add(...classes.exitTo);
if (!onExit || onExit.length < 2) {
el.addEventListener("transitionend", endTransition);
el.addEventListener("animationend", endTransition);
}
});
function endTransition(e?: Event) {
if (!e || e.target === el) {
// calling done() will remove element from the DOM,
// but also trigger onChange callback in .
// Which is why the classes need to removed afterwards,
// so that removing them won't change el styles when for the move transition
done?.();
el.removeEventListener("transitionend", endTransition);
el.removeEventListener("animationend", endTransition);
el.classList.remove(...classes.exitActive);
el.classList.remove(...classes.exitTo);
onAfterExit?.(el);
}
}
}
export type TransitionEvents = {
/**
* Function called before the enter transition starts.
* The {@link element} is not yet rendered.
*/
onBeforeEnter?: (element: Element) => void;
/**
* Function called when the enter transition starts.
* The {@link element} is rendered to the DOM.
*
* Call {@link done} to end the transition - removes the enter classes,
* and calls {@link TransitionEvents.onAfterEnter}.
* If the parameter for {@link done} is not provided, it will be called on `transitionend` or `animationend`.
*/
onEnter?: (element: Element, done: () => void) => void;
/**
* Function called after the enter transition ends.
* The {@link element} is removed from the DOM.
*/
onAfterEnter?: (element: Element) => void;
/**
* Function called before the exit transition starts.
* The {@link element} is still rendered, exit classes are not yet applied.
*/
onBeforeExit?: (element: Element) => void;
/**
* Function called when the exit transition starts, after the exit classes are applied
* ({@link TransitionProps.enterToClass} and {@link TransitionProps.exitActiveClass}).
* The {@link element} is still rendered.
*
* Call {@link done} to end the transition - removes exit classes,
* calls {@link TransitionEvents.onAfterExit} and removes the element from the DOM.
* If the parameter for {@link done} is not provided, it will be called on `transitionend` or `animationend`.
*/
onExit?: (element: Element, done: () => void) => void;
/**
* Function called after the exit transition ends.
* The {@link element} is removed from the DOM.
*/
onAfterExit?: (element: Element) => void;
};
/**
* Props for the {@link Transition} component.
*/
export type TransitionProps = TransitionEvents & {
/**
* Used to automatically generate transition CSS class names.
* e.g. `name: 'fade'` will auto expand to `.fade-enter`, `.fade-enter-active`, etc.
* Defaults to `"s"`.
*/
name?: string;
/**
* CSS class applied to the entering element for the entire duration of the enter transition.
* Defaults to `"s-enter-active"`.
*/
enterActiveClass?: string;
/**
* CSS class applied to the entering element at the start of the enter transition, and removed the frame after.
* Defaults to `"s-enter"`.
*/
enterClass?: string;
/**
* CSS class applied to the entering element after the enter transition starts.
* Defaults to `"s-enter-to"`.
*/
enterToClass?: string;
/**
* CSS class applied to the exiting element for the entire duration of the exit transition.
* Defaults to `"s-exit-active"`.
*/
exitActiveClass?: string;
/**
* CSS class applied to the exiting element at the start of the exit transition, and removed the frame after.
* Defaults to `"s-exit"`.
*/
exitClass?: string;
/**
* CSS class applied to the exiting element after the exit transition starts.
* Defaults to `"s-exit-to"`.
*/
exitToClass?: string;
/**
* Whether to apply transition on initial render. Defaults to `false`.
*/
appear?: boolean;
/**
* Controls the timing sequence of leaving/entering transitions.
* Available modes are `"outin"` and `"inout"`;
* Defaults to simultaneous.
*/
mode?: "inout" | "outin";
};
const TRANSITION_MODE_MAP = {
inout: "in-out",
outin: "out-in",
} as const;
/**
* The `` component lets you apply enter and leave animations on element passed to `props.children`.
*
* It only supports transitioning a single element at a time.
*
* @param props {@link TransitionProps}
*/
export const Transition: FlowComponent = props => {
const classnames = createClassnames(props);
return createSwitchTransition(
resolveFirst(() => props.children),
{
mode: TRANSITION_MODE_MAP[props.mode!],
appear: props.appear,
onEnter(el, done) {
enterTransition(classnames(), props, el, done);
},
onExit(el, done) {
exitTransition(classnames(), props, el, done);
},
},
) as unknown as JSX.Element;
};
/**
* Props for the {@link TransitionGroup} component.
*/
export type TransitionGroupProps = Omit & {
/**
* CSS class applied to the moving elements for the entire duration of the move transition.
* Defaults to `"s-move"`.
*/
moveClass?: string;
};
/**
* The `` component lets you apply enter and leave animations on elements passed to `props.children`.
*
* It supports transitioning multiple elements at a time and moving elements around.
*
* @param props {@link TransitionGroupProps}
*/
export const TransitionGroup: FlowComponent = props => {
const classnames = createClassnames(props);
return createListTransition(resolveElements(() => props.children).toArray, {
appear: props.appear,
exitMethod: "keep-index",
onChange({ added, removed, finishRemoved, list }) {
const classes = classnames();
// ENTER
for (const el of added) {
enterTransition(classes, props, el);
}
// MOVE
const toMove: { el: HTMLElement | SVGElement; rect: DOMRect }[] = [];
// get rects of elements before the changes to the DOM
for (const el of list) {
if (el.isConnected && (el instanceof HTMLElement || el instanceof SVGElement)) {
toMove.push({ el, rect: el.getBoundingClientRect() });
}
}
// wait for th new list to be rendered
queueMicrotask(() => {
const moved: (HTMLElement | SVGElement)[] = [];
for (const { el, rect } of toMove) {
if (el.isConnected) {
const newRect = el.getBoundingClientRect(),
dX = rect.left - newRect.left,
dY = rect.top - newRect.top;
if (dX || dY) {
// set els to their old position before transition
el.style.transform = `translate(${dX}px, ${dY}px)`;
el.style.transitionDuration = "0s";
moved.push(el);
}
}
}
document.body.offsetHeight; // force reflow
for (const el of moved) {
el.classList.add(...classes.move);
// clear transition - els will move to their new position
el.style.transform = el.style.transitionDuration = "";
function endTransition(e: Event) {
if (e.target === el || /transform$/.test((e as TransitionEvent).propertyName)) {
el.removeEventListener("transitionend", endTransition);
el.classList.remove(...classes.move);
}
}
el.addEventListener("transitionend", endTransition);
}
});
// EXIT
for (const el of removed) {
exitTransition(classes, props, el, () => finishRemoved([el]));
}
},
}) as unknown as JSX.Element;
};
================================================
FILE: tailwind.config.cjs
================================================
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
theme: {
extend: {}
},
plugins: []
};
================================================
FILE: test/index.test.tsx
================================================
// Flush animation frames manually
const rafQueue: VoidFunction[] = [];
(globalThis as any).requestAnimationFrame = (cb: VoidFunction) => {
rafQueue.push(cb);
};
function flushRaf() {
const queue = rafQueue.slice();
rafQueue.length = 0;
queue.forEach(cb => cb());
}
import { Show, createRoot, createSignal } from "solid-js";
import { describe, expect, it } from "vitest";
import { Transition, exitTransition } from "../src/index.js";
describe("Transition", () => {
it("matches the timing of vue out-in transition", async () => {
const captured: [type: string, parentNode: boolean, classname: string][] = [];
let runEnter!: VoidFunction;
let runExit!: VoidFunction;
function onBeforeEnter(el: Element) {
captured.push(["before enter", el.parentNode !== null, el.className]);
requestAnimationFrame(() => {
captured.push(["1 frame", el.parentNode !== null, el.className]);
requestAnimationFrame(() => {
captured.push(["2 frame", el.parentNode !== null, el.className]);
requestAnimationFrame(() => {
captured.push(["3 frame", el.parentNode !== null, el.className]);
});
});
});
}
function onEnter(el: Element, done: VoidFunction) {
captured.push(["enter", el.parentNode !== null, el.className]);
runEnter = done;
}
function onAfterEnter(el: Element) {
captured.push(["after enter", el.parentNode !== null, el.className]);
}
function onBeforeExit(el: Element) {
captured.push(["before exit", el.parentNode !== null, el.className]);
}
function onExit(el: Element, done: VoidFunction) {
captured.push(["exit", el.parentNode !== null, el.className]);
runExit = done;
}
function onAfterExit(el: Element) {
captured.push(["after exit", el.parentNode !== null, el.className]);
}
const [page, setPage] = createSignal(1);
const dispose = createRoot(dispose => {