$(function () { 'use strict'; var modals={}; var currentmodal; // DOM ready, take it away gsap.config({ nullTargetWarn: false, }); $('.open-modal').each(function(){ activateModal('modal-'+$(this).attr('data-page-guid'), $(this)); }); function activateModal(id, $open) { var $modal=$('#'+id); if ($modal.length) { // sliders let $carousel = $modal.find('.slideshow'); $carousel.flickity({ cellAlign: 'left', contain: false, freeScroll: false, prevNextButtons: $modal.find(".slide").length>1, pageDots: $modal.find(".slide").length>1, wrapAround: true, adaptiveHeight: false, on: { change: function( index ) { // make sure any playing video is paused $('.video-player').each(function(player){ $(this).get(0).pause(); }) } } }); // center modal if content has less height then 500px if ($modal.find(".flickity-viewport").length) { var flickityVieport = $modal.find('.flickity-viewport'); var flickityVieportHeight = flickityVieport.height(); if (flickityVieportHeight < 500) { $.each(modals, function (i, modal) { $modal.css('align-items', 'center'); }); } } var $content=$modal.find('.modal-content'); // open modal on click $open.on('click', function () { modalOpen(id); let slideNumber = $open.data('page-index'); if (slideNumber !== null && slideNumber !== '') { //$carousel.flickity('select', slideNumber-1); $carousel.flickity('selectCell', '.slide-'+slideNumber); } }); const openModal = gsap.timeline({paused: true}); /* //fade animation self openModal.from($content, { delay: 0, duration: .4, ease: Power4.easeInOut, autoAlpha:1, y:'244px' }); //fadce animation background openModal.to($modal, { duration: .4, ease: Power4.easeInOut, autoAlpha:1 }); */ openModal.to($modal, { duration: .6, ease: Power4.easeOut, autoAlpha:1, onStart: function() { $('html').addClass('no-scroll'); }, }); openModal.from($content, { delay: -.3, duration: .6, ease: Power4.easeOut, autoAlpha:0, y:'0px', }); modals[id]=openModal; } } // open modal function modalOpen(modalId) { currentmodal= modals[modalId]; currentmodal.play().timeScale(1); } // close modal function modalClose(modalId) { if (currentmodal!==undefined) currentmodal.reverse().timeScale(-2) $('video').each(function() { $(this).get(0).pause(); }); $('html').removeClass('no-scroll'); } // close modal $('.modal-close').on('click', function () { modalClose(); }); $('.modal').click(function (event) { if (!$(event.target).closest('.modal-content').length && !$(event.target).is('.modal-content')) { modalClose(); } }); }); /*******************************************************************/ /* ftrtch dino */ /* [type: JS] [file:ilearn-carrousel-page] [120.960] DESIGN*/ /*******************************************************************/ /* 0.9 D>D */ /* db 178 */