-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add record block layout options (wrap, no wrap)
- Loading branch information
Showing
8 changed files
with
217 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
export default { | ||
data () { | ||
return { | ||
resizeObserver: null, | ||
columnWrapClass: '', | ||
} | ||
}, | ||
|
||
methods: { | ||
initializeResizeObserver (el) { | ||
this.resizeObserver = new ResizeObserver((entries) => { | ||
for (let entry of entries) { | ||
// Handle the resize event here | ||
this.applyColumnClasses(entry.contentRect.width) | ||
} | ||
}) | ||
|
||
this.resizeObserver.observe(el) | ||
}, | ||
|
||
applyColumnClasses (width) { | ||
const breakpoints = { | ||
xs: 576, | ||
md: 768, | ||
lg: 992, | ||
xl: 1200, | ||
} | ||
|
||
const columnClasses = { | ||
xs: 'col-12', | ||
md: 'col-6', | ||
lg: 'col-4', | ||
xl: 'col-3', | ||
} | ||
|
||
let columnClass | ||
|
||
switch (true) { | ||
case width <= breakpoints.xs: | ||
columnClass = columnClasses.xs | ||
break | ||
case width > breakpoints.xs && width <= breakpoints.md: | ||
columnClass = columnClasses.md | ||
break | ||
case width > breakpoints.md && width <= breakpoints.lg: | ||
columnClass = columnClasses.lg | ||
break | ||
default: | ||
columnClass = columnClasses.xl | ||
break | ||
} | ||
|
||
this.columnWrapClass = `field-col ${columnClass}` | ||
}, | ||
|
||
destroyEvents (el) { | ||
if (this.resizeObserver) { | ||
this.resizeObserver.unobserve(el) | ||
this.resizeObserver.disconnect() | ||
} | ||
}, | ||
}, | ||
} |
Oops, something went wrong.