Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HeightGroup {
- constructor(els) {
- this.nodeArray = [...els]
- this.nodeHeights
- this.newHeight
- }
- matchHeights() {
- this.nodeHeights = []
- this.newHeight = null
- this.nodeArray.forEach(node => {
- node.style.minHeight = ''
- this.nodeHeights.push(node.offsetHeight)
- })
- this.newHeight = Math.max.apply(null, this.nodeHeights)
- this.nodeArray.forEach(node => {
- node.style.minHeight = `${this.newHeight}px`
- })
- }
- watchElements() {
- window.addEventListener('resize', this.matchHeights)
- this.matchHeights()
- }
- destroy() {
- window.removeEventListener('resize', this.matchHeights)
- this.nodeArray.forEach(node => {
- node.style.minHeight = ''
- })
- }
- }
- export default HeightGroup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement