Skip to content

Wait Transition to finish before showing x-show #721

@surjithctly

Description

@surjithctly

Hello,

I have a strange issue while trying to animate Tabs. I have 3 buttons for tabs, and 3 div's to display content. But when I add transition to the content. It breaks. See the below fiddle to see what I mean.

https://jsfiddle.net/0mv8husn/1/

How do I let other tab wait for the transition to finish before showing?

I have seen the pull #177 but this is not working.

View Code

 <div x-data="{ open: 'tab1' }">
   <button @click.prevent="open= 'tab1'">
     Open Tab 1
   </button>

   <button @click.preventk="open= 'tab2'">
     Open Tab 2
   </button>

   <button @click.prevent="open= 'tab3'">
     Open Tab 3
   </button>

   <div x-show="open === 'tab1'">
     Hey I'm tab 01
     <div x-show="open === 'tab1'" x-transition:enter-start="opacity-0 scale-90" x-transition:enter="ease-out transition-slow" x-transition:enter-end="opacity-100 scale-100" x-transition:leave-start="opacity-100 scale-100" x-transition:leave="ease-in transition-slow" x-transition:leave-end="opacity-0 scale-90">
       I'm transitioning 01
     </div>
   </div>

   <div x-show="open === 'tab2'">
     Hey I'm tab 02
     <div x-show="open === 'tab2'" x-transition:enter-start="opacity-0 scale-90" x-transition:enter="ease-out transition-slow" x-transition:enter-end="opacity-100 scale-100" x-transition:leave-start="opacity-100 scale-100" x-transition:leave="ease-in transition-slow" x-transition:leave-end="opacity-0 scale-90">
       I'm transitioning 02
     </div>
   </div>

   <div x-show="open === 'tab3'">
     Hey I'm tab 03
     <div x-show="open === 'tab3'" x-transition:enter-start="opacity-0 scale-90" x-transition:enter="ease-out transition-slow" x-transition:enter-end="opacity-100 scale-100" x-transition:leave-start="opacity-100 scale-100" x-transition:leave="ease-in transition-slow" x-transition:leave-end="opacity-0 scale-90">
       I'm transitioning 03
     </div>
   </div>
 </div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions