---vivi-file-Type-application/javascript---// ---- banner text animation ---- // $(document).ready(function() { // $(window).on('load resize', function(event){ // var tRightWidth, tContent = $('.section-banner .overlay-banner'); // tRightWidth = Math.sqrt(Math.pow(tContent.width(), 2) + Math.pow(tContent.height(), 2)); // var angle = Math.atan(tContent.height() / tContent.width()); // angle = angle * 180 / Math.PI // tContent.find('.top, .bottom').css({ // width: tRightWidth, // transform: 'rotate(-'+angle+'deg)', // }); // }); // }); var bL = $('.banner-slide').length $('.slick-banner-index').on('init',function(e, slick) { var slides = $('.banner-slide').eq(0) setTimeout(function(){ slides.addClass('slick-current-active') $('.section-banner .overlay-banner').addClass('slick-current-overlay') }, 200) }) var slide = $('.banner-slide') $('.slick-banner-index').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: false, autoplay: true, fade: true, speed: 1000, autoplaySpeed: 5000, pauseOnHover: false, pauseOnFocus: false, touchThreshold: 30, dots: true, }).on('beforeChange', function(event, slick, currentSlide, nextSlide){ //- console.log(currentSlide,nextSlide) if(currentSlide != nextSlide){ slide.removeClass('slick-current-active') $('.section-banner .overlay-banner').removeClass('slick-current-overlay') setTimeout(function(){ $('.section-banner .overlay-banner').addClass('slick-current-overlay') slide.eq(nextSlide).addClass('slick-current-active') }, 500) } }) $(document).ready(function(){ $('.slick-prev').on('click', function(){ $('.slick-banner-index').slick('slickPrev'); }); $('.slick-next').on('click', function(){ $('.slick-banner-index').slick('slickNext'); }); }); const results = Splitting({ target: '.banner-slide .txt-inner', by: 'chars', matching: 'div > p', whitespace: false }); // block-0003 matchHeight $(function() { $('.block-0003-js').matchHeight() }) // block-0004 click open video modal $('.modalVideo-js').on('click', function () { var tar = $(this).data('target') var url = $(this).data('url') var filename = url.substring(url.lastIndexOf('/') + 1); var extend = filename.split('.') //- console.log(tar,url,filename,extend) if (extend[extend.length - 1] === 'mp4') { $(tar).on('shown.bs.modal', function () { if ($(this).find('video').length == 0) { $(this).find('.inner-wrap').append( "
") } else { $(this).find('video source').attr('src', url) } $(this).find('video')[0].load() var _this = $(this) setTimeout(function(){ _this.find('video')[0].play() }, 1000) }) } else { $(tar).on('shown.bs.modal', function () { if ($(this).find('iframe').length == 0) { $(this).find('.inner-wrap').append( "
") } else { $(this).find('iframe').attr('src', url) } }) } }) $('#modalVideo').on('hidden.bs.modal', function () { if ($(this).find('video').length != 0) { $(this).find('video source').attr('src', '') $(this).find('video')[0].load() } else { $(this).find('iframe').attr('src', '') } }) // block-0004 counter $('.content-0004 .editor-content').mCustomScrollbar() // block-0004 counter var counter= { el: $('.block-0004-couter .count'), counted: false, duration: 4000, offset: 800, counting: function(scrollTop){ var s = this this.el.not(".counted").each(function() { var $this = $(this), countTo = $this.attr('data-count'); $this.addClass("counted") $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: s.duration, step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } }); }); }, init: function(){ var s = this s.counting() } } counter.init() var imgHeight = $('.index-idx5__item .item-img .ratio').outerHeight(); $(window).on('resize', function(e){ setTimeout(function(e){ imgHeight = $('.index-idx5__item .item-img .ratio').outerHeight(); }, 1); }) if($(window).width() > 991) { $('.index-idx5__item').on('mouseover touchstart', function(e){ $(this).find('.item-img').css('height', imgHeight); }); $('.index-idx5__item').on('mouseout touchend', function(e){ $(this).find('.item-img').css('height', '0'); }); } //Scroll var scrollBar = { isMobile: false, scrollTop: function() { return $(window).scrollTop() }, autoMove: 300, current: 0, pages: $('.index-group-section .section').length, scroll: 0, wheelDelay: 150, speed: 900, sectionMoveSpeed: 1500, easing: "easeOutQuint", thumb: $(".scrollbar-thumb"), windowHeight: $(window).height(), bodyHeight: $("body").outerHeight(), stopScroll: false, thumbHeight: function(){ return this.windowHeight / this.bodyHeight * this.windowHeight }, thumbPosition: function(){ return this.scroll / this.bodyHeight * this.windowHeight }, scrollPosition: function(thumbPosition){ return thumbPosition / this.windowHeight * this.bodyHeight }, scrolling: function (speed) { var speed = speed || this.speed $("body").addClass("scrolling").removeClass("scroll-stop") var s = this $("body,html").stop().animate({scrollTop: this.scroll},speed,this.easing,this.stopScrolling(this)) this.thumb.stop().animate({top: this.thumbPosition()},speed,this.easing) setTimeout(function(){ if(s.thumbPosition()+s.thumbHeight() > s.windowHeight) s.thumb.stop().animate({top: s.windowHeight - s.thumbHeight()},500,this.easing); if(s.thumbPosition() < 0) s.thumb.stop().animate({top: 0},500,this.easing); },speed*0.6) }, spyPosition: function() { var s = this $(".section").each(function (e) { var sectionStart = $(this).offset().top var sectionEnd = sectionStart + $(this).outerHeight() if(s.scroll >= sectionStart && s.scroll < sectionEnd){ $(this).addClass("section-active") }else{ // $(this).removeClass("active") } //- console.log((s.scroll + s.windowHeight) + "==" + $("body").height()) if(s.scroll >= sectionStart - 600 && s.scroll < sectionEnd - 600 || s.scroll + s.windowHeight > $("body").height() - 10){ $(this).removeClass("before-active") }else { // if($(this).attr("id") == "about") counter(1) // $(this).addClass("before-active") } }) }, autoMoveSection: function() { var s = this if($("#section-1").length == 0) return false; $(".section.section-active").next().each(function (e) { var sectionStart = $(this).offset().top var sectionEnd = sectionStart + $(this).outerHeight() if(s.scroll > sectionStart - s.autoMove && s.scroll < sectionStart){ s.scroll = sectionStart s.scrolling() } }) $(".section.section-active").each(function (e) { var sectionStart = $(this).offset().top var sectionEnd = sectionStart + $(this).outerHeight() if(s.scrollTop() < sectionStart + s.autoMove && s.scrollTop() > sectionStart){ s.scroll = sectionStart s.scrolling() } }) }, sectionMove: function(id){ this.scroll = $(id).offset().top this.current = $(id).index() if($(window).width() < 768) this.scroll = $(id).offset().top this.scrolling(this.sectionMoveSpeed) }, stopScrolling: function(s) { s.spyPosition() if(s.stopScroll) clearTimeout(s.stopScroll) s.stopScroll = setTimeout(function(){ $("body").removeClass("scrolling").addClass("scroll-stop"); // s.autoMoveSection() },500) }, onScroll: function(){ var self = this, wheel = 0, wheeling; $("body").on("mousewheel",function(e){ if(self.isMobile) return false; // e.preventDefault() if(wheeling) { clearTimeout(wheeling) }else if(!$("body").hasClass("scrolling")){ if(e.deltaY > 0){ if( self.current > 0) self.current = self.current - 1 else self.current = 0 $("body").addClass("scrollUp").removeClass("scrollDown") }else{ if( self.current > self.pages - 1) self.current = self.pages - 1 else self.current = self.current + 1 $("body").addClass("scrollDown").removeClass("scrollUp") } //- console.log(self.pages) self.scroll = self.current * $(window).height() //- console.log(self.scroll) wheel++ self.scrolling() } // console.log(wheel) wheeling = setTimeout(function(){ wheel = 0 wheeling = false }, self.wheelDelay) }) $(window).on("scroll",function(e){ if(!self.isMobile) return false; // e.preventDefault() self.scroll = $(this).scrollTop() self.spyPosition() $("body").addClass("scrolling").removeClass("scroll-stop") if(wheeling){ clearTimeout(wheeling); } wheeling = setTimeout(function(){ $("body").removeClass("scrolling").addClass("scroll-stop") self.autoMove = 50 //self.autoMoveSection() }, 600) }) $(document).on("touchstart touch",function () { //- console.log("touch") if(!self.isMobile) return false; $("body,html").stop() }) }, onThumbDrag: function(){ var s = this s.thumb.on("mousedown", function(e) { var $drag = $(this).addClass('draggable'); var drg_h = $drag.outerHeight(), drg_w = $drag.outerWidth(), pos_y = $drag.offset().top + drg_h - e.pageY; $drag.css('z-index', 1000).parents().on("mousemove", function(e) { var pos = e.pageY + pos_y - drg_h if(pos < 0) pos = 0; $('.draggable').offset({ top:pos }) var top = s.thumb.css("top") s.scroll = s.scrollPosition(parseInt(top)) s.scrolling() $(document).on("mouseup", function() { var top = s.thumb.css("top") if((parseFloat(top)+drg_h) > $(window).height()) s.thumb.stop().animate({top:s.windowHeight-drg_h},500) $drag.removeClass('draggable') }); }); e.preventDefault(); // disable selection }) $(document).on("mouseup", function() { s.thumb.removeClass('draggable'); }); }, init: function () { this.thumb.height(this.thumbHeight()) this.onScroll() this.onThumbDrag() this.scroll = this.scrollTop() this.scrolling() } } // if($("#nav-side").length == 1){ // $("#nav-side").addClass("active") // $('body').scrollspy({ target: '#nav-side .nav-side'}) // } // var s = skrollr.init({ // smoothScrolling:false, // forceHeight:false // }); // var isMobile = $(window).width() < 992 || $(window).height() < 700 // if(isMobile){ // s.destroy() // } else{ // $('body').addClass('of-hidden') // } // scrollBar.isMobile = isMobile // scrollBar.init() // $(".nav-side a").on('click', function(e){ // e.preventDefault() // var id = $(this).attr('href') // scrollBar.sectionMove(id) // }) // function paddingSection(){ // if(isMobile) { // $('.section:not(.section-banner) .section-wrap').css('padding-top', 0); // } else { // // var headerHeight = $('.header-custom').outerHeight(); // $('.section:not(.section-banner) .section-wrap').css('padding-top', 80); // } // } // paddingSection(); $(window).on('resize', function(e){ setTimeout(function(){ paddingSection(); }, 3500) }) if($(window).width() > 767) { $('.block-0003-main .card-mid').mCustomScrollbar({ theme: "minimal-dark", }) } else { $('.block-0003-main .card-mid').mCustomScrollbar("destroy") }