如何在 bootstrap-vue modal[b-modal] 上创建 transition/animation
How to create transition/animation on bootstrap-vue modal[b-modal]
我是 bootstrap-vue 和 vue 的新手。
我正在尝试使用 Animate.css. I'm referring this Custom-Transition-Classes.
创建具有某些动画效果的 b-modal
我的代码是这样的:
<transition name="modal1" enter-active-class="animated slideInLeft" leave-
active-class="animated slideOutLeft">
<b-modal ref="saveModal" transition id="modal1" title="Save"
@ok="handleOk" @cancel="handleCancel">
<p class="my-4">Are you sure, you want to save?.</p>
</b-modal>
</transition>
似乎bootstrap Vue 的模态动画与过渡不兼容。一些简单的解决方法似乎是简单地在 shown
ok
或 cancel
事件上手动添加动画 class 名称(https://bootstrap-vue.js.org/docs/components/modal/ 参见最后一节),例如这个:
https://jsfiddle.net/Sirence/g8w2d413/33/
methods: {
shown: function(){
let modal = document.getElementById('modal1');
modal.parentElement.parentElement.classList.remove('hidden');
modal.classList.add('slideInLeft');
modal.classList.add('animated');
},
hidden: function(evt) {
let modal = document.getElementById('modal1');
evt.preventDefault();
modal.classList.add('slideOutLeft');
setTimeout(() => {
this.$refs.myModalRef.hide();
modal.parentElement.parentElement.classList.add('hidden');
console.log('test');
}, 1000)
}
}
.hidden {
display: none;
}
<b-btn v-b-modal.modal1>Launch demo modal</b-btn>
<b-modal ref="myModalRef" id="modal1" title="Bootstrap-Vue" @shown="shown" no-fade class="hidden" @ok="hidden" @cancel="hidden">
<p class="my-4">Hello from modal!</p>
</b-modal>
我是 bootstrap-vue 和 vue 的新手。 我正在尝试使用 Animate.css. I'm referring this Custom-Transition-Classes.
创建具有某些动画效果的 b-modal我的代码是这样的:
<transition name="modal1" enter-active-class="animated slideInLeft" leave-
active-class="animated slideOutLeft">
<b-modal ref="saveModal" transition id="modal1" title="Save"
@ok="handleOk" @cancel="handleCancel">
<p class="my-4">Are you sure, you want to save?.</p>
</b-modal>
</transition>
似乎bootstrap Vue 的模态动画与过渡不兼容。一些简单的解决方法似乎是简单地在 shown
ok
或 cancel
事件上手动添加动画 class 名称(https://bootstrap-vue.js.org/docs/components/modal/ 参见最后一节),例如这个:
https://jsfiddle.net/Sirence/g8w2d413/33/
methods: {
shown: function(){
let modal = document.getElementById('modal1');
modal.parentElement.parentElement.classList.remove('hidden');
modal.classList.add('slideInLeft');
modal.classList.add('animated');
},
hidden: function(evt) {
let modal = document.getElementById('modal1');
evt.preventDefault();
modal.classList.add('slideOutLeft');
setTimeout(() => {
this.$refs.myModalRef.hide();
modal.parentElement.parentElement.classList.add('hidden');
console.log('test');
}, 1000)
}
}
.hidden {
display: none;
}
<b-btn v-b-modal.modal1>Launch demo modal</b-btn>
<b-modal ref="myModalRef" id="modal1" title="Bootstrap-Vue" @shown="shown" no-fade class="hidden" @ok="hidden" @cancel="hidden">
<p class="my-4">Hello from modal!</p>
</b-modal>