I need a help to animated my web project with gsap staggerFromTo()

烂漫一生 提交于 2021-02-11 15:03:08

问题


I want to popup my footer thumbnailed one by one with staggerFromTo() property.

Here is my HTML code.

<div class="footer">
    <img src="img/pic1.jpg" alt="">
    <img src="img/pic2.jpg" alt="">
    <img src="img/pic3.jpg" alt="">
    <img src="img/pic4.jpg" alt="">
</div>

Here is my js code:

const footer = document.querySelector(".footer");
const tl = new TimelineMax();
tl.staggerFromTo(footer,1.5,{y: "-100px"},{y: "0%",stagger:0.2})

回答1:


You don't need this CSS. It's just to visualize the example!

I hope I've been helpful

gsap.fromTo('.footer > *', {
    y: 0,
    opacity: 0,
}, {
    duration: 1,
    stagger: 0.2,
    y: -100,
    opacity: 1,
})
.footer {
    position: absolute;
    bottom: 0px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.6/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


<div class="footer">
    <img src="https://blog.54ka.org/wp-content/uploads/2020/08/horses-on-summer-meadow_013_by_54ka-165x165.jpg"
        alt="" width="100">
    <img src="https://blog.54ka.org/wp-content/uploads/2020/08/horses-on-summer-meadow_014_by_54ka-165x165.jpg"
        alt="" width="100">
    <img src="https://blog.54ka.org/wp-content/uploads/2020/08/horses-on-summer-meadow_015_by_54ka-165x165.jpg"
        alt="" width="100">
    <img src="https://blog.54ka.org/wp-content/uploads/2020/08/horses-on-summer-meadow_016_by_54ka-165x165.jpg"
        alt="" width="100">
</div>


来源:https://stackoverflow.com/questions/64817267/i-need-a-help-to-animated-my-web-project-with-gsap-staggerfromto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!