Created
April 16, 2019 17:10
-
-
Save iErik/89f24bce8f84dd27b6e68d79bd692cd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Collapsible = (refName = 'contentWrapper') => ({ | |
| data: () => ({ | |
| hideContents: false, | |
| contentObs: null, | |
| contentHeight: 0, | |
| }), | |
| mounted () { | |
| this.$nextTick(() => { | |
| const el = this.$refs[refName].childNodes[0] | |
| this.contentObs = new ResizeObserver(ev => { | |
| const rect = ev[0].target.getBoundingClientRect() | |
| this.contentHeight = rect.height | |
| }) | |
| this.contentObs.observe(el) | |
| }) | |
| }, | |
| beforeDestroy () { | |
| this.contentObs.disconnect() | |
| } | |
| }) | |
| export default Collapsible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment