//jQuery is required to run this code
$( document ).ready(function() {
scaleAnimationContainer();
initBaerAnimationSize('.animation-container .animation img');
initBaerAnimationSize('.animation-container .mask');
initBaerAnimationSize('.animation-container video');
$(window).on('resize', function() {
scaleAnimationContainer();
scaleBaerAnimationSize('.animation-container .animation img');
scaleBaerAnimationSize('.animation-container .mask');
scaleBaerAnimationSize('.animation-container video');
});
});
function scaleAnimationContainer() {
var height = $(window).height() + 5;
var unitHeight = parseInt(height) + 'px';
$('.homepage-baer').css('height',unitHeight);
}
function initBaerAnimationSize(element){
$(element).each(function(){
$(this).data('height', $(this).height());
$(this).data('width', $(this).width());
});
scaleBaerAnimationSize(element);
}
function scaleBaerAnimationSize(element){
var windowWidth = $(window).width(),
windowHeight = $(window).height() + 5,
animationWidth,
animationHeight;
console.log(windowHeight);
$(element).each(function(){
var animationAspectRatio = $(this).data('height')/$(this).data('width');
$(this).width(windowWidth);
if(windowWidth < 1000){
animationHeight = windowHeight;
animationWidth = animationHeight / animationAspectRatio;
$(this).css({'margin-top' : 0, 'margin-left' : -(animationWidth - windowWidth) / 2 + 'px'});
$(this).width(animationWidth).height(animationHeight);
}
$('.homepage-baer .animation-container video').addClass('fadeIn animated');
});
}
برچسب: انیمیشنی,
نویسنده: استخدام کار