您好我有这个代码,提供类型写作效果。但是,我希望动画只在用户向下滚动到这个div时运行。你们能帮忙吗?感谢
<script>
$(function(){
$("#typed").typed({
strings: ["oru exp", "Oru expertise", '"Our expertise Graphic Designer will create the template based \n on your company activity and will provide with a proffesional \n and ergonic design to your website."'],
typeSpeed: 30,
backDelay: 500,
loop: false,
// defaults to false for infinite loop
loopCount: false,
callback: function(){ foo(); },
resetCallback: function() { newTyped(); }
});
$(".reset").click(function(){
$("#typed").typed('reset');
});
});
function newTyped(){ /* A new typed object */ }
function foo(){ console.log("Callback"); }
</script>
&#13;
这里是html:
<div class="wrap">
<div class="type-wrap">
<span id="typed" style="white-space:pre;"></span>
</div>
</div>
答案 0 :(得分:1)
$(window).scroll(function(){
var height = $(window).scrollTop();
if(height > 400){
// $('#your_htmlelement').typed();
}else{
// $('#your_htmlelement').typed('reset');
}
});
获得一定高度然后播放动画怎么样?