šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

solid-transition-size

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solid-transition-size

SolidJS utility which makes it possible to transition the width and height of elements that don't have a fixed size applied.

0.1.4
latest
Source
npm
Version published
Weekly downloads
1.5K
-5.07%
Maintainers
0
Weekly downloads
Ā 
Created
Source
Solid Transition Size

SolidJS utility which makes it possible to transition the width and height of elements that don't have a fixed size applied.

Features

  • Works with any CSS transition configuration
  • Specify which dimension to observe (width, height, or both)
  • Uses a ResizeObserver to detect changes in the size of the element

Usage

The utility returns two signals: transitioning and transitionSize. transitioning can be used to know when the transition is happening, and transitionSize returns the fixed size of the element while transitioning. You have to use it to style the element you want to transition.

import createTransitionSize from 'solid-transition-size';

For a very simple example we can take the <details> element and transition the height when it is toggled:

const Details = () => {
  const [ref, setRef] = createSignal<HTMLElement | null>(null)
  const { transitionSize } = createTransitionSize({
    element: ref,
    dimension: 'height',
  })

  const height = () => {
    if (!transitionSize()) return undefined
    return transitionSize() + 'px'
  }

  return (
    <details
      ref={setRef}
      class="transition-[height]"
      style={{
        height: height(),
      }}
    >
      <summary>Show detail</summary>
      Detail
    </details>
  )
}

Further Reading

This utility is from the maintainers of corvu, a collection of unstyled, accessible and customizable UI primitives for SolidJS. It is also documented in the corvu docs under Transition Size.

Keywords

solid

FAQs

Package last updated on 04 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts