滚动到指定位置时候播放视频

曹え 5811 发布于:2022-07-15 07:33:49

$w = $(window).width()    
t = $('.banner1').offset().top / 2    
h = $('.banner1').height()    
z = t + h * 1.57    
q = 1    
if ($w > 1200) {    
$(window).scroll(function(e) {    
var w_top = $(window).scrollTop();    
// 导航条固定在屏幕    
if (w_top > t && w_top < z) {    
if (q == 1) {    
q = 0    
var tr = setTimeout(function() {    
$('.banner1 .item').addClass('on')    
$('.video1')[0].play()    
}, 3000)    
	console.log('播放开始')    
}    
} else {    
$('.banner1 .item').removeClass('on')    
$('.video1')[0].pause()    
q = 1    
clearTimeout(tr)    
	console.log('播放暂停')    
}    
})    
}


觉得有用请点个赞吧!
1 896