pbca26
8 years ago
3 changed files with 37 additions and 37 deletions
@ -0,0 +1,35 @@ |
|||
import cssAnimation from 'css-animation'; |
|||
|
|||
function animate(node, show, done) { |
|||
let height = node.offsetHeight; |
|||
|
|||
return cssAnimation(node, 'collapse', { |
|||
start() { |
|||
if (!show) { |
|||
node.style.height = `${node.offsetHeight}px`; |
|||
} else { |
|||
height = node.offsetHeight; |
|||
node.style.height = 0; |
|||
} |
|||
}, |
|||
active() { |
|||
node.style.height = `${show ? height : 0}px`; |
|||
}, |
|||
end() { |
|||
node.style.height = ''; |
|||
done(); |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
export const animation = { |
|||
enter(node, done) { |
|||
return animate(node, true, done); |
|||
}, |
|||
leave(node, done) { |
|||
return animate(node, false, done); |
|||
}, |
|||
appear(node, done) { |
|||
return animate(node, true, done); |
|||
}, |
|||
}; |
Loading…
Reference in new issue