我试图在MODAL内容中应用动画但不起作用(aos动画)

时间:2018-04-09 09:32:52

标签: javascript html css animation modal-dialog

AOS.init({
  duration: 1800,
  delay: 300,
})

$(function() {
  //----- OPEN
  $('[data-popup-open]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-open');
    $('[data-popup="' + targeted_popup_class + '"]').fadeIn(550);
    e.preventDefault();
  });
  //----- CLOSE
  $('[data-popup-close]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-close');
    $('[data-popup="' + targeted_popup_class + '"]').fadeOut(550);
    e.preventDefault();
  });
  $(".popup").click(function() {
    $(".popup").fadeOut(550).removeClass("active");
  });
  $(".popup-inner").click(function(e) {
    e.stopPropagation();
  });
});
<style>#main {
  width: 100%;
  height: 100%;
  position: relative;
  background-size: cover;
  padding-bottom: 150px;
  font-family: 'Montserrat', sans-serif;
  background: url(Mimg/tree.png) absolute;
  background: url(Mimg/testback2.png) no-repeat center absolute;
}

a1 {
  font-size: 36px;
  font-weight: 700;
  text-decoration: none;
}

a2 {
  font-size: 21px;
  font-weight: 500;
}

.fishes {
  position: relative;
  top: 0;
  left: 0;
}

.fish {
  position: absolute;
  top: 50%;
  left: 10%;
}

.fish:hover {
  background: #ffffff;
  opacity: 0.5;
}


/* Outer */

.popup {
  width: 100%;
  height: 100%;
  display: none;
  position: fixed;
  top: 0px;
  left: 0px;
  background: rgba(255, 255, 255, 0.75);
}


/* Inner */

.popup-inner {
  max-width: 500px;
  width: 90%;
  padding: 40px;
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  box-shadow: 0px 2px 6px rgba(0, 0, 0, 1);
  border-radius: 3px;
  background: #fff;
}


/* Close Button */

.popup-close {
  width: 30px;
  height: 30px;
  padding-top: 4px;
  display: inline-block;
  position: absolute;
  top: 0px;
  right: 0px;
  transition: ease 0.25s all;
  -webkit-transform: translate(50%, -50%);
  transform: translate(50%, -50%);
  border-radius: 1000px;
  background: rgba(0, 0, 0, 0.8);
  font-family: Arial, Sans-Serif;
  font-size: 20px;
  text-align: center;
  line-height: 100%;
  color: #fff;
}

.popup-close:hover {
  -webkit-transform: translate(50%, -50%) rotate(180deg);
  transform: translate(50%, -50%) rotate(180deg);
  background: rgba(0, 0, 0, 1);
  text-decoration: none;
}

</style>
<script src="plugin/aos/aos.js"></script>
<div id="main">
  <img class="fishes" src="Mimg/testback2.png">
  <a class="btn" data-popup-open="popup-1" href="#"><img class="fish" src="Mimg/tree.png" data-aos="zoom-in"></a>
  <div class="popup" data-popup="popup-1">
    <div class="popup-inner">
      <a1 data-aos="zoom-in">Wow! This is Awesome! (Popup #1)</a1><br>
      <img data-aos="zoom-in" width="100%" class="run" src="Mimg/run-1.gif"><br>
      <a2 data-aos="zoom-in">Donec in volutpat nisi. In quam lectus, aliquet rhoncus cursus a, congue et arcu. Vestibulum tincidunt neque id nisi pulvinar aliquam. Nulla luctus luctus ipsum at ultricies. Nullam nec velit dui. Nullam sem eros, pulvinar sed pellentesque ac, feugiat
        et turpis. Donec gravida ipsum cursus massa malesuada tincidunt. Nullam finibus nunc mauris, quis semper neque ultrices in. Ut ac risus eget eros imperdiet posuere nec eu lectus.</a2>
      <p>
        <a2 data-popup-close="popup-1" href="#"><u>Close</u></a2>
      </p>
      <a class="popup-close" data-popup-close="popup-1" href="#">X</a>
    </div>
  </div>
</div>

当我将data-aos="zoom-in"置于模态内容中时变得不起作用,但它适用于照片按钮。

对此有何想法?

0 个答案:

没有答案