{"version":3,"sources":["webpack:///./src/js/modules/MediaSlideshow.ts"],"names":["_slideshows","_options","autoPlay","pageDots","prevNextButtons","wrapAround","dragMoveEvent","document","createEvent","showCursorEvent","hideCursorEvent","this","initEvent","slideshow_elements","querySelectorAll","i","length","setupSlideshow","element","slides","querySelector","parseInt","dataset","realCount","on","val","handleSlideshowChange","images","addEventListener","handleImageLoaded","push","event","initCustomEvent","x","clientX","y","clientY","window","dispatchEvent","handleSlideshowContainerMouseEnter","handleSlideshowContainerMouseLeave","total","counter_element","corrected_index_val","innerText","toString","slideshow","resize","changeCursorLabelEvent","label"],"mappings":";;;;;;;;oIAAA,uFAKA,aAiBE,aAfQ,KAAAA,YAA+B,GAC/B,KAAAC,SAAmB,CAEzBC,SAAU,IACVC,UAAU,EACVC,iBAAiB,EACjBC,YAAY,GAIN,KAAAC,cAA6BC,SAASC,YAAY,eAClD,KAAAC,gBAA+BF,SAASC,YAAY,eACpD,KAAAE,gBAA+BH,SAASC,YAAY,eAK1DG,KAAKF,gBAAgBG,UAAU,mBAAmB,GAAO,GACzDD,KAAKD,gBAAgBE,UAAU,mBAAmB,GAAO,GAGzD,IADA,IAAMC,EAA8CN,SAASO,iBAAkB,sBACrEC,EAAY,EAAGA,EAAIF,EAAmBG,OAAQD,IAAKJ,KAAKM,eAAgBJ,EAAoBE,IA8E1G,OAzEU,YAAAE,eAAR,SAAwBC,GAAxB,WAEQC,EAAsBD,EAAQE,cAAe,8BAEnD,GAAKD,EAAS,CAEV,IAAM,EAAsB,IAAI,IAAUA,EAAQR,KAAKV,UACjD,EAAgBoB,SAASH,EAAQI,QAAQC,WACzC,EAA+BL,EAAQE,cAAe,wCAEvD,GAAS,GAAkB,EAAUI,GAAI,UAAU,SAAEC,GAAiB,SAAKC,sBAAuBD,EAAK,EAAO,MAGnH,IADA,IAAME,EAAuCT,EAAQJ,iBAAkB,OAC7DC,EAAY,EAAGA,EAAIY,EAAOX,OAAQD,IAE1CY,EAAQZ,GAAIa,iBAAkB,QAAQ,WAAM,SAAKC,kBAAmB,MAItElB,KAAKX,YAAY8B,KAAM,GAEvB,EAAUN,GAAI,YAAY,SAAEO,GAG1B,EAAKzB,cAAc0B,gBAAgB,iBAAiB,GAAO,EAAM,CAAEC,EAAGF,EAAMG,QAASC,EAAGJ,EAAMK,UAC9FC,OAAOC,cAAe,EAAKhC,kBAI7BY,EAAQU,iBAAkB,cAAc,WAAM,SAAKW,wCACnDrB,EAAQU,iBAAkB,cAAc,WAAM,SAAKY,0CAOjD,YAAAd,sBAAR,SAA+BD,EAAagB,EAAeC,GAEzD,IAAIC,EAA8BlB,EAAM,EAIxCkB,GADAA,EAAwBA,EAAsBF,EAAUE,EAAsBF,EAAQE,GACxCF,EAAUE,EAAsBF,EAAQE,EACtFD,EAAgBE,UAAYD,EAAoBE,YAK1C,YAAAhB,kBAAR,SAA2BiB,GAEzBA,EAAUC,UAKJ,YAAAR,mCAAR,WAEE5B,KAAKqC,uBAAyBzC,SAASC,YAAY,eACnDG,KAAKqC,uBAAuBhB,gBAAgB,0BAA0B,GAAO,EAAM,CAAEiB,MAAO,SAC5FZ,OAAOC,cAAc3B,KAAKqC,wBAE1BX,OAAOC,cAAc3B,KAAKF,kBAKpB,YAAA+B,mCAAR,WAEEH,OAAOC,cAAc3B,KAAKD,kBAI9B,EArGA","file":"js/mediaSlideshow.b7266153dbde83ecb853.js","sourcesContent":["import '../../css/global/flickity.css';\nimport '../../css/modules/media_slideshow.css';\n\nimport Flickity, { FlickityEvents } from 'flickity';\n\nexport class MediaSlideshow {\n\n private _slideshows: Array = [];\n private _options: Object = {\n\n autoPlay: 5000,\n pageDots: false,\n prevNextButtons: false,\n wrapAround: true\n\n }\n\n private dragMoveEvent: CustomEvent = document.createEvent(\"CustomEvent\");\n private showCursorEvent: CustomEvent = document.createEvent(\"CustomEvent\");\n private hideCursorEvent: CustomEvent = document.createEvent(\"CustomEvent\");\n private changeCursorLabelEvent: CustomEvent;\n\n constructor() {\n\n this.showCursorEvent.initEvent(\"showCursorEvent\", false, true);\n this.hideCursorEvent.initEvent(\"hideCursorEvent\", false, true);\n\n const slideshow_elements: NodeListOf = document.querySelectorAll( '.c-media-slideshow' );\n for ( let i: number = 0; i < slideshow_elements.length; i++) this.setupSlideshow( slideshow_elements[ i ] );\n\n }\n\n\n private setupSlideshow( element: HTMLElement ) {\n\n const slides: HTMLElement = element.querySelector( '.c-media-slideshow__slides' );\n\n if ( slides ) {\n\n const slideshow: Flickity = new Flickity( slides, this._options );\n const total: number = parseInt(element.dataset.realCount);\n const counter_element: HTMLElement = element.querySelector( '.c-media-slideshow__counter__current' );\n \n if ( total && counter_element ) slideshow.on( 'select', ( val: number ) => this.handleSlideshowChange( val, total, counter_element ) );\n \n const images: NodeListOf = element.querySelectorAll( 'img' );\n for ( let i: number = 0; i < images.length; i++ ) {\n \n images[ i ].addEventListener( 'load', () => this.handleImageLoaded( slideshow ) );\n \n }\n \n this._slideshows.push( slideshow );\n\n slideshow.on( 'dragMove', ( event: Event ) => {\n\n // @ts-ignore\n this.dragMoveEvent.initCustomEvent(\"dragMoveEvent\", false, true, { x: event.clientX, y: event.clientY } );\n window.dispatchEvent( this.dragMoveEvent );\n\n } );\n\n element.addEventListener( 'mouseenter', () => this.handleSlideshowContainerMouseEnter() );\n element.addEventListener( 'mouseleave', () => this.handleSlideshowContainerMouseLeave() );\n\n }\n\n }\n\n\n private handleSlideshowChange( val: number, total: number, counter_element: HTMLElement ) {\n\n let corrected_index_val: number = val + 1;\n // - total * 2 because all slides are appended twice when a low number of slides are in the slideshow.\n // Implemented to avoid empty spaces on the sides on wider screens\n corrected_index_val = ( corrected_index_val > total ) ? corrected_index_val - total : corrected_index_val;\n corrected_index_val = ( corrected_index_val > total ) ? corrected_index_val - total : corrected_index_val;\n counter_element.innerText = corrected_index_val.toString();\n\n }\n\n\n private handleImageLoaded( slideshow: Flickity ) {\n \n slideshow.resize();\n\n }\n\n\n private handleSlideshowContainerMouseEnter() {\n\n this.changeCursorLabelEvent = document.createEvent(\"CustomEvent\");\n this.changeCursorLabelEvent.initCustomEvent(\"changeCursorLabelEvent\", false, true, { label: 'drag' });\n window.dispatchEvent(this.changeCursorLabelEvent);\n\n window.dispatchEvent(this.showCursorEvent);\n\n }\n\n\n private handleSlideshowContainerMouseLeave() {\n \n window.dispatchEvent(this.hideCursorEvent);\n \n }\n\n}"],"sourceRoot":""}