1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Oinktube/plugin/FloatVideo/floatVideo.js
Daniel Neto e1689279ed update
2023-08-09 11:13:59 -03:00

47 lines
No EOL
1.4 KiB
JavaScript

var FloatVideoTimeout;
var floatClosed = 0;
function closeFloatVideo() {
if(!$('body').hasClass('floatVideo')){
return false;
}
clearTimeout(FloatVideoTimeout);
setTimeout(function () {
$('#videoCol').css('height', '');
$('#videoContainer').removeClass('animate__animated');
$('#videoContainer').removeClass('animate__bounceInDown');
$('body').removeClass('floatVideo');
}, 100);
}
function setFloatVideo() {
if(floatClosed){
return false;
}
if($('body').hasClass('floatVideo')){
return false;
}
clearTimeout(FloatVideoTimeout);
setTimeout(function () {
var videoContainerHeight = $('#videoContainer').height();
$('#videoCol').height(videoContainerHeight);
$('#videoContainer').addClass('animate__animated');
$('#videoContainer').addClass('animate__bounceInDown');
$('body').addClass('floatVideo');
}, 100);
}
$(function () {
// Function to handle scroll event
function handleScroll() {
var element = $('#videoCol'); // Replace 'your-element-id' with the ID of your target element
if (element.isVisible()) {
closeFloatVideo();
} else {
setFloatVideo();
}
}
// Bind the handleScroll function to the scroll event
$(window).scroll(handleScroll);
});