useAutoAnimatedHeight
Animer endring av høyden når innholdet endrer seg. Hooken tar inn en triggerverdi, og når denne endrer seg animeres høyden på elementet dersom den har endret seg.
Kom i gang
Se oversikten for hvordan installere pakken.
Live demo
useAutoAnimatedHeight
Visning
function Demo() {const [content, setContent] = React.useState(randomContentBlock());const animationRef = useAutoAnimatedHeight(content);const changeContent = () => {setContent(randomContentBlock(content));};return (<section ref={animationRef} className="auto-animation-example"><p className="jkl-heading-2">Lorem Ipsum</p>{content}<buttonclassName="jkl-button jkl-button--secondary"data-density="compact"onClick={changeContent}>Endre innhold</button></section>);}const content1 = (<><p className="jkl-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industrys standard dummy text ever since the1500s, when an unknown printer took a galley of type and scrambled it tomake a type specimen book.</p></>);const content2 = (<><p className="jkl-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industrys standard dummy text ever since the1500s, when an unknown printer took a galley of type and scrambled it tomake a type specimen book.</p><p className="jkl-body">It has survived not only five centuries, but also the leap into electronictypesetting, remaining essentially unchanged.</p></>);const content3 = (<><p className="jkl-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industrys standard dummy text ever since the1500s, when an unknown printer took a galley of type and scrambled it tomake a type specimen book.</p><p className="jkl-body">It has survived not only five centuries, but also the leap into electronictypesetting, remaining essentially unchanged.</p><p className="jkl-body">It was popularised in the 1960s with the release of Letraset sheetscontaining Lorem Ipsum passages, and more recently with desktop publishingsoftware like Aldus PageMaker including versions of Lorem Ipsum.</p></>);const content4 = (<><p className="jkl-body">Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industrys standard dummy text ever since the1500s, when an unknown printer took a galley of type and scrambled it tomake a type specimen book.</p><p className="jkl-body">It has survived not only five centuries, but also the leap into electronictypesetting, remaining essentially unchanged.</p><p className="jkl-body">It was popularised in the 1960s with the release of Letraset sheetscontaining Lorem Ipsum passages, and more recently with desktop publishingsoftware like Aldus PageMaker including versions of Lorem Ipsum.</p><p className="jkl-body">Contrary to popular belief, Lorem Ipsum is not simply random text. It hasroots in a piece of classical Latin literature from 45 BC, making it over2000 years old.</p></>);const contentBlocks = [content1, content2, content3, content4];function randomContentBlock(except) {let content = contentBlocks[Math.floor(Math.random() * contentBlocks.length)];if (content === except) {content = randomContentBlock(except);}return content;}render(<Demo />);
React API
Her finner du en oversikt over props på komponentene i pakken.