简体   繁体   中英

Bootstrap : animation in modal window

i want to use wow.js animations (with animate.css) in a modal window of bootstrap like this

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
          <div class="container">
             <div class="row">
                <div class="col-md-6 col-sm-6 col-xs-12 wow fadeInLeft">
                   <p>Animation from Right</p>
                </div>
                <div class="col-md-6 col-sm-6 col-xs-12 wow fadeInRight">
                   <p>Animation from Right</p>
                </div>
             </div> 
          </div>
      </div>

    </div>

  </div>
</div> 

i included wow.js, animate.css , animations are working properly in the page but in modal window it does not work , Need your help with this please

It's not working because when you call wow.init() , the lightbox element doesn't exist yet.

You need to call either wow.init() or wow.sync() after the element is created (ie when it is opened) in order for the wow code to find the element.

Bootstrap can run a callback when the modal is created and shown. Yours will end up looking something like this

$('#myModal').on('shown.bs.modal', function () {
  wow.sync()
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM