| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- (function ($) {
- "use strict";
- //--------------------------------------------------
- // Preloader
- //--------------------------------------------------
- $(window).on('load', function () {
- $('.preloader').fadeOut('slow');
- RevealLoad();
- startAnim();
- $('.preloader').removeClass()
- })
- //--------------------------------------------------
- // Animation Start
- //--------------------------------------------------
- function startAnim() {
- TweenMax.from('.logo', 1, {
- y: '100',
- autoAlpha: 0,
- delay: '.3',
- ease: Power4.easeInOut,
- })
- TweenMax.from('.toggle-btn', 1, {
- y: '100',
- delay: '.3',
- autoAlpha: 0,
- ease: Power4.easeInOut,
- })
- TweenMax.from('.bg-right', 1, {
- x: 100,
- ease: Power4.easeInOut,
- delay: '.3',
- })
- TweenMax.from('.bg-about', 1, {
- x: 100,
- ease: Power4.easeInOut,
- delay: '.3',
- })
- TweenMax.from('.scr', 1, {
- y: '100',
- ease: Power4.easeInOut,
- autoAlpha: 0,
- })
- TweenMax.from('.scrolls', 1, {
- y: '100',
- delay: 1,
- ease: Power4.easeInOut,
- autoAlpha: 0,
- })
- TweenMax.to('.menu', 0, {
- autoAlpha: 0,
- })
- }
- //--------------------------------------------------
- // Parralax
- //--------------------------------------------------
- var headermove = $('#headmove').get(0);
- var parallaxInstance = new Parallax(headermove, {
- relativeInput: true,
- scalarX: 14,
- hoverOnly: false,
- });
- //--------------------------------------------------
- // Web Load
- //--------------------------------------------------
- function RevealLoad() {
- var loadTL = new TimelineMax();
- var block1 = $('.block-1');
- var block2 = $('.block-2');
- var logo = $('.logo-load');
- loadTL
- .to(block1, 0.5, {
- height: '0',
- delay: '0'
- })
- .to(block2, 0.5, {
- height: '0',
- })
- .to(logo, 0, {
- autoAlpha: 0,
- delay: '-0.4',
- })
- loadTL.play();
- }
- function HideLoad() {
- var loadTL = new TimelineMax();
- var block1 = $('.block-1');
- var block2 = $('.block-2');
- var logo = $('.logo-load');
- loadTL
- .to(block1, 0.5, {
- height: '100%',
- delay: '0'
- })
- .to(block2, 0.5, {
- height: '100%',
- })
- .to(logo, 0, {
- autoAlpha: 1,
- delay: '-0.5'
- })
- loadTL.play();
- }
-
- //为点击事件专门做一个过渡动画方法
- function HideLoadClick() {
- var loadTL = new TimelineMax();
- var block1 = $('.block-1');
- var block2 = $('.block-2');
- var logo = $('.logo-load');
- loadTL
- .to(block1, 0.5, {
- height: '100%',
- delay: '0'
- })
- .to(block2, 0.5, {
- height: '100%',
- })
- .to(logo, 0, {
- autoAlpha: 1,
- delay: '-0.5'
- })
- loadTL.play();
- //设置一个定时器
- setTimeout(function () {
- RevealLoad();
- }, 5000);
- }
-
- $('.load-spiral').on('click', function (e) {
- e.preventDefault();
- setTimeout(function (url) {
- window.location = url;
- }, 1000, this.href);
- HideLoadClick();
- });
- //--------------------------------------------------
- // Animation on navbar scrolling background
- //--------------------------------------------------
- var wind = $(window);
- wind.on("scroll", function () {
- var bodyScroll = wind.scrollTop();
- if (bodyScroll > 300) {
- TweenMax.to('.scr', .5, {
- autoAlpha: 0,
- y: '100',
- })
- TweenMax.to('.scrolls', .5, {
- autoAlpha: 0,
- y: '100',
- })
- } else {
- TweenMax.to('.scr', 1, {
- autoAlpha: 1,
- y: '00',
- })
- TweenMax.to('.scrolls', .5, {
- autoAlpha: 1,
- y: '0',
- })
- }
- });
- $('.img-folio').on('mouseenter', function () {
- TweenMax.to(this, 0.4, {
- y: '-30',
- })
- });
- $('.img-folio').on('mouseleave', function () {
- TweenMax.to(this, 0.4, {
- y: '1',
- })
- });
- luxy.init({
- wrapper: '#spiral',
- wrapperSpeed: '0.07',
- });
- //--------------------------------------------------
- // Cursor
- //--------------------------------------------------
- var isMobile = false;
- if (/Android|webOS|iPhone|iPod|iPad|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
- $('html').addClass('touch');
- isMobile = true;
- } else {
- $('html').addClass('no-touch');
- isMobile = false;
- }
- var isMacLike = /(Mac)/i.test(navigator.platform);
- var cursor = {
- delay: 8,
- _x: 0,
- _y: 0,
- endX: (window.innerWidth / 2),
- endY: (window.innerHeight / 2),
- cursorVisible: true,
- cursorEnlarged: false,
- $cursor: document.querySelector('.cursor'),
- $cursor1: document.querySelector('.cursor1'),
- init: function () {
-
- // Set up element sizes
- this.cursorSize = this.$cursor.offsetWidth;
- this.cursor1Size = this.$cursor1.offsetWidth;
- this.setupEventListeners();
- this.animateDotOutline();
- this.cursorDrag();
- this.cursorExplore();
- this.cursorZoom();
- this.cursorNext();
- this.cursorPrev();
- },
- setupEventListeners: function () {
- var self = this;
- // Anchor hovering
- Array.prototype.slice.call(document.querySelectorAll(' .zoom-cursor, .hover-target')).forEach(function (el) {
- el.addEventListener('mouseover', function () {
- self.cursorEnlarged = true;
- self.toggleCursorSize();
- });
- el.addEventListener('mouseout', function () {
- self.cursorEnlarged = false;
- self.toggleCursorSize();
- });
- });
- document.addEventListener('mousemove', function (e) {
- // Show the cursor
- self.cursorVisible = true;
- self.toggleCursorVisibility();
- // Position the dot
- self.endX = e.clientX;
- self.endY = e.clientY;
- self.$cursor.style.top = self.endY + 'px';
- self.$cursor.style.left = self.endX + 'px';
- });
- // Hide/show cursor
- document.addEventListener('mouseenter', function (e) {
- self.cursorVisible = true;
- self.toggleCursorVisibility();
- self.$cursor.style.opacity = 1;
- self.$cursor1.style.opacity = 1;
- });
- document.addEventListener('mouseleave', function (e) {
- self.cursorVisible = true;
- self.toggleCursorVisibility();
- self.$cursor.style.opacity = 0;
- self.$cursor1.style.opacity = 0;
- });
- },
- animateDotOutline: function () {
- var self = this;
- self._x += (self.endX - self._x) / self.delay;
- self._y += (self.endY - self._y) / self.delay;
- self.$cursor1.style.top = self._y + 'px';
- self.$cursor1.style.left = self._x + 'px';
- requestAnimationFrame(this.animateDotOutline.bind(self));
- },
- toggleCursorSize: function () {
- var self = this;
- if (self.cursorEnlarged) {
- self.$cursor1.classList.add('expand');
- } else {
- self.$cursor1.classList.remove('expand');
- }
- },
- toggleCursorVisibility: function () {
- var self = this;
- if (self.cursorVisible) {
- self.$cursor.style.opacity = 1;
- self.$cursor1.style.opacity = 1;
- } else {
- self.$cursor.style.opacity = 0;
- self.$cursor1.style.opacity = 0;
- }
- },
- cursorDrag: function () {
- var self = this;
- $('.cursorDrag').on('mouseenter', function () {
- self.$cursor1.classList.add('drag', 'expand');
- });
- $('.cursorDrag').on('mouseleave', function () {
- self.$cursor1.classList.remove('drag', 'expand');
- });
- },
- cursorExplore: function () {
- var self = this;
- $('.cursorExplore').on('mouseenter', function () {
- self.$cursor1.classList.add('explore');
- });
- $('.cursorExplore').on('mouseleave', function () {
- self.$cursor1.classList.remove('explore');
- });
- },
- cursorZoom: function () {
- var self = this;
- $('.cursorZoom').on('mouseenter', function () {
- self.$cursor1.classList.add('zoom');
- });
- $('.cursorZoom').on('mouseleave', function () {
- self.$cursor1.classList.remove('zoom');
- });
- },
- cursorNext: function () {
- var self = this;
- $('.cursorNext').on('mouseenter', function () {
- self.$cursor1.classList.add('next');
- });
- $('.cursorNext').on('mouseleave', function () {
- self.$cursor1.classList.remove('next');
- });
- },
- cursorPrev: function () {
- var self = this;
- $('.cursorPrev').on('mouseenter', function () {
- self.$cursor1.classList.add('prev');
- });
- $('.cursorPrev').on('mouseleave', function () {
- self.$cursor1.classList.remove('prev');
- });
- }
- }
- if (!isMobile) {
- cursor.init(); //Init custom cursor
- }
- //--------------------------------------------------
- // Work detail slider
- //--------------------------------------------------
- workSlider();
- function workSlider() {
- var workSlide = $('.work-slider .owl-carousel');
- workSlide.owlCarousel({
- loop: true,
- margin: 30,
- mouseDrag: false,
- autoplay: false,
- center: false,
- dots: false,
- dragEndSpeed: 700,
- smartSpeed: 2000,
- responsiveClass: true,
- autoplayHoverPause: true,
- autoplayTimeout: 9000,
- responsive: {
- 0: {
- items: 1,
- margin: 0,
- },
- 600: {
- items: 1,
- margin: 0,
- },
- 1000: {
- items: 1,
- margin: 0,
- }
- }
- });
- $('.right-over-next').on("click", function () {
- workSlide.trigger('next.owl.carousel');
- })
- $('.right-over-prev').on("click", function () {
- workSlide.trigger('prev.owl.carousel');
- })
- }
- //--------------------------------------------------
- // Toggle Menu
- //--------------------------------------------------
- var t1 = new TimelineMax({
- paused: true
- });
- t1.to(".one", 0.4, {
- y: 9,
- autoAlpha: 0,
- ease: Expo.easeInOut
- });
- t1.to(".two", 0.4, {
- ease: Expo.easeInOut,
- delay: -1
- });
- t1.to(".tre", 0.4, {
- y: -9,
- autoAlpha: 0,
- ease: Expo.easeInOut,
- delay: -1
- });
- t1.to(".over-all", 0.5, {
- autoAlpha: 1,
- ease: Expo.easeOut,
- })
- t1.to(".bg-nav", 0.5, {
- autoAlpha: 1,
- ease: Power4.easeOut,
- delay: -1
- })
- t1.to(".menu", 0.5, {
- autoAlpha: 1,
- ease: Expo.easeOut,
- delay: -1
- })
- t1.staggerFrom(".menu ul li", 1.5, {
- y: 50,
- opacity: 0,
- ease: Power4.easeInOut,
- }, '0.1', '-0.01');
- t1.reverse();
- $('.toggle-btn').on("click", function () {
- t1.reversed(!t1.reversed()); //toggles the orientation
- })
-
- //--------------------------------------------------
- // Magnetic
- //--------------------------------------------------
- $(document).on('mousemove', function (e) {
- $('.magnetic').each(function () {
- if (!isMobile) {
- magnetic(this, e); //Init effect magnetic
- }
- });
- });
- function magnetic(el, e) {
- var mX = e.pageX,
- mY = e.pageY;
- const obj = $(el);
- const customDist = 20 * obj.data('dist') || 80,
- centerX = obj.offset().left + obj.width() / 2,
- centerY = obj.offset().top + obj.height() / 2;
- var deltaX = Math.floor((centerX - mX)) * -.4,
- deltaY = Math.floor((centerY - mY)) * -.4;
- var distance = calcDistance(obj, mX, mY);
- if (distance < customDist) {
- TweenMax.to(obj, .4, {
- y: deltaY,
- x: deltaX
- });
- } else {
- TweenMax.to(obj, .4, {
- y: 0,
- x: 0
- });
- }
- }
- function calcDistance(elem, mouseX, mouseY) {
- return Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left + (elem.width() / 2)), 2) + Math.pow(mouseY - (elem.offset().top + (elem.height() / 2)), 2)));
- }
- //--------------------------------------------------
- // Zoom Image
- //--------------------------------------------------
- mediumZoom(document.querySelectorAll('.cover'), {
- background: '#000',
- })
- var workSlide = new Swiper('.swiper-container', {
- slidesPerView: 1,
- pagination: {
- el: '.swiper-pagination',
- type: 'progressbar',
- },
- loop: false,
- centeredSlides: false,
- speed: 900,
- spaceBetween: 0,
- mousewheel: true,
- });
- workSlide.on('slideChange', function () {
- TweenMax.to('.text-1', 0.3, {
- y: '80',
-
- })
- TweenMax.to('.text-2', 0.3, {
- y: '80',
-
- })
-
-
- });
- workSlide.on('slideChangeTransitionEnd', function () {
- TweenMax.to('.text-1', 0.3, {
- y: '0',
-
- })
- TweenMax.to('.text-2', 0.3, {
- y: '0',
-
- })
-
- });
- var toggler = $('.menu__toggler');
- var menu = $('.menus');
- toggler.on("click", function () {
- toggler.toggleClass('activez');
- menu.toggleClass('activez');
- });
- })(jQuery);
|