简体   繁体   English

gif动画完成后如何激活页面滚动

[英]How to activate page-scroll after gif animation is complete

My idea is to show an image of an ice-cube that the use must click, only to then show the ice cube breaking. 我的想法是显示用户必须单击的冰块图像,然后才显示冰块破裂。 After only 3 seconds, the ice cube will be fully broken and the GIF complete (it's not an infinite clip) and then the page will scroll down to the "About" of the page. 仅3秒钟后,冰块将被完全打破,GIF完成(这不是一个无限的剪辑),然后页面将向下滚动到页面的“关于”。 This is the div where I have the Ice Cube image: 这是我拥有Ice Cube图像的div:

<div class="row">
    <div class="col-lg-12 imageWrap page-scroll">
        <a href="#about"><img id="icebreaker" onclick="changeImg();"  src="img/wiggle.gif"></a>
        <p class="callToAction">Break The Ice</p>
    </div>
</div>

And the next section has an id = #about which it should scroll to. 下一节有一个id = #about,它应该滚动到该位置。 I'm using the Bootstrap page-scroll plug-in to allow the smooth-scroll to occur on click, but what I want is for that smooth-scroll not happen until the GIF is done playing. 我正在使用Bootstrap页面滚动插件,以允许单击时进行平滑滚动,但是我想要的是平滑滚动直到GIF播放完毕才发生。 The following script is to replace my current ice cube with the breaking ice cube GIF. 下面的脚本是用破碎的冰块GIF替换我当前的冰块。

<script>
    function changeImg() {
        $("#icebreaker").attr("src", "img/ice-cube.gif");
    }
</script>

I have tried using the settimeout scroll but I couldn't get it to work and I've tried breaking the page for a few seconds before it scrolled but then it would stop the animation as well since it breaks the entire page. 我已经尝试过使用settimeout滚动,但是我无法使其正常工作,并且在滚动之前尝试将页面中断几秒钟,但是由于它会中断整个页面,因此它也会停止动画。 If anyone can help me figure out some sort of chain-reaction, that would be great! 如果有人可以帮助我弄清楚某种连锁反应,那就太好了!

Try this one 试试这个

 function changeImg() { var img = document.getElementById("icebreaker"); img.onload = function() { setTimeout(function() { /*your scroll fn here*/ }, 5000) } img.src = "img/ice-cube.gif"; } 

The timeOut fn is working you need to have jquery.ui.js as well to do this check working sample here timeOut fn正在工作,您还需要jquery.ui.js来执行此检查工作示例

activate page scroll with timeout 激活页面滚动超时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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