【发布时间】:2017-08-11 16:53:30
【问题描述】:
几个小时后,在几个人的帮助下,我设法用脚本解决了这个问题。
但是,我再次发现样式有问题。
我的问题在哪里?为什么相关文字会闪烁?
var offsetTop = $('#skills').offset().top;
function animateSkillBars() {
$( ".bar" ).each( function() {
var $bar = $( this ),
$pct = $bar.find( ".pct" ),
data = $bar.data( "bar" );
setTimeout( function() {
$bar
.css( "background-color", data.color )
.animate({
"width": $pct.html()
}, data.speed || 10, function() {
$pct.css({
"color": data.color,
"opacity": 1
});
});
}, data.delay || 0 );
});
}
;( function( $ ) {
"use strict";
$(window).scroll(function() {
var height = $(window).height();
if($(window).scrollTop()+height > offsetTop) {
animateSkillBars();
}
});
})( jQuery );
【问题讨论】:
标签: javascript jquery html css scrolltop