(props: TransitionGroupProps, { slots }: SetupContext)
| 68 | }), |
| 69 | |
| 70 | setup(props: TransitionGroupProps, { slots }: SetupContext) { |
| 71 | const instance = getCurrentInstance()! |
| 72 | const state = useTransitionState() |
| 73 | let prevChildren: VNode[] |
| 74 | let children: VNode[] |
| 75 | |
| 76 | onUpdated(() => { |
| 77 | // children is guaranteed to exist after initial render |
| 78 | if (!prevChildren.length) { |
| 79 | return |
| 80 | } |
| 81 | const moveClass = props.moveClass || `${props.name || 'v'}-move` |
| 82 | |
| 83 | if ( |
| 84 | !hasCSSTransform( |
| 85 | prevChildren[0].el as ElementWithTransition, |
| 86 | instance.vnode.el as Node, |
| 87 | moveClass, |
| 88 | ) |
| 89 | ) { |
| 90 | prevChildren = [] |
| 91 | return |
| 92 | } |
| 93 | |
| 94 | // we divide the work into three loops to avoid mixing DOM reads and writes |
| 95 | // in each iteration - which helps prevent layout thrashing. |
| 96 | prevChildren.forEach(callPendingCbs) |
| 97 | prevChildren.forEach(recordPosition) |
| 98 | const movedChildren = prevChildren.filter(applyTranslation) |
| 99 | |
| 100 | // force reflow to put everything in position |
| 101 | forceReflow(instance.vnode.el as Node) |
| 102 | |
| 103 | movedChildren.forEach(c => { |
| 104 | const el = c.el as ElementWithTransition |
| 105 | const style = el.style |
| 106 | addTransitionClass(el, moveClass) |
| 107 | style.transform = style.webkitTransform = style.transitionDuration = '' |
| 108 | const cb = ((el as any)[moveCbKey] = (e: TransitionEvent) => { |
| 109 | if (e && e.target !== el) { |
| 110 | return |
| 111 | } |
| 112 | if (!e || e.propertyName.endsWith('transform')) { |
| 113 | el.removeEventListener('transitionend', cb) |
| 114 | ;(el as any)[moveCbKey] = null |
| 115 | removeTransitionClass(el, moveClass) |
| 116 | } |
| 117 | }) |
| 118 | el.addEventListener('transitionend', cb) |
| 119 | }) |
| 120 | prevChildren = [] |
| 121 | }) |
| 122 | |
| 123 | return () => { |
| 124 | const rawProps = toRaw(props) |
| 125 | const cssTransitionProps = resolveTransitionProps(rawProps) |
| 126 | let tag = rawProps.tag || Fragment |
| 127 |
nothing calls this directly
no test coverage detected