App.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <script vapor>
  2. import {
  3. createComponent,
  4. defineVaporComponent,
  5. ref,
  6. shallowRef,
  7. VaporTransition,
  8. createIf,
  9. template,
  10. defineVaporAsyncComponent,
  11. onUnmounted,
  12. onUpdated,
  13. setElementText,
  14. renderEffect,
  15. inject,
  16. provide,
  17. child,
  18. txt,
  19. applyVShow,
  20. setText,
  21. delegateEvents,
  22. toDisplayString,
  23. } from 'vue'
  24. const show = ref(true)
  25. const toggle = ref(true)
  26. const count = ref(0)
  27. const timeout = (fn, time) => setTimeout(fn, time)
  28. const duration = window.__TRANSITION_DURATION__ || 50
  29. let calls = {
  30. basic: [],
  31. withoutAppear: [],
  32. withArgs: [],
  33. enterCancel: [],
  34. withAppear: [],
  35. cssFalse: [],
  36. ifInOut: [],
  37. show: [],
  38. showLeaveCancel: [],
  39. showAppear: [],
  40. notEnter: [],
  41. updated: [],
  42. unmount: [],
  43. }
  44. window.getCalls = key => calls[key]
  45. window.resetCalls = key => (calls[key] = [])
  46. import VaporCompA from './components/VaporCompA.vue'
  47. import VaporCompB from './components/VaporCompB.vue'
  48. const activeComponent = shallowRef(VaporCompB)
  49. function toggleComponent() {
  50. activeComponent.value =
  51. activeComponent.value === VaporCompA ? VaporCompB : VaporCompA
  52. }
  53. const toggleVdom = ref(true)
  54. import VDomComp from './components/VdomComp.vue'
  55. const interopComponent = shallowRef(VDomComp)
  56. function toggleInteropComponent() {
  57. interopComponent.value =
  58. interopComponent.value === VaporCompA ? VDomComp : VaporCompA
  59. }
  60. const name = ref('test')
  61. const MyTransition = defineVaporComponent((props, { slots }) => {
  62. return createComponent(VaporTransition, { name: () => 'test' }, slots)
  63. })
  64. const MyTransitionFallthroughAttr = defineVaporComponent((props, { slots }) => {
  65. return createComponent(
  66. VaporTransition,
  67. { foo: () => 1, name: () => 'test' },
  68. slots,
  69. )
  70. })
  71. const One = defineVaporComponent({
  72. setup() {
  73. return createIf(
  74. () => false,
  75. () => template('<div>one</div>', true)(),
  76. )
  77. },
  78. })
  79. const Two = defineVaporComponent({
  80. setup() {
  81. return template('<div>two</div>', true)()
  82. },
  83. })
  84. const view = shallowRef(One)
  85. function changeView() {
  86. view.value = view.value === One ? Two : One
  87. }
  88. const SimpleOne = defineVaporComponent({
  89. setup() {
  90. return template('<div>one</div>', true)()
  91. },
  92. })
  93. const viewInOut = shallowRef(SimpleOne)
  94. function changeViewInOut() {
  95. viewInOut.value = viewInOut.value === SimpleOne ? Two : SimpleOne
  96. }
  97. const AsyncComp = defineVaporAsyncComponent(() => {
  98. return new Promise(resolve => setTimeout(() => resolve(VaporCompA), 50))
  99. })
  100. const TrueBranch = defineVaporComponent({
  101. name: 'TrueBranch',
  102. setup() {
  103. onUnmounted(() => {
  104. calls.unmount.push('TrueBranch')
  105. })
  106. return template('<div>0</div>')()
  107. },
  108. })
  109. const includeRef = ref(['TrueBranch'])
  110. const click = () => {
  111. toggle.value = !toggle.value
  112. if (toggle.value) {
  113. includeRef.value = ['TrueBranch']
  114. } else {
  115. includeRef.value = []
  116. }
  117. }
  118. const CompA = defineVaporComponent({
  119. name: 'CompA',
  120. setup() {
  121. onUpdated(() => {
  122. calls.updated.push('CompA updated')
  123. })
  124. return template('<div>CompA</div>')()
  125. },
  126. })
  127. const CompB = defineVaporComponent({
  128. name: 'CompB',
  129. setup() {
  130. return template('<div>CompB</div>')()
  131. },
  132. })
  133. const CompC = defineVaporComponent({
  134. name: 'CompC',
  135. setup() {
  136. onUnmounted(() => {
  137. calls.unmount.push('CompC unmounted')
  138. })
  139. return template('<div>CompC</div>')()
  140. },
  141. })
  142. const includeToChange = ref(['CompA', 'CompB', 'CompC'])
  143. const currentView = shallowRef(CompA)
  144. const switchToB = () => (currentView.value = CompB)
  145. const switchToC = () => (currentView.value = CompC)
  146. const switchToA = () => {
  147. currentView.value = CompA
  148. includeToChange.value = ['CompA']
  149. }
  150. const CompA2 = defineVaporComponent({
  151. name: 'CompA2',
  152. setup() {
  153. const current = inject('currentView2')
  154. const n0 = template('<div></div>')()
  155. renderEffect(() => setElementText(n0, toDisplayString(current.value.name)))
  156. return n0
  157. },
  158. })
  159. const CompB2 = defineVaporComponent({
  160. name: 'CompB2',
  161. setup() {
  162. onUnmounted(() => {
  163. calls.unmount.push('CompB2 unmounted')
  164. })
  165. const current = inject('currentView2')
  166. const n0 = template('<div></div>')()
  167. renderEffect(() => setElementText(n0, toDisplayString(current.value.name)))
  168. return n0
  169. },
  170. })
  171. const includeRef2 = ref(['CompA2'])
  172. const currentView2 = shallowRef(CompA2)
  173. provide('currentView2', currentView2)
  174. const switchToB2 = () => {
  175. currentView2.value = CompB2
  176. includeRef2.value = ['CompA2', 'CompB2']
  177. }
  178. const switchToA2 = () => {
  179. currentView2.value = CompA2
  180. includeRef2.value = ['CompA2']
  181. }
  182. const show2 = ref(true)
  183. const state = ref(1)
  184. const Item = defineVaporComponent({
  185. name: 'Item',
  186. setup() {
  187. return createComponent(
  188. VaporTransition,
  189. { name: () => 'test', persisted: () => '' },
  190. {
  191. default: () => {
  192. const n1 = template('<div><h2> </h2></div>')()
  193. const n0 = child(n1)
  194. const x0 = txt(n0)
  195. applyVShow(n1, () => show2.value)
  196. renderEffect(() =>
  197. setText(
  198. x0,
  199. toDisplayString(
  200. show2.value ? 'I should show' : "I shouldn't show ",
  201. ),
  202. ),
  203. )
  204. return n1
  205. },
  206. },
  207. )
  208. },
  209. })
  210. const Comp1 = defineVaporComponent({
  211. name: 'Comp1',
  212. setup() {
  213. delegateEvents('click')
  214. const n0 = createComponent(Item)
  215. const n1 = template('<h2>This is page1</h2>')()
  216. const n2 = template('<button id="changeShowBtn"></button>')()
  217. n2.$evtclick = () => (show2.value = !show2.value)
  218. renderEffect(() => {
  219. setElementText(n2, show2.value)
  220. })
  221. return [n0, n1, n2]
  222. },
  223. })
  224. const Comp2 = defineVaporComponent({
  225. name: 'Comp2',
  226. setup() {
  227. return template('<h2>This is page2</h2>')()
  228. },
  229. })
  230. </script>
  231. <template>
  232. <div class="transition-container">
  233. <!-- work with vif -->
  234. <div class="if-basic">
  235. <div>
  236. <transition>
  237. <div v-if="toggle" class="test">content</div>
  238. </transition>
  239. </div>
  240. <button @click="toggle = !toggle">basic toggle</button>
  241. </div>
  242. <div class="if-named">
  243. <div>
  244. <transition name="test">
  245. <div v-if="toggle" class="test">content</div>
  246. </transition>
  247. </div>
  248. <button @click="toggle = !toggle">button</button>
  249. </div>
  250. <div class="if-custom-classes">
  251. <div>
  252. <transition
  253. enter-from-class="hello-from"
  254. enter-active-class="hello-active"
  255. enter-to-class="hello-to"
  256. leave-from-class="bye-from"
  257. leave-active-class="bye-active"
  258. leave-to-class="bye-to"
  259. >
  260. <div v-if="toggle" class="test">content</div>
  261. </transition>
  262. </div>
  263. <button @click="toggle = !toggle">button</button>
  264. </div>
  265. <div class="if-dynamic-name">
  266. <div>
  267. <transition :name="name">
  268. <div v-if="toggle" class="test">content</div>
  269. </transition>
  270. </div>
  271. <button class="toggle" @click="toggle = !toggle">button</button>
  272. <button class="change" @click="name = 'changed'">{{ name }}</button>
  273. </div>
  274. <div class="if-events-without-appear">
  275. <div>
  276. <transition
  277. name="test"
  278. @before-enter="() => calls.withoutAppear.push('beforeEnter')"
  279. @enter="() => calls.withoutAppear.push('onEnter')"
  280. @after-enter="() => calls.withoutAppear.push('afterEnter')"
  281. @beforeLeave="() => calls.withoutAppear.push('beforeLeave')"
  282. @leave="() => calls.withoutAppear.push('onLeave')"
  283. @afterLeave="() => calls.withoutAppear.push('afterLeave')"
  284. >
  285. <div v-if="toggle" class="test">content</div>
  286. </transition>
  287. </div>
  288. <button @click="toggle = !toggle">button</button>
  289. </div>
  290. <div class="if-events-with-args">
  291. <div>
  292. <transition
  293. :css="false"
  294. name="test"
  295. @before-enter="
  296. el => {
  297. calls.withArgs.push('beforeEnter')
  298. el.classList.add('before-enter')
  299. }
  300. "
  301. @enter="
  302. (el, done) => {
  303. calls.withArgs.push('onEnter')
  304. el.classList.add('enter')
  305. timeout(done, 200)
  306. }
  307. "
  308. @after-enter="
  309. el => {
  310. calls.withArgs.push('afterEnter')
  311. el.classList.add('after-enter')
  312. }
  313. "
  314. @before-leave="
  315. el => {
  316. calls.withArgs.push('beforeLeave')
  317. el.classList.add('before-leave')
  318. }
  319. "
  320. @leave="
  321. (el, done) => {
  322. calls.withArgs.push('onLeave')
  323. el.classList.add('leave')
  324. timeout(done, 200)
  325. }
  326. "
  327. @after-leave="
  328. () => {
  329. calls.withArgs.push('afterLeave')
  330. }
  331. "
  332. >
  333. <div v-if="toggle" class="test">content</div>
  334. </transition>
  335. </div>
  336. <button @click="toggle = !toggle">button</button>
  337. </div>
  338. <div class="if-enter-cancelled">
  339. <div>
  340. <transition
  341. name="test"
  342. @enter-cancelled="
  343. () => {
  344. calls.enterCancel.push('enterCancelled')
  345. }
  346. "
  347. >
  348. <div v-if="!toggle" class="test">content</div>
  349. </transition>
  350. </div>
  351. <button @click="toggle = !toggle">cancelled</button>
  352. </div>
  353. <div class="if-appear">
  354. <div>
  355. <transition
  356. name="test"
  357. appear
  358. appear-from-class="test-appear-from"
  359. appear-to-class="test-appear-to"
  360. appear-active-class="test-appear-active"
  361. >
  362. <div v-if="toggle" class="test">content</div>
  363. </transition>
  364. </div>
  365. <button @click="toggle = !toggle">button</button>
  366. </div>
  367. <div class="if-events-with-appear">
  368. <div>
  369. <transition
  370. name="test"
  371. appear
  372. appear-from-class="test-appear-from"
  373. appear-to-class="test-appear-to"
  374. appear-active-class="test-appear-active"
  375. @beforeEnter="() => calls.withAppear.push('beforeEnter')"
  376. @enter="() => calls.withAppear.push('onEnter')"
  377. @afterEnter="() => calls.withAppear.push('afterEnter')"
  378. @beforeLeave="() => calls.withAppear.push('beforeLeave')"
  379. @leave="() => calls.withAppear.push('onLeave')"
  380. @afterLeave="() => calls.withAppear.push('afterLeave')"
  381. @beforeAppear="() => calls.withAppear.push('beforeAppear')"
  382. @appear="() => calls.withAppear.push('onAppear')"
  383. @afterAppear="() => calls.withAppear.push('afterAppear')"
  384. >
  385. <div v-if="toggle" class="test">content</div>
  386. </transition>
  387. </div>
  388. <button @click="toggle = !toggle">button</button>
  389. </div>
  390. <div class="if-css-false">
  391. <div>
  392. <transition
  393. :css="false"
  394. name="test"
  395. @beforeEnter="() => calls.cssFalse.push('beforeEnter')"
  396. @enter="() => calls.cssFalse.push('onEnter')"
  397. @afterEnter="() => calls.cssFalse.push('afterEnter')"
  398. @beforeLeave="() => calls.cssFalse.push('beforeLeave')"
  399. @leave="() => calls.cssFalse.push('onLeave')"
  400. @afterLeave="() => calls.cssFalse.push('afterLeave')"
  401. >
  402. <div v-if="toggle" class="test">content</div>
  403. </transition>
  404. </div>
  405. <button @click="toggle = !toggle"></button>
  406. </div>
  407. <div class="if-no-trans">
  408. <div>
  409. <transition name="noop">
  410. <div v-if="toggle">content</div>
  411. </transition>
  412. </div>
  413. <button @click="toggle = !toggle">button</button>
  414. </div>
  415. <div class="if-ani">
  416. <div>
  417. <transition name="test-anim">
  418. <div v-if="toggle">content</div>
  419. </transition>
  420. </div>
  421. <button @click="toggle = !toggle">button</button>
  422. </div>
  423. <div class="if-ani-explicit-type">
  424. <div>
  425. <transition name="test-anim-long" type="animation">
  426. <div v-if="toggle">content</div>
  427. </transition>
  428. </div>
  429. <button @click="toggle = !toggle">button</button>
  430. </div>
  431. <div class="if-high-order">
  432. <div>
  433. <MyTransition>
  434. <div v-if="toggle" class="test">content</div>
  435. </MyTransition>
  436. </div>
  437. <button @click="toggle = !toggle">button</button>
  438. </div>
  439. <div class="if-empty-root">
  440. <div>
  441. <transition name="test">
  442. <component class="test" :is="view"></component>
  443. </transition>
  444. </div>
  445. <button class="toggle" @click="toggle = !toggle">button</button>
  446. <button class="change" @click="changeView">changeView button</button>
  447. </div>
  448. <div class="if-at-component-root-level">
  449. <div>
  450. <transition name="test" mode="out-in">
  451. <component class="test" :is="view"></component>
  452. </transition>
  453. </div>
  454. <button class="toggle" @click="toggle = !toggle">button</button>
  455. <button class="change" @click="changeView">changeView button</button>
  456. </div>
  457. <div class="if-fallthrough-attr">
  458. <div>
  459. <MyTransitionFallthroughAttr>
  460. <div v-if="toggle">content</div>
  461. </MyTransitionFallthroughAttr>
  462. </div>
  463. <button @click="toggle = !toggle">button fallthrough</button>
  464. </div>
  465. <div class="if-fallthrough-attr-in-out">
  466. <div>
  467. <transition
  468. foo="1"
  469. name="test"
  470. mode="in-out"
  471. @beforeEnter="() => calls.ifInOut.push('beforeEnter')"
  472. @enter="() => calls.ifInOut.push('onEnter')"
  473. @afterEnter="() => calls.ifInOut.push('afterEnter')"
  474. @beforeLeave="() => calls.ifInOut.push('beforeLeave')"
  475. @leave="() => calls.ifInOut.push('onLeave')"
  476. @afterLeave="() => calls.ifInOut.push('afterLeave')"
  477. >
  478. <component :is="viewInOut"></component>
  479. </transition>
  480. </div>
  481. <button @click="changeViewInOut">button</button>
  482. </div>
  483. <!-- work with vif end -->
  484. <!-- work with vshow -->
  485. <div class="show-named">
  486. <div>
  487. <transition name="test">
  488. <div v-show="toggle" class="test">content</div>
  489. </transition>
  490. </div>
  491. <button @click="toggle = !toggle">button</button>
  492. </div>
  493. <div class="show-events">
  494. <div>
  495. <transition
  496. name="test"
  497. @beforeEnter="() => calls.show.push('beforeEnter')"
  498. @enter="() => calls.show.push('onEnter')"
  499. @afterEnter="() => calls.show.push('afterEnter')"
  500. @beforeLeave="() => calls.show.push('beforeLeave')"
  501. @leave="() => calls.show.push('onLeave')"
  502. @afterLeave="() => calls.show.push('afterLeave')"
  503. >
  504. <div v-show="toggle" class="test">content</div>
  505. </transition>
  506. </div>
  507. <button @click="toggle = !toggle">button</button>
  508. </div>
  509. <div class="show-leave-cancelled">
  510. <div>
  511. <transition
  512. name="test"
  513. @leave-cancelled="() => calls.showLeaveCancel.push('leaveCancelled')"
  514. >
  515. <div v-show="toggle" class="test">content</div>
  516. </transition>
  517. </div>
  518. <button @click="toggle = !toggle">leave cancelled</button>
  519. </div>
  520. <div class="show-appear">
  521. <div>
  522. <transition
  523. name="test"
  524. appear
  525. appear-from-class="test-appear-from"
  526. appear-to-class="test-appear-to"
  527. appear-active-class="test-appear-active"
  528. @beforeEnter="() => calls.showAppear.push('beforeEnter')"
  529. @enter="() => calls.showAppear.push('onEnter')"
  530. @afterEnter="() => calls.showAppear.push('afterEnter')"
  531. >
  532. <div v-show="toggle" class="test">content</div>
  533. </transition>
  534. </div>
  535. <button @click="toggle = !toggle">button</button>
  536. </div>
  537. <div class="show-appear-not-enter">
  538. <div>
  539. <transition
  540. name="test"
  541. appear
  542. @beforeEnter="() => calls.notEnter.push('beforeEnter')"
  543. @enter="() => calls.notEnter.push('onEnter')"
  544. @afterEnter="() => calls.notEnter.push('afterEnter')"
  545. >
  546. <div v-show="!toggle" class="test">content</div>
  547. </transition>
  548. </div>
  549. <button @click="toggle = !toggle">button</button>
  550. </div>
  551. <!-- work with vshow end -->
  552. <!-- explicit durations -->
  553. <div class="duration-single-value">
  554. <div>
  555. <transition name="test" :duration="duration * 2">
  556. <div v-if="toggle" class="test">content</div>
  557. </transition>
  558. </div>
  559. <button @click="toggle = !toggle">button</button>
  560. </div>
  561. <div class="duration-enter">
  562. <div>
  563. <transition name="test" :duration="{ enter: duration * 2 }">
  564. <div v-if="toggle" class="test">content</div>
  565. </transition>
  566. </div>
  567. <button @click="toggle = !toggle">button</button>
  568. </div>
  569. <div class="duration-leave">
  570. <div>
  571. <transition name="test" :duration="{ leave: duration * 2 }">
  572. <div v-if="toggle" class="test">content</div>
  573. </transition>
  574. </div>
  575. <button @click="toggle = !toggle">button</button>
  576. </div>
  577. <div class="duration-enter-leave">
  578. <div>
  579. <transition
  580. name="test"
  581. :duration="{ enter: duration * 4, leave: duration * 2 }"
  582. >
  583. <div v-if="toggle" class="test">content</div>
  584. </transition>
  585. </div>
  586. <button @click="toggle = !toggle">button</button>
  587. </div>
  588. <!-- explicit durations end -->
  589. <!-- keyed fragment -->
  590. <div class="keyed">
  591. <button @click="count++">inc</button>
  592. <Transition>
  593. <h1 style="position: absolute" :key="count">{{ count }}</h1>
  594. </Transition>
  595. </div>
  596. <!-- keyed fragment end -->
  597. <!-- mode -->
  598. <div class="out-in">
  599. <button @click="toggleComponent">toggle out-in</button>
  600. <div>
  601. <Transition name="fade" mode="out-in">
  602. <component :is="activeComponent"></component>
  603. </Transition>
  604. </div>
  605. </div>
  606. <div class="in-out">
  607. <button @click="toggleComponent">toggle in-out</button>
  608. <div>
  609. <Transition name="fade" mode="in-out">
  610. <component :is="activeComponent"></component>
  611. </Transition>
  612. </div>
  613. </div>
  614. <!-- mode end -->
  615. <!-- async component -->
  616. <div class="async">
  617. <div id="container">
  618. <transition>
  619. <AsyncComp v-if="!toggle"></AsyncComp>
  620. </transition>
  621. </div>
  622. <button @click="toggle = !toggle">button</button>
  623. </div>
  624. <!-- async component end -->
  625. <!-- with teleport -->
  626. <div class="with-teleport">
  627. <div class="target"></div>
  628. <div class="container">
  629. <Transition>
  630. <Teleport to=".target" defer>
  631. <!-- comment -->
  632. <VaporCompB v-if="!toggle" class="test"></VaporCompB>
  633. </Teleport>
  634. </Transition>
  635. </div>
  636. <button @click="toggle = !toggle">button</button>
  637. </div>
  638. <!-- with teleport end -->
  639. <!-- with keep-alive -->
  640. <div class="keep-alive">
  641. <div>
  642. <transition mode="out-in">
  643. <KeepAlive :include="includeRef">
  644. <TrueBranch v-if="toggle"></TrueBranch>
  645. </KeepAlive>
  646. </transition>
  647. </div>
  648. <button @click="click">button</button>
  649. </div>
  650. <div class="keep-alive-update-include">
  651. <div>
  652. <transition mode="out-in">
  653. <KeepAlive :include="includeToChange">
  654. <component :is="currentView" />
  655. </KeepAlive>
  656. </transition>
  657. </div>
  658. <button id="switchToB" @click="switchToB">switchToB</button>
  659. <button id="switchToC" @click="switchToC">switchToC</button>
  660. <button id="switchToA" @click="switchToA">switchToA</button>
  661. </div>
  662. <div class="keep-alive-switch-then-update-include">
  663. <div>
  664. <transition name="test-anim" mode="out-in">
  665. <KeepAlive :include="includeRef2">
  666. <component :is="currentView2" />
  667. </KeepAlive>
  668. </transition>
  669. </div>
  670. <button id="switchToA" @click="switchToA2">switchToA</button>
  671. <button id="switchToB" @click="switchToB2">switchToB</button>
  672. </div>
  673. <div class="keep-alive-move-before-leave-finishes">
  674. <div>
  675. <KeepAlive :include="['Comp1', 'Comp2']">
  676. <component :is="state === 1 ? Comp1 : Comp2" />
  677. </KeepAlive>
  678. </div>
  679. <button @click="state = state === 1 ? 2 : 1">button</button>
  680. </div>
  681. <!-- with keep-alive end -->
  682. <!-- vdom interop -->
  683. <div class="vdom">
  684. <button @click="toggleVdom = !toggleVdom">toggle vdom component</button>
  685. <div>
  686. <Transition>
  687. <VDomComp v-if="toggleVdom" />
  688. </Transition>
  689. </div>
  690. </div>
  691. <div class="vdom-vapor-out-in">
  692. <button @click="toggleInteropComponent">
  693. switch between vdom/vapor component out-in mode
  694. </button>
  695. <div>
  696. <Transition name="fade" mode="out-in">
  697. <component :is="interopComponent"></component>
  698. </Transition>
  699. </div>
  700. </div>
  701. <div class="vdom-vapor-in-out">
  702. <button @click="toggleVdom = !toggleVdom">
  703. switch between vdom/vapor component in-out mode
  704. </button>
  705. <div>
  706. <Transition name="fade" mode="in-out">
  707. <VaporCompA v-if="toggleVdom" />
  708. <VDomComp v-else></VDomComp>
  709. </Transition>
  710. </div>
  711. </div>
  712. <!-- vdom interop end -->
  713. </div>
  714. </template>
  715. <style>
  716. .keyed {
  717. height: 100px;
  718. }
  719. </style>
  720. <style>
  721. .transition-container > div {
  722. padding: 15px;
  723. border: 1px solid #f7f7f7;
  724. margin-top: 15px;
  725. }
  726. </style>