Skip to content

1.3.3 #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vue-collapsed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-collapsed",
"version": "1.3.2",
"version": "1.3.3",
"private": false,
"description": "Dynamic CSS height transition from any to auto and vice versa for Vue 3. Accordion ready.",
"keywords": [
Expand Down
9 changes: 9 additions & 0 deletions packages/vue-collapsed/src/Collapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ onMounted(() => {
// Collapse / Expand handler

watch(isExpanded, (isExpanding) => {
if (!collapseRef.value) return

if (isExpanding) {
if (isReducedOrDisabled(collapseRef)) return onExpanded()

Expand All @@ -161,7 +163,11 @@ watch(isExpanded, (isExpanding) => {
})

requestAnimationFrame(() => {
/** If for any unknown edge case the scrollHeight === 0, abort transition and force expand */
if (collapseRef.value!.scrollHeight === 0) return onExpanded()

/** Set height to scrollHeight and trigger the transition. */

addStyles({
...getHeightProp(collapseRef),
...getTransitionProp(collapseRef),
Expand All @@ -186,6 +192,9 @@ watch(isExpanded, (isExpanding) => {
...getHeightProp(collapseRef),
})

/** Same as for expand, abort transition and force collapse */
if (collapseRef.value.scrollHeight === 0) return onCollapsed()

requestAnimationFrame(() => {
/** Set height to baseHeight and trigger the transition. */
addStyles({
Expand Down
Loading