123movies-seo/resources/js/home.js

168 lines
4.6 KiB
JavaScript

'use strict';
// import slickCarousel from 'slick-carousel'
// $('#langSel').niceSelect();
// new WOW().init();
// mainSlider
function mainSlider() {
var BasicSlider = $('.hero__slider');
if(BasicSlider) {
BasicSlider.on('init', function (e, slick) {
var $firstAnimatingElements = $('.movie-slide:first-child').find('[data-animation]');
doAnimations($firstAnimatingElements);
});
BasicSlider.on('beforeChange', function (e, slick, currentSlide, nextSlide) {
var $animatingElements = $('.movie-slide[data-slick-index="' + nextSlide + '"]').find('[data-animation]');
doAnimations($animatingElements);
});
BasicSlider.slick({
autoplay: true,
autoplaySpeed: 3000,
lazyLoad: 'ondemand',
dots: true,
fade: false,
arrows: false,
// nextArrow: '<div class="next"><i class="las la-long-arrow-alt-right"></i></div>',
// prevArrow: '<div class="prev"><i class="las la-long-arrow-alt-left"></i></div>',
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
}
},
{
breakpoint: 991,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
arrows: false
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
arrows: false
}
}
]
});
}
function doAnimations(elements) {
var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
elements.each(function () {
var $this = $(this);
var $animationDelay = $this.data('delay');
var $animationType = 'animated ' + $this.data('animation');
$this.css({
'animation-delay': $animationDelay,
'-webkit-animation-delay': $animationDelay
});
$this.addClass($animationType).one(animationEndEvents, function () {
$this.removeClass($animationType);
});
});
}
}
mainSlider();
// $(window).on('load', function() {})
$('.movie-slider-one').slick({
lazyLoad: 'ondemand',
autoplay:true,
slidesToShow: 7,
slidesToScroll: 1,
infinite: true,
speed: 700,
dots: false,
arrows: true,
nextArrow: '<div class="next"><svg class="si"><use href="#si-long-arrow-right"></svg></i></div>',
prevArrow: '<div class="prev"><svg class="si"><use href="#si-long-arrow-left"></svg></i></div>',
responsive: [
{
breakpoint: 1650,
settings: {
slidesToShow: 5
}
},
{
breakpoint: 1200,
settings: {
slidesToShow: 4
}
},
{
breakpoint: 992,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 2
}
},
{
breakpoint: 512,
settings: {
slidesToShow: 2
}
}
]
});
// ///lazy loading image script
// function lazyLoading(){
// let images = document.querySelectorAll('.loading-img');
// function preloadImage(image) {
// let src = image.getAttribute('data-src');
// image.setAttribute('src', src)
// image = $(image);
// image.siblings('.thumb_overlay').fadeTo(2500, 0)
// }
// let imageOptions = {
// threshold: 1,
// };
// const imageObserver = new IntersectionObserver((entries, imageObserver) => {
// entries.forEach(entry => {
// if (entry.isIntersecting) {
// // setTimeout(() => {
// preloadImage(entry.target)
// // overlay.style.display = 'none';
// // }, 2000);
// imageObserver.unobserve(entry.target)
// }
// })
// }, imageOptions)
// images.forEach(image => {
// imageObserver.observe(image)
// }, imageOptions)
// }
// lazyLoading();
(function ($) {
"user strict";
})(jQuery);
document.addEventListener('readystatechange', event => {
if (document.readyState === "complete") {
}
});