Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
fix(skeleton): use TransitionGroup instead of Transition
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Dec 25, 2020
1 parent 25e980a commit e739dea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/skeleton/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
VNode,
PropType,
computed,
Transition
TransitionGroup,
} from "vue"

import {
Expand Down Expand Up @@ -140,14 +140,23 @@ const AtSkeleton = defineComponent({
}

function genSkeleton() {
const children: any[] = []
let children: any[] = []

if (!isLoading.value) children.push(slots.default?.())
else children.push(genStructure())

if (!props.transition) return children

return h(Transition, {
// children must be keyed when using TransitionGroup
children = children.map((child) => {
child.map((c, index) => {
c.key = index
return c
})
return child
})

return h(TransitionGroup, {
onAfterEnter: resetStyles,
onBeforeEnter: onBeforeEnter,
onBeforeLeave: onBeforeLeave,
Expand Down
1 change: 1 addition & 0 deletions src/pages/advanced/skeleton/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<example-item>
<at-skeleton
style="margin: 10px;"
transition=".3s ease"
type="list-item-avatar, divider, list-item-three-line, card-heading, image, actions"
>
</at-skeleton>
Expand Down

0 comments on commit e739dea

Please sign in to comment.