MCPcopy
hub / github.com/vuejs/core / setup

Function setup

packages/runtime-dom/src/components/TransitionGroup.ts:70–180  ·  view source on GitHub ↗
(props: TransitionGroupProps, { slots }: SetupContext)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

getCurrentInstanceFunction · 0.90
useTransitionStateFunction · 0.90
forceReflowFunction · 0.90
addTransitionClassFunction · 0.90
removeTransitionClassFunction · 0.90
resolveTransitionPropsFunction · 0.90
setTransitionHooksFunction · 0.90
resolveTransitionHooksFunction · 0.90
getTransitionRawChildrenFunction · 0.90
warnFunction · 0.90
hasCSSTransformFunction · 0.85
toRawFunction · 0.85

Tested by

no test coverage detected