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

114 lines
2.9 KiB
JavaScript
Raw Normal View History

2024-08-24 23:08:42 +03:00
'use strict';
// Import our custom CSS
// import '../scss/app.scss'
// Import all of Bootstrap's JS
import * as bootstrap from 'bootstrap'
import * as Popper from '@popperjs/core'
// import { Tooltip, Toast, Popover, To } from 'bootstrap';
2024-08-25 21:58:11 +03:00
// import 'jquery'
2024-08-24 23:08:42 +03:00
window.Popper = Popper
import 'bootstrap'
// menu options custom affix
var fixed_top = $(".header");
$(window).on("scroll", function(){
if( $(window).scrollTop() > 50){
fixed_top.addClass("animated fadeInDown menu-fixed");
}
else{
fixed_top.removeClass("animated fadeInDown menu-fixed");
}
});
$('.navbar-toggler').on('click', function (){
$('.header').toggleClass('active');
});
$('.nav-right__search-btn').on('click', function(){
$('.header-search-area').addClass('active');
});
//close when click off of container
$(document).on('click touchstart', function (e){
if (!$(e.target).is('.nav-right__search-btn, .nav-right__search-btn *, .header-search-form, .header-search-form *')) {
$('.header-search-area').removeClass('active');
}
});
// mobile menu js
$(".navbar-collapse>ul>li>a, .navbar-collapse ul.sub-menu>li>a").on("click", function() {
const element = $(this).parent("li");
if (element.hasClass("open")) {
element.removeClass("open");
element.find("li").removeClass("open");
}
else {
element.addClass("open");
element.siblings("li").removeClass("open");
element.siblings("li").find("li").removeClass("open");
}
});
// Animate the scroll to top
$(".scroll-to-top").on("click", function(event) {
event.preventDefault();
$("html, body").animate({scrollTop: 0}, 300);
});
//preloader js code
$("#preloader").delay(300).animate({
"opacity" : "0"
}, 300, function() {
$("#preloader").css("display","none");
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
///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";
// Search options
$(".search-bar > a").on("click", function () {
$(".header-top-search-area").slideToggle();
});
})(jQuery);