Download pool/shard005/JavaScript/0031205_collapse.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard005/JavaScript/0031205_collapse.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard005/JavaScript/0031205_collapse.js
-
curl -L -o 0031205_collapse.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard005/JavaScript/0031205_collapse.js
1.17 kB
| import anim from '../src'; | |
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { storiesOf } from '@storybook/react'; | |
| const style = ` | |
| .box { | |
| background:red; | |
| width:100px; | |
| height:100px; | |
| } | |
| .collapse-active { | |
| transition: height .3s ease-out; | |
| } | |
| `; | |
| let show = true; | |
| function toggle() { | |
| const t = document.getElementById('t'); | |
| const b = document.getElementById('b'); | |
| b.disabled = true; | |
| t.style.display = ''; | |
| let height; | |
| anim(t, `collapse`, { | |
| start() { | |
| if (show) { | |
| t.style.height = `${t.offsetHeight}px`; | |
| } else { | |
| height = t.offsetHeight; | |
| t.style.height = 0; | |
| } | |
| }, | |
| active() { | |
| t.style.height = `${show ? height : 0}px`; | |
| }, | |
| end() { | |
| t.style.display = show ? '' : 'none'; | |
| b.disabled = false; | |
| t.style.height = ''; | |
| }, | |
| }); | |
| show = !show; | |
| } | |
| const Demo = () => ( | |
| <div> | |
| <style dangerouslySetInnerHTML={{ __html: style }}></style> | |
| <div className="box" id="t"></div> | |
| <button onClick={toggle} id="b"> | |
| toggle | |
| </button> | |
| </div> | |
| ); | |
| Demo.story = 'collapse'; | |
| storiesOf(Demo.story, module).add('demo', () => <Demo />); | |
| export default Demo; | |