Run transition on programmatically created component

Viewed 79

I'm using this code

var ComponentClass = Vue.extend(Notification);
var instance = new ComponentClass({
    propsData: {
        notification: notification
    }
});
instance.$mount();
this.$refs.notificationContainer.appendChild(instance.$el);

to programmatically create a component when a new notification is received through pusher, this is my notification component

<template>
    <transition
        enter-active-class="transition ease-out duration-100 transform"
        enter-class="opacity-0 scale-95"
        enter-to-class="opacity-100 scale-100"
        leave-active-class="transition ease-in duration-75 transform"
        leave-class="opacity-100 scale-100"
        leave-to-class="opacity-0 scale-95"
    >
        <div class="bg-gray-100 px-4 py-2 border-0 rounded relative mb-4 text-gray-700 flex items-center">
            <div class="flex-shrink-0 h-10 w-10">
                <img
                    class="h-10 w-10 rounded-full"
                    :src="notification.user.profile_photo_url"
                    :alt="notification.user.username"
                >
            </div>
            <span class="inline-block align-middle flex-1 ml-2 mr-4">
                <strong>{{notification.user.username}}</strong> {{notification.message}}
            </span>
            <button class="focus:outline-none">
                <i
                    class="fad fa-times text-red-600"
                ></i>
            </button>
        </div>
    </transition>
</template>

<script>
export default {
    props: {
        notification: Object
    }
}
</script>

but for some reason the transition doesnt run when the component is created

1 Answers

Fixed by adding appear to the transition element

Related