vCarousel/public/JS/exampleFlickity.app.js

4104 lines
292 KiB
JavaScript

/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./node_modules/desandro-matches-selector/matches-selector.js":
/*!********************************************************************!*\
!*** ./node_modules/desandro-matches-selector/matches-selector.js ***!
\********************************************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
* matchesSelector v2.0.2
* matchesSelector( element, '.selector' )
* MIT license
*/
/*jshint browser: true, strict: true, undef: true, unused: true */
( function( window, factory ) {
/*global define: false, module: false */
'use strict';
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory() {
'use strict';
var matchesMethod = ( function() {
var ElemProto = window.Element.prototype;
// check for the standard method name first
if ( ElemProto.matches ) {
return 'matches';
}
// check un-prefixed
if ( ElemProto.matchesSelector ) {
return 'matchesSelector';
}
// check vendor prefixes
var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
for ( var i=0; i < prefixes.length; i++ ) {
var prefix = prefixes[i];
var method = prefix + 'MatchesSelector';
if ( ElemProto[ method ] ) {
return method;
}
}
})();
return function matchesSelector( elem, selector ) {
return elem[ matchesMethod ]( selector );
};
}));
/***/ }),
/***/ "./node_modules/ev-emitter/ev-emitter.js":
/*!***********************************************!*\
!*** ./node_modules/ev-emitter/ev-emitter.js ***!
\***********************************************/
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
* EvEmitter v1.1.0
* Lil' event emitter
* MIT License
*/
/* jshint unused: true, undef: true, strict: true */
( function( global, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, window */
if ( true ) {
// AMD - RequireJS
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( typeof window != 'undefined' ? window : this, function() {
"use strict";
function EvEmitter() {}
var proto = EvEmitter.prototype;
proto.on = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// set events hash
var events = this._events = this._events || {};
// set listeners array
var listeners = events[ eventName ] = events[ eventName ] || [];
// only add once
if ( listeners.indexOf( listener ) == -1 ) {
listeners.push( listener );
}
return this;
};
proto.once = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// add event
this.on( eventName, listener );
// set once flag
// set onceEvents hash
var onceEvents = this._onceEvents = this._onceEvents || {};
// set onceListeners object
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
// set flag
onceListeners[ listener ] = true;
return this;
};
proto.off = function( eventName, listener ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
var index = listeners.indexOf( listener );
if ( index != -1 ) {
listeners.splice( index, 1 );
}
return this;
};
proto.emitEvent = function( eventName, args ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
// copy over to avoid interference if .off() in listener
listeners = listeners.slice(0);
args = args || [];
// once stuff
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
for ( var i=0; i < listeners.length; i++ ) {
var listener = listeners[i]
var isOnce = onceListeners && onceListeners[ listener ];
if ( isOnce ) {
// remove listener
// remove before trigger to prevent recursion
this.off( eventName, listener );
// unset once flag
delete onceListeners[ listener ];
}
// trigger listener
listener.apply( this, args );
}
return this;
};
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
};
return EvEmitter;
}));
/***/ }),
/***/ "./node_modules/fizzy-ui-utils/utils.js":
/*!**********************************************!*\
!*** ./node_modules/fizzy-ui-utils/utils.js ***!
\**********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
* Fizzy UI utils v2.0.7
* MIT license
*/
/*jshint browser: true, undef: true, unused: true, strict: true */
( function( window, factory ) {
// universal module definition
/*jshint strict: false */ /*globals define, module, require */
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! desandro-matches-selector/matches-selector */ "./node_modules/desandro-matches-selector/matches-selector.js")
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( matchesSelector ) {
return factory( window, matchesSelector );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, matchesSelector ) {
'use strict';
var utils = {};
// ----- extend ----- //
// extends objects
utils.extend = function( a, b ) {
for ( var prop in b ) {
a[ prop ] = b[ prop ];
}
return a;
};
// ----- modulo ----- //
utils.modulo = function( num, div ) {
return ( ( num % div ) + div ) % div;
};
// ----- makeArray ----- //
var arraySlice = Array.prototype.slice;
// turn element or nodeList into an array
utils.makeArray = function( obj ) {
if ( Array.isArray( obj ) ) {
// use object if already an array
return obj;
}
// return empty array if undefined or null. #6
if ( obj === null || obj === undefined ) {
return [];
}
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
return arraySlice.call( obj );
}
// array of single index
return [ obj ];
};
// ----- removeFrom ----- //
utils.removeFrom = function( ary, obj ) {
var index = ary.indexOf( obj );
if ( index != -1 ) {
ary.splice( index, 1 );
}
};
// ----- getParent ----- //
utils.getParent = function( elem, selector ) {
while ( elem.parentNode && elem != document.body ) {
elem = elem.parentNode;
if ( matchesSelector( elem, selector ) ) {
return elem;
}
}
};
// ----- getQueryElement ----- //
// use element as selector string
utils.getQueryElement = function( elem ) {
if ( typeof elem == 'string' ) {
return document.querySelector( elem );
}
return elem;
};
// ----- handleEvent ----- //
// enable .ontype to trigger from .addEventListener( elem, 'type' )
utils.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
// ----- filterFindElements ----- //
utils.filterFindElements = function( elems, selector ) {
// make array of elems
elems = utils.makeArray( elems );
var ffElems = [];
elems.forEach( function( elem ) {
// check that elem is an actual element
if ( !( elem instanceof HTMLElement ) ) {
return;
}
// add elem if no selector
if ( !selector ) {
ffElems.push( elem );
return;
}
// filter & find items if we have a selector
// filter
if ( matchesSelector( elem, selector ) ) {
ffElems.push( elem );
}
// find children
var childElems = elem.querySelectorAll( selector );
// concat childElems to filterFound array
for ( var i=0; i < childElems.length; i++ ) {
ffElems.push( childElems[i] );
}
});
return ffElems;
};
// ----- debounceMethod ----- //
utils.debounceMethod = function( _class, methodName, threshold ) {
threshold = threshold || 100;
// original method
var method = _class.prototype[ methodName ];
var timeoutName = methodName + 'Timeout';
_class.prototype[ methodName ] = function() {
var timeout = this[ timeoutName ];
clearTimeout( timeout );
var args = arguments;
var _this = this;
this[ timeoutName ] = setTimeout( function() {
method.apply( _this, args );
delete _this[ timeoutName ];
}, threshold );
};
};
// ----- docReady ----- //
utils.docReady = function( callback ) {
var readyState = document.readyState;
if ( readyState == 'complete' || readyState == 'interactive' ) {
// do async to allow for other scripts to run. metafizzy/flickity#441
setTimeout( callback );
} else {
document.addEventListener( 'DOMContentLoaded', callback );
}
};
// ----- htmlInit ----- //
// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
utils.toDashed = function( str ) {
return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
return $1 + '-' + $2;
}).toLowerCase();
};
var console = window.console;
/**
* allow user to initialize classes via [data-namespace] or .js-namespace class
* htmlInit( Widget, 'widgetName' )
* options are parsed from data-namespace-options
*/
utils.htmlInit = function( WidgetClass, namespace ) {
utils.docReady( function() {
var dashedNamespace = utils.toDashed( namespace );
var dataAttr = 'data-' + dashedNamespace;
var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
var elems = utils.makeArray( dataAttrElems )
.concat( utils.makeArray( jsDashElems ) );
var dataOptionsAttr = dataAttr + '-options';
var jQuery = window.jQuery;
elems.forEach( function( elem ) {
var attr = elem.getAttribute( dataAttr ) ||
elem.getAttribute( dataOptionsAttr );
var options;
try {
options = attr && JSON.parse( attr );
} catch ( error ) {
// log error, do not initialize
if ( console ) {
console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
': ' + error );
}
return;
}
// initialize
var instance = new WidgetClass( elem, options );
// make available via $().data('namespace')
if ( jQuery ) {
jQuery.data( elem, namespace, instance );
}
});
});
};
// ----- ----- //
return utils;
}));
/***/ }),
/***/ "./node_modules/flickity/js/add-remove-cell.js":
/*!*****************************************************!*\
!*** ./node_modules/flickity/js/add-remove-cell.js ***!
\*****************************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// add, remove cell
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Flickity, utils ) {
return factory( window, Flickity, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Flickity, utils ) {
'use strict';
// append cells to a document fragment
function getCellsFragment( cells ) {
var fragment = document.createDocumentFragment();
cells.forEach( function( cell ) {
fragment.appendChild( cell.element );
} );
return fragment;
}
// -------------------------- add/remove cell prototype -------------------------- //
var proto = Flickity.prototype;
/**
* Insert, prepend, or append cells
* @param {[Element, Array, NodeList]} elems - Elements to insert
* @param {Integer} index - Zero-based number to insert
*/
proto.insert = function( elems, index ) {
var cells = this._makeCells( elems );
if ( !cells || !cells.length ) {
return;
}
var len = this.cells.length;
// default to append
index = index === undefined ? len : index;
// add cells with document fragment
var fragment = getCellsFragment( cells );
// append to slider
var isAppend = index == len;
if ( isAppend ) {
this.slider.appendChild( fragment );
} else {
var insertCellElement = this.cells[ index ].element;
this.slider.insertBefore( fragment, insertCellElement );
}
// add to this.cells
if ( index === 0 ) {
// prepend, add to start
this.cells = cells.concat( this.cells );
} else if ( isAppend ) {
// append, add to end
this.cells = this.cells.concat( cells );
} else {
// insert in this.cells
var endCells = this.cells.splice( index, len - index );
this.cells = this.cells.concat( cells ).concat( endCells );
}
this._sizeCells( cells );
this.cellChange( index, true );
};
proto.append = function( elems ) {
this.insert( elems, this.cells.length );
};
proto.prepend = function( elems ) {
this.insert( elems, 0 );
};
/**
* Remove cells
* @param {[Element, Array, NodeList]} elems - ELements to remove
*/
proto.remove = function( elems ) {
var cells = this.getCells( elems );
if ( !cells || !cells.length ) {
return;
}
var minCellIndex = this.cells.length - 1;
// remove cells from collection & DOM
cells.forEach( function( cell ) {
cell.remove();
var index = this.cells.indexOf( cell );
minCellIndex = Math.min( index, minCellIndex );
utils.removeFrom( this.cells, cell );
}, this );
this.cellChange( minCellIndex, true );
};
/**
* logic to be run after a cell's size changes
* @param {Element} elem - cell's element
*/
proto.cellSizeChange = function( elem ) {
var cell = this.getCell( elem );
if ( !cell ) {
return;
}
cell.getSize();
var index = this.cells.indexOf( cell );
this.cellChange( index );
};
/**
* logic any time a cell is changed: added, removed, or size changed
* @param {Integer} changedCellIndex - index of the changed cell, optional
* @param {Boolean} isPositioningSlider - Positions slider after selection
*/
proto.cellChange = function( changedCellIndex, isPositioningSlider ) {
var prevSelectedElem = this.selectedElement;
this._positionCells( changedCellIndex );
this._getWrapShiftCells();
this.setGallerySize();
// update selectedIndex
// try to maintain position & select previous selected element
var cell = this.getCell( prevSelectedElem );
if ( cell ) {
this.selectedIndex = this.getCellSlideIndex( cell );
}
this.selectedIndex = Math.min( this.slides.length - 1, this.selectedIndex );
this.emitEvent( 'cellChange', [ changedCellIndex ] );
// position slider
this.select( this.selectedIndex );
// do not position slider after lazy load
if ( isPositioningSlider ) {
this.positionSliderAtSelected();
}
};
// ----- ----- //
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/animate.js":
/*!*********************************************!*\
!*** ./node_modules/flickity/js/animate.js ***!
\*********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// animate
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( utils ) {
return factory( window, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, utils ) {
'use strict';
// -------------------------- animate -------------------------- //
var proto = {};
proto.startAnimation = function() {
if ( this.isAnimating ) {
return;
}
this.isAnimating = true;
this.restingFrames = 0;
this.animate();
};
proto.animate = function() {
this.applyDragForce();
this.applySelectedAttraction();
var previousX = this.x;
this.integratePhysics();
this.positionSlider();
this.settle( previousX );
// animate next frame
if ( this.isAnimating ) {
var _this = this;
requestAnimationFrame( function animateFrame() {
_this.animate();
} );
}
};
proto.positionSlider = function() {
var x = this.x;
// wrap position around
if ( this.options.wrapAround && this.cells.length > 1 ) {
x = utils.modulo( x, this.slideableWidth );
x -= this.slideableWidth;
this.shiftWrapCells( x );
}
this.setTranslateX( x, this.isAnimating );
this.dispatchScrollEvent();
};
proto.setTranslateX = function( x, is3d ) {
x += this.cursorPosition;
// reverse if right-to-left and using transform
x = this.options.rightToLeft ? -x : x;
var translateX = this.getPositionValue( x );
// use 3D transforms for hardware acceleration on iOS
// but use 2D when settled, for better font-rendering
this.slider.style.transform = is3d ?
'translate3d(' + translateX + ',0,0)' : 'translateX(' + translateX + ')';
};
proto.dispatchScrollEvent = function() {
var firstSlide = this.slides[0];
if ( !firstSlide ) {
return;
}
var positionX = -this.x - firstSlide.target;
var progress = positionX / this.slidesWidth;
this.dispatchEvent( 'scroll', null, [ progress, positionX ] );
};
proto.positionSliderAtSelected = function() {
if ( !this.cells.length ) {
return;
}
this.x = -this.selectedSlide.target;
this.velocity = 0; // stop wobble
this.positionSlider();
};
proto.getPositionValue = function( position ) {
if ( this.options.percentPosition ) {
// percent position, round to 2 digits, like 12.34%
return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 ) + '%';
} else {
// pixel positioning
return Math.round( position ) + 'px';
}
};
proto.settle = function( previousX ) {
// keep track of frames where x hasn't moved
var isResting = !this.isPointerDown &&
Math.round( this.x * 100 ) == Math.round( previousX * 100 );
if ( isResting ) {
this.restingFrames++;
}
// stop animating if resting for 3 or more frames
if ( this.restingFrames > 2 ) {
this.isAnimating = false;
delete this.isFreeScrolling;
// render position with translateX when settled
this.positionSlider();
this.dispatchEvent( 'settle', null, [ this.selectedIndex ] );
}
};
proto.shiftWrapCells = function( x ) {
// shift before cells
var beforeGap = this.cursorPosition + x;
this._shiftCells( this.beforeShiftCells, beforeGap, -1 );
// shift after cells
var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition );
this._shiftCells( this.afterShiftCells, afterGap, 1 );
};
proto._shiftCells = function( cells, gap, shift ) {
for ( var i = 0; i < cells.length; i++ ) {
var cell = cells[i];
var cellShift = gap > 0 ? shift : 0;
cell.wrapShift( cellShift );
gap -= cell.size.outerWidth;
}
};
proto._unshiftCells = function( cells ) {
if ( !cells || !cells.length ) {
return;
}
for ( var i = 0; i < cells.length; i++ ) {
cells[i].wrapShift( 0 );
}
};
// -------------------------- physics -------------------------- //
proto.integratePhysics = function() {
this.x += this.velocity;
this.velocity *= this.getFrictionFactor();
};
proto.applyForce = function( force ) {
this.velocity += force;
};
proto.getFrictionFactor = function() {
return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ];
};
proto.getRestingPosition = function() {
// my thanks to Steven Wittens, who simplified this math greatly
return this.x + this.velocity / ( 1 - this.getFrictionFactor() );
};
proto.applyDragForce = function() {
if ( !this.isDraggable || !this.isPointerDown ) {
return;
}
// change the position to drag position by applying force
var dragVelocity = this.dragX - this.x;
var dragForce = dragVelocity - this.velocity;
this.applyForce( dragForce );
};
proto.applySelectedAttraction = function() {
// do not attract if pointer down or no slides
var dragDown = this.isDraggable && this.isPointerDown;
if ( dragDown || this.isFreeScrolling || !this.slides.length ) {
return;
}
var distance = this.selectedSlide.target * -1 - this.x;
var force = distance * this.options.selectedAttraction;
this.applyForce( force );
};
return proto;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/cell.js":
/*!******************************************!*\
!*** ./node_modules/flickity/js/cell.js ***!
\******************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Flickity.Cell
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! get-size/get-size */ "./node_modules/get-size/get-size.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( getSize ) {
return factory( window, getSize );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, getSize ) {
'use strict';
function Cell( elem, parent ) {
this.element = elem;
this.parent = parent;
this.create();
}
var proto = Cell.prototype;
proto.create = function() {
this.element.style.position = 'absolute';
this.element.setAttribute( 'aria-hidden', 'true' );
this.x = 0;
this.shift = 0;
};
proto.destroy = function() {
// reset style
this.unselect();
this.element.style.position = '';
var side = this.parent.originSide;
this.element.style[ side ] = '';
this.element.removeAttribute('aria-hidden');
};
proto.getSize = function() {
this.size = getSize( this.element );
};
proto.setPosition = function( x ) {
this.x = x;
this.updateTarget();
this.renderPosition( x );
};
// setDefaultTarget v1 method, backwards compatibility, remove in v3
proto.updateTarget = proto.setDefaultTarget = function() {
var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
this.target = this.x + this.size[ marginProperty ] +
this.size.width * this.parent.cellAlign;
};
proto.renderPosition = function( x ) {
// render position of cell with in slider
var side = this.parent.originSide;
this.element.style[ side ] = this.parent.getPositionValue( x );
};
proto.select = function() {
this.element.classList.add('is-selected');
this.element.removeAttribute('aria-hidden');
};
proto.unselect = function() {
this.element.classList.remove('is-selected');
this.element.setAttribute( 'aria-hidden', 'true' );
};
/**
* @param {Integer} shift - 0, 1, or -1
*/
proto.wrapShift = function( shift ) {
this.shift = shift;
this.renderPosition( this.x + this.parent.slideableWidth * shift );
};
proto.remove = function() {
this.element.parentNode.removeChild( this.element );
};
return Cell;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/drag.js":
/*!******************************************!*\
!*** ./node_modules/flickity/js/drag.js ***!
\******************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// drag
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! unidragger/unidragger */ "./node_modules/unidragger/unidragger.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Flickity, Unidragger, utils ) {
return factory( window, Flickity, Unidragger, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Flickity, Unidragger, utils ) {
'use strict';
// ----- defaults ----- //
utils.extend( Flickity.defaults, {
draggable: '>1',
dragThreshold: 3,
} );
// ----- create ----- //
Flickity.createMethods.push('_createDrag');
// -------------------------- drag prototype -------------------------- //
var proto = Flickity.prototype;
utils.extend( proto, Unidragger.prototype );
proto._touchActionValue = 'pan-y';
// -------------------------- -------------------------- //
var isTouch = 'createTouch' in document;
var isTouchmoveScrollCanceled = false;
proto._createDrag = function() {
this.on( 'activate', this.onActivateDrag );
this.on( 'uiChange', this._uiChangeDrag );
this.on( 'deactivate', this.onDeactivateDrag );
this.on( 'cellChange', this.updateDraggable );
// TODO updateDraggable on resize? if groupCells & slides change
// HACK - add seemingly innocuous handler to fix iOS 10 scroll behavior
// #457, RubaXa/Sortable#973
if ( isTouch && !isTouchmoveScrollCanceled ) {
window.addEventListener( 'touchmove', function() {} );
isTouchmoveScrollCanceled = true;
}
};
proto.onActivateDrag = function() {
this.handles = [ this.viewport ];
this.bindHandles();
this.updateDraggable();
};
proto.onDeactivateDrag = function() {
this.unbindHandles();
this.element.classList.remove('is-draggable');
};
proto.updateDraggable = function() {
// disable dragging if less than 2 slides. #278
if ( this.options.draggable == '>1' ) {
this.isDraggable = this.slides.length > 1;
} else {
this.isDraggable = this.options.draggable;
}
if ( this.isDraggable ) {
this.element.classList.add('is-draggable');
} else {
this.element.classList.remove('is-draggable');
}
};
// backwards compatibility
proto.bindDrag = function() {
this.options.draggable = true;
this.updateDraggable();
};
proto.unbindDrag = function() {
this.options.draggable = false;
this.updateDraggable();
};
proto._uiChangeDrag = function() {
delete this.isFreeScrolling;
};
// -------------------------- pointer events -------------------------- //
proto.pointerDown = function( event, pointer ) {
if ( !this.isDraggable ) {
this._pointerDownDefault( event, pointer );
return;
}
var isOkay = this.okayPointerDown( event );
if ( !isOkay ) {
return;
}
this._pointerDownPreventDefault( event );
this.pointerDownFocus( event );
// blur
if ( document.activeElement != this.element ) {
// do not blur if already focused
this.pointerDownBlur();
}
// stop if it was moving
this.dragX = this.x;
this.viewport.classList.add('is-pointer-down');
// track scrolling
this.pointerDownScroll = getScrollPosition();
window.addEventListener( 'scroll', this );
this._pointerDownDefault( event, pointer );
};
// default pointerDown logic, used for staticClick
proto._pointerDownDefault = function( event, pointer ) {
// track start event position
// Safari 9 overrides pageX and pageY. These values needs to be copied. #779
this.pointerDownPointer = {
pageX: pointer.pageX,
pageY: pointer.pageY,
};
// bind move and end events
this._bindPostStartEvents( event );
this.dispatchEvent( 'pointerDown', event, [ pointer ] );
};
var focusNodes = {
INPUT: true,
TEXTAREA: true,
SELECT: true,
};
proto.pointerDownFocus = function( event ) {
var isFocusNode = focusNodes[ event.target.nodeName ];
if ( !isFocusNode ) {
this.focus();
}
};
proto._pointerDownPreventDefault = function( event ) {
var isTouchStart = event.type == 'touchstart';
var isTouchPointer = event.pointerType == 'touch';
var isFocusNode = focusNodes[ event.target.nodeName ];
if ( !isTouchStart && !isTouchPointer && !isFocusNode ) {
event.preventDefault();
}
};
// ----- move ----- //
proto.hasDragStarted = function( moveVector ) {
return Math.abs( moveVector.x ) > this.options.dragThreshold;
};
// ----- up ----- //
proto.pointerUp = function( event, pointer ) {
delete this.isTouchScrolling;
this.viewport.classList.remove('is-pointer-down');
this.dispatchEvent( 'pointerUp', event, [ pointer ] );
this._dragPointerUp( event, pointer );
};
proto.pointerDone = function() {
window.removeEventListener( 'scroll', this );
delete this.pointerDownScroll;
};
// -------------------------- dragging -------------------------- //
proto.dragStart = function( event, pointer ) {
if ( !this.isDraggable ) {
return;
}
this.dragStartPosition = this.x;
this.startAnimation();
window.removeEventListener( 'scroll', this );
this.dispatchEvent( 'dragStart', event, [ pointer ] );
};
proto.pointerMove = function( event, pointer ) {
var moveVector = this._dragPointerMove( event, pointer );
this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );
this._dragMove( event, pointer, moveVector );
};
proto.dragMove = function( event, pointer, moveVector ) {
if ( !this.isDraggable ) {
return;
}
event.preventDefault();
this.previousDragX = this.dragX;
// reverse if right-to-left
var direction = this.options.rightToLeft ? -1 : 1;
if ( this.options.wrapAround ) {
// wrap around move. #589
moveVector.x %= this.slideableWidth;
}
var dragX = this.dragStartPosition + moveVector.x * direction;
if ( !this.options.wrapAround && this.slides.length ) {
// slow drag
var originBound = Math.max( -this.slides[0].target, this.dragStartPosition );
dragX = dragX > originBound ? ( dragX + originBound ) * 0.5 : dragX;
var endBound = Math.min( -this.getLastSlide().target, this.dragStartPosition );
dragX = dragX < endBound ? ( dragX + endBound ) * 0.5 : dragX;
}
this.dragX = dragX;
this.dragMoveTime = new Date();
this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );
};
proto.dragEnd = function( event, pointer ) {
if ( !this.isDraggable ) {
return;
}
if ( this.options.freeScroll ) {
this.isFreeScrolling = true;
}
// set selectedIndex based on where flick will end up
var index = this.dragEndRestingSelect();
if ( this.options.freeScroll && !this.options.wrapAround ) {
// if free-scroll & not wrap around
// do not free-scroll if going outside of bounding slides
// so bounding slides can attract slider, and keep it in bounds
var restingX = this.getRestingPosition();
this.isFreeScrolling = -restingX > this.slides[0].target &&
-restingX < this.getLastSlide().target;
} else if ( !this.options.freeScroll && index == this.selectedIndex ) {
// boost selection if selected index has not changed
index += this.dragEndBoostSelect();
}
delete this.previousDragX;
// apply selection
// TODO refactor this, selecting here feels weird
// HACK, set flag so dragging stays in correct direction
this.isDragSelect = this.options.wrapAround;
this.select( index );
delete this.isDragSelect;
this.dispatchEvent( 'dragEnd', event, [ pointer ] );
};
proto.dragEndRestingSelect = function() {
var restingX = this.getRestingPosition();
// how far away from selected slide
var distance = Math.abs( this.getSlideDistance( -restingX, this.selectedIndex ) );
// get closet resting going up and going down
var positiveResting = this._getClosestResting( restingX, distance, 1 );
var negativeResting = this._getClosestResting( restingX, distance, -1 );
// use closer resting for wrap-around
var index = positiveResting.distance < negativeResting.distance ?
positiveResting.index : negativeResting.index;
return index;
};
/**
* given resting X and distance to selected cell
* get the distance and index of the closest cell
* @param {Number} restingX - estimated post-flick resting position
* @param {Number} distance - distance to selected cell
* @param {Integer} increment - +1 or -1, going up or down
* @returns {Object} - { distance: {Number}, index: {Integer} }
*/
proto._getClosestResting = function( restingX, distance, increment ) {
var index = this.selectedIndex;
var minDistance = Infinity;
var condition = this.options.contain && !this.options.wrapAround ?
// if contain, keep going if distance is equal to minDistance
function( dist, minDist ) {
return dist <= minDist;
} : function( dist, minDist ) {
return dist < minDist;
};
while ( condition( distance, minDistance ) ) {
// measure distance to next cell
index += increment;
minDistance = distance;
distance = this.getSlideDistance( -restingX, index );
if ( distance === null ) {
break;
}
distance = Math.abs( distance );
}
return {
distance: minDistance,
// selected was previous index
index: index - increment,
};
};
/**
* measure distance between x and a slide target
* @param {Number} x - horizontal position
* @param {Integer} index - slide index
* @returns {Number} - slide distance
*/
proto.getSlideDistance = function( x, index ) {
var len = this.slides.length;
// wrap around if at least 2 slides
var isWrapAround = this.options.wrapAround && len > 1;
var slideIndex = isWrapAround ? utils.modulo( index, len ) : index;
var slide = this.slides[ slideIndex ];
if ( !slide ) {
return null;
}
// add distance for wrap-around slides
var wrap = isWrapAround ? this.slideableWidth * Math.floor( index/len ) : 0;
return x - ( slide.target + wrap );
};
proto.dragEndBoostSelect = function() {
// do not boost if no previousDragX or dragMoveTime
if ( this.previousDragX === undefined || !this.dragMoveTime ||
// or if drag was held for 100 ms
new Date() - this.dragMoveTime > 100 ) {
return 0;
}
var distance = this.getSlideDistance( -this.dragX, this.selectedIndex );
var delta = this.previousDragX - this.dragX;
if ( distance > 0 && delta > 0 ) {
// boost to next if moving towards the right, and positive velocity
return 1;
} else if ( distance < 0 && delta < 0 ) {
// boost to previous if moving towards the left, and negative velocity
return -1;
}
return 0;
};
// ----- staticClick ----- //
proto.staticClick = function( event, pointer ) {
// get clickedCell, if cell was clicked
var clickedCell = this.getParentCell( event.target );
var cellElem = clickedCell && clickedCell.element;
var cellIndex = clickedCell && this.cells.indexOf( clickedCell );
this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] );
};
// ----- scroll ----- //
proto.onscroll = function() {
var scroll = getScrollPosition();
var scrollMoveX = this.pointerDownScroll.x - scroll.x;
var scrollMoveY = this.pointerDownScroll.y - scroll.y;
// cancel click/tap if scroll is too much
if ( Math.abs( scrollMoveX ) > 3 || Math.abs( scrollMoveY ) > 3 ) {
this._pointerDone();
}
};
// ----- utils ----- //
function getScrollPosition() {
return {
x: window.pageXOffset,
y: window.pageYOffset,
};
}
// ----- ----- //
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/flickity.js":
/*!**********************************************!*\
!*** ./node_modules/flickity/js/flickity.js ***!
\**********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Flickity main
/* eslint-disable max-params */
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ev-emitter/ev-emitter */ "./node_modules/ev-emitter/ev-emitter.js"),
__webpack_require__(/*! get-size/get-size */ "./node_modules/get-size/get-size.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
__webpack_require__(/*! ./cell */ "./node_modules/flickity/js/cell.js"),
__webpack_require__(/*! ./slide */ "./node_modules/flickity/js/slide.js"),
__webpack_require__(/*! ./animate */ "./node_modules/flickity/js/animate.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( EvEmitter, getSize, utils, Cell, Slide, animatePrototype ) {
return factory( window, EvEmitter, getSize, utils, Cell, Slide, animatePrototype );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else { var _Flickity; }
}( window, function factory( window, EvEmitter, getSize,
utils, Cell, Slide, animatePrototype ) {
/* eslint-enable max-params */
'use strict';
// vars
var jQuery = window.jQuery;
var getComputedStyle = window.getComputedStyle;
var console = window.console;
function moveElements( elems, toElem ) {
elems = utils.makeArray( elems );
while ( elems.length ) {
toElem.appendChild( elems.shift() );
}
}
// -------------------------- Flickity -------------------------- //
// globally unique identifiers
var GUID = 0;
// internal store of all Flickity intances
var instances = {};
function Flickity( element, options ) {
var queryElement = utils.getQueryElement( element );
if ( !queryElement ) {
if ( console ) {
console.error( 'Bad element for Flickity: ' + ( queryElement || element ) );
}
return;
}
this.element = queryElement;
// do not initialize twice on same element
if ( this.element.flickityGUID ) {
var instance = instances[ this.element.flickityGUID ];
if ( instance ) instance.option( options );
return instance;
}
// add jQuery
if ( jQuery ) {
this.$element = jQuery( this.element );
}
// options
this.options = utils.extend( {}, this.constructor.defaults );
this.option( options );
// kick things off
this._create();
}
Flickity.defaults = {
accessibility: true,
// adaptiveHeight: false,
cellAlign: 'center',
// cellSelector: undefined,
// contain: false,
freeScrollFriction: 0.075, // friction when free-scrolling
friction: 0.28, // friction when selecting
namespaceJQueryEvents: true,
// initialIndex: 0,
percentPosition: true,
resize: true,
selectedAttraction: 0.025,
setGallerySize: true,
// watchCSS: false,
// wrapAround: false
};
// hash of methods triggered on _create()
Flickity.createMethods = [];
var proto = Flickity.prototype;
// inherit EventEmitter
utils.extend( proto, EvEmitter.prototype );
proto._create = function() {
// add id for Flickity.data
var id = this.guid = ++GUID;
this.element.flickityGUID = id; // expando
instances[ id ] = this; // associate via id
// initial properties
this.selectedIndex = 0;
// how many frames slider has been in same position
this.restingFrames = 0;
// initial physics properties
this.x = 0;
this.velocity = 0;
this.originSide = this.options.rightToLeft ? 'right' : 'left';
// create viewport & slider
this.viewport = document.createElement('div');
this.viewport.className = 'flickity-viewport';
this._createSlider();
if ( this.options.resize || this.options.watchCSS ) {
window.addEventListener( 'resize', this );
}
// add listeners from on option
for ( var eventName in this.options.on ) {
var listener = this.options.on[ eventName ];
this.on( eventName, listener );
}
Flickity.createMethods.forEach( function( method ) {
this[ method ]();
}, this );
if ( this.options.watchCSS ) {
this.watchCSS();
} else {
this.activate();
}
};
/**
* set options
* @param {Object} opts - options to extend
*/
proto.option = function( opts ) {
utils.extend( this.options, opts );
};
proto.activate = function() {
if ( this.isActive ) {
return;
}
this.isActive = true;
this.element.classList.add('flickity-enabled');
if ( this.options.rightToLeft ) {
this.element.classList.add('flickity-rtl');
}
this.getSize();
// move initial cell elements so they can be loaded as cells
var cellElems = this._filterFindCellElements( this.element.children );
moveElements( cellElems, this.slider );
this.viewport.appendChild( this.slider );
this.element.appendChild( this.viewport );
// get cells from children
this.reloadCells();
if ( this.options.accessibility ) {
// allow element to focusable
this.element.tabIndex = 0;
// listen for key presses
this.element.addEventListener( 'keydown', this );
}
this.emitEvent('activate');
this.selectInitialIndex();
// flag for initial activation, for using initialIndex
this.isInitActivated = true;
// ready event. #493
this.dispatchEvent('ready');
};
// slider positions the cells
proto._createSlider = function() {
// slider element does all the positioning
var slider = document.createElement('div');
slider.className = 'flickity-slider';
slider.style[ this.originSide ] = 0;
this.slider = slider;
};
proto._filterFindCellElements = function( elems ) {
return utils.filterFindElements( elems, this.options.cellSelector );
};
// goes through all children
proto.reloadCells = function() {
// collection of item elements
this.cells = this._makeCells( this.slider.children );
this.positionCells();
this._getWrapShiftCells();
this.setGallerySize();
};
/**
* turn elements into Flickity.Cells
* @param {[Array, NodeList, HTMLElement]} elems - elements to make into cells
* @returns {Array} items - collection of new Flickity Cells
*/
proto._makeCells = function( elems ) {
var cellElems = this._filterFindCellElements( elems );
// create new Flickity for collection
var cells = cellElems.map( function( cellElem ) {
return new Cell( cellElem, this );
}, this );
return cells;
};
proto.getLastCell = function() {
return this.cells[ this.cells.length - 1 ];
};
proto.getLastSlide = function() {
return this.slides[ this.slides.length - 1 ];
};
// positions all cells
proto.positionCells = function() {
// size all cells
this._sizeCells( this.cells );
// position all cells
this._positionCells( 0 );
};
/**
* position certain cells
* @param {Integer} index - which cell to start with
*/
proto._positionCells = function( index ) {
index = index || 0;
// also measure maxCellHeight
// start 0 if positioning all cells
this.maxCellHeight = index ? this.maxCellHeight || 0 : 0;
var cellX = 0;
// get cellX
if ( index > 0 ) {
var startCell = this.cells[ index - 1 ];
cellX = startCell.x + startCell.size.outerWidth;
}
var len = this.cells.length;
for ( var i = index; i < len; i++ ) {
var cell = this.cells[i];
cell.setPosition( cellX );
cellX += cell.size.outerWidth;
this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight );
}
// keep track of cellX for wrap-around
this.slideableWidth = cellX;
// slides
this.updateSlides();
// contain slides target
this._containSlides();
// update slidesWidth
this.slidesWidth = len ? this.getLastSlide().target - this.slides[0].target : 0;
};
/**
* cell.getSize() on multiple cells
* @param {Array} cells - cells to size
*/
proto._sizeCells = function( cells ) {
cells.forEach( function( cell ) {
cell.getSize();
} );
};
// -------------------------- -------------------------- //
proto.updateSlides = function() {
this.slides = [];
if ( !this.cells.length ) {
return;
}
var slide = new Slide( this );
this.slides.push( slide );
var isOriginLeft = this.originSide == 'left';
var nextMargin = isOriginLeft ? 'marginRight' : 'marginLeft';
var canCellFit = this._getCanCellFit();
this.cells.forEach( function( cell, i ) {
// just add cell if first cell in slide
if ( !slide.cells.length ) {
slide.addCell( cell );
return;
}
var slideWidth = ( slide.outerWidth - slide.firstMargin ) +
( cell.size.outerWidth - cell.size[ nextMargin ] );
if ( canCellFit.call( this, i, slideWidth ) ) {
slide.addCell( cell );
} else {
// doesn't fit, new slide
slide.updateTarget();
slide = new Slide( this );
this.slides.push( slide );
slide.addCell( cell );
}
}, this );
// last slide
slide.updateTarget();
// update .selectedSlide
this.updateSelectedSlide();
};
proto._getCanCellFit = function() {
var groupCells = this.options.groupCells;
if ( !groupCells ) {
return function() {
return false;
};
} else if ( typeof groupCells == 'number' ) {
// group by number. 3 -> [0,1,2], [3,4,5], ...
var number = parseInt( groupCells, 10 );
return function( i ) {
return ( i % number ) !== 0;
};
}
// default, group by width of slide
// parse '75%
var percentMatch = typeof groupCells == 'string' &&
groupCells.match( /^(\d+)%$/ );
var percent = percentMatch ? parseInt( percentMatch[1], 10 ) / 100 : 1;
return function( i, slideWidth ) {
/* eslint-disable-next-line no-invalid-this */
return slideWidth <= ( this.size.innerWidth + 1 ) * percent;
};
};
// alias _init for jQuery plugin .flickity()
proto._init =
proto.reposition = function() {
this.positionCells();
this.positionSliderAtSelected();
};
proto.getSize = function() {
this.size = getSize( this.element );
this.setCellAlign();
this.cursorPosition = this.size.innerWidth * this.cellAlign;
};
var cellAlignShorthands = {
// cell align, then based on origin side
center: {
left: 0.5,
right: 0.5,
},
left: {
left: 0,
right: 1,
},
right: {
right: 0,
left: 1,
},
};
proto.setCellAlign = function() {
var shorthand = cellAlignShorthands[ this.options.cellAlign ];
this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign;
};
proto.setGallerySize = function() {
if ( this.options.setGallerySize ) {
var height = this.options.adaptiveHeight && this.selectedSlide ?
this.selectedSlide.height : this.maxCellHeight;
this.viewport.style.height = height + 'px';
}
};
proto._getWrapShiftCells = function() {
// only for wrap-around
if ( !this.options.wrapAround ) {
return;
}
// unshift previous cells
this._unshiftCells( this.beforeShiftCells );
this._unshiftCells( this.afterShiftCells );
// get before cells
// initial gap
var gapX = this.cursorPosition;
var cellIndex = this.cells.length - 1;
this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );
// get after cells
// ending gap between last cell and end of gallery viewport
gapX = this.size.innerWidth - this.cursorPosition;
// start cloning at first cell, working forwards
this.afterShiftCells = this._getGapCells( gapX, 0, 1 );
};
proto._getGapCells = function( gapX, cellIndex, increment ) {
// keep adding cells until the cover the initial gap
var cells = [];
while ( gapX > 0 ) {
var cell = this.cells[ cellIndex ];
if ( !cell ) {
break;
}
cells.push( cell );
cellIndex += increment;
gapX -= cell.size.outerWidth;
}
return cells;
};
// ----- contain ----- //
// contain cell targets so no excess sliding
proto._containSlides = function() {
if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) {
return;
}
var isRightToLeft = this.options.rightToLeft;
var beginMargin = isRightToLeft ? 'marginRight' : 'marginLeft';
var endMargin = isRightToLeft ? 'marginLeft' : 'marginRight';
var contentWidth = this.slideableWidth - this.getLastCell().size[ endMargin ];
// content is less than gallery size
var isContentSmaller = contentWidth < this.size.innerWidth;
// bounds
var beginBound = this.cursorPosition + this.cells[0].size[ beginMargin ];
var endBound = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign );
// contain each cell target
this.slides.forEach( function( slide ) {
if ( isContentSmaller ) {
// all cells fit inside gallery
slide.target = contentWidth * this.cellAlign;
} else {
// contain to bounds
slide.target = Math.max( slide.target, beginBound );
slide.target = Math.min( slide.target, endBound );
}
}, this );
};
// ----- ----- //
/**
* emits events via eventEmitter and jQuery events
* @param {String} type - name of event
* @param {Event} event - original event
* @param {Array} args - extra arguments
*/
proto.dispatchEvent = function( type, event, args ) {
var emitArgs = event ? [ event ].concat( args ) : args;
this.emitEvent( type, emitArgs );
if ( jQuery && this.$element ) {
// default trigger with type if no event
type += this.options.namespaceJQueryEvents ? '.flickity' : '';
var $event = type;
if ( event ) {
// create jQuery event
var jQEvent = new jQuery.Event( event );
jQEvent.type = type;
$event = jQEvent;
}
this.$element.trigger( $event, args );
}
};
// -------------------------- select -------------------------- //
/**
* @param {Integer} index - index of the slide
* @param {Boolean} isWrap - will wrap-around to last/first if at the end
* @param {Boolean} isInstant - will immediately set position at selected cell
*/
proto.select = function( index, isWrap, isInstant ) {
if ( !this.isActive ) {
return;
}
index = parseInt( index, 10 );
this._wrapSelect( index );
if ( this.options.wrapAround || isWrap ) {
index = utils.modulo( index, this.slides.length );
}
// bail if invalid index
if ( !this.slides[ index ] ) {
return;
}
var prevIndex = this.selectedIndex;
this.selectedIndex = index;
this.updateSelectedSlide();
if ( isInstant ) {
this.positionSliderAtSelected();
} else {
this.startAnimation();
}
if ( this.options.adaptiveHeight ) {
this.setGallerySize();
}
// events
this.dispatchEvent( 'select', null, [ index ] );
// change event if new index
if ( index != prevIndex ) {
this.dispatchEvent( 'change', null, [ index ] );
}
// old v1 event name, remove in v3
this.dispatchEvent('cellSelect');
};
// wraps position for wrapAround, to move to closest slide. #113
proto._wrapSelect = function( index ) {
var len = this.slides.length;
var isWrapping = this.options.wrapAround && len > 1;
if ( !isWrapping ) {
return index;
}
var wrapIndex = utils.modulo( index, len );
// go to shortest
var delta = Math.abs( wrapIndex - this.selectedIndex );
var backWrapDelta = Math.abs( ( wrapIndex + len ) - this.selectedIndex );
var forewardWrapDelta = Math.abs( ( wrapIndex - len ) - this.selectedIndex );
if ( !this.isDragSelect && backWrapDelta < delta ) {
index += len;
} else if ( !this.isDragSelect && forewardWrapDelta < delta ) {
index -= len;
}
// wrap position so slider is within normal area
if ( index < 0 ) {
this.x -= this.slideableWidth;
} else if ( index >= len ) {
this.x += this.slideableWidth;
}
};
proto.previous = function( isWrap, isInstant ) {
this.select( this.selectedIndex - 1, isWrap, isInstant );
};
proto.next = function( isWrap, isInstant ) {
this.select( this.selectedIndex + 1, isWrap, isInstant );
};
proto.updateSelectedSlide = function() {
var slide = this.slides[ this.selectedIndex ];
// selectedIndex could be outside of slides, if triggered before resize()
if ( !slide ) {
return;
}
// unselect previous selected slide
this.unselectSelectedSlide();
// update new selected slide
this.selectedSlide = slide;
slide.select();
this.selectedCells = slide.cells;
this.selectedElements = slide.getCellElements();
// HACK: selectedCell & selectedElement is first cell in slide, backwards compatibility
// Remove in v3?
this.selectedCell = slide.cells[0];
this.selectedElement = this.selectedElements[0];
};
proto.unselectSelectedSlide = function() {
if ( this.selectedSlide ) {
this.selectedSlide.unselect();
}
};
proto.selectInitialIndex = function() {
var initialIndex = this.options.initialIndex;
// already activated, select previous selectedIndex
if ( this.isInitActivated ) {
this.select( this.selectedIndex, false, true );
return;
}
// select with selector string
if ( initialIndex && typeof initialIndex == 'string' ) {
var cell = this.queryCell( initialIndex );
if ( cell ) {
this.selectCell( initialIndex, false, true );
return;
}
}
var index = 0;
// select with number
if ( initialIndex && this.slides[ initialIndex ] ) {
index = initialIndex;
}
// select instantly
this.select( index, false, true );
};
/**
* select slide from number or cell element
* @param {[Element, Number]} value - zero-based index or element to select
* @param {Boolean} isWrap - enables wrapping around for extra index
* @param {Boolean} isInstant - disables slide animation
*/
proto.selectCell = function( value, isWrap, isInstant ) {
// get cell
var cell = this.queryCell( value );
if ( !cell ) {
return;
}
var index = this.getCellSlideIndex( cell );
this.select( index, isWrap, isInstant );
};
proto.getCellSlideIndex = function( cell ) {
// get index of slides that has cell
for ( var i = 0; i < this.slides.length; i++ ) {
var slide = this.slides[i];
var index = slide.cells.indexOf( cell );
if ( index != -1 ) {
return i;
}
}
};
// -------------------------- get cells -------------------------- //
/**
* get Flickity.Cell, given an Element
* @param {Element} elem - matching cell element
* @returns {Flickity.Cell} cell - matching cell
*/
proto.getCell = function( elem ) {
// loop through cells to get the one that matches
for ( var i = 0; i < this.cells.length; i++ ) {
var cell = this.cells[i];
if ( cell.element == elem ) {
return cell;
}
}
};
/**
* get collection of Flickity.Cells, given Elements
* @param {[Element, Array, NodeList]} elems - multiple elements
* @returns {Array} cells - Flickity.Cells
*/
proto.getCells = function( elems ) {
elems = utils.makeArray( elems );
var cells = [];
elems.forEach( function( elem ) {
var cell = this.getCell( elem );
if ( cell ) {
cells.push( cell );
}
}, this );
return cells;
};
/**
* get cell elements
* @returns {Array} cellElems
*/
proto.getCellElements = function() {
return this.cells.map( function( cell ) {
return cell.element;
} );
};
/**
* get parent cell from an element
* @param {Element} elem - child element
* @returns {Flickit.Cell} cell - parent cell
*/
proto.getParentCell = function( elem ) {
// first check if elem is cell
var cell = this.getCell( elem );
if ( cell ) {
return cell;
}
// try to get parent cell elem
elem = utils.getParent( elem, '.flickity-slider > *' );
return this.getCell( elem );
};
/**
* get cells adjacent to a slide
* @param {Integer} adjCount - number of adjacent slides
* @param {Integer} index - index of slide to start
* @returns {Array} cells - array of Flickity.Cells
*/
proto.getAdjacentCellElements = function( adjCount, index ) {
if ( !adjCount ) {
return this.selectedSlide.getCellElements();
}
index = index === undefined ? this.selectedIndex : index;
var len = this.slides.length;
if ( 1 + ( adjCount * 2 ) >= len ) {
return this.getCellElements();
}
var cellElems = [];
for ( var i = index - adjCount; i <= index + adjCount; i++ ) {
var slideIndex = this.options.wrapAround ? utils.modulo( i, len ) : i;
var slide = this.slides[ slideIndex ];
if ( slide ) {
cellElems = cellElems.concat( slide.getCellElements() );
}
}
return cellElems;
};
/**
* select slide from number or cell element
* @param {[Element, String, Number]} selector - element, selector string, or index
* @returns {Flickity.Cell} - matching cell
*/
proto.queryCell = function( selector ) {
if ( typeof selector == 'number' ) {
// use number as index
return this.cells[ selector ];
}
if ( typeof selector == 'string' ) {
// do not select invalid selectors from hash: #123, #/. #791
if ( selector.match( /^[#.]?[\d/]/ ) ) {
return;
}
// use string as selector, get element
selector = this.element.querySelector( selector );
}
// get cell from element
return this.getCell( selector );
};
// -------------------------- events -------------------------- //
proto.uiChange = function() {
this.emitEvent('uiChange');
};
// keep focus on element when child UI elements are clicked
proto.childUIPointerDown = function( event ) {
// HACK iOS does not allow touch events to bubble up?!
if ( event.type != 'touchstart' ) {
event.preventDefault();
}
this.focus();
};
// ----- resize ----- //
proto.onresize = function() {
this.watchCSS();
this.resize();
};
utils.debounceMethod( Flickity, 'onresize', 150 );
proto.resize = function() {
if ( !this.isActive ) {
return;
}
this.getSize();
// wrap values
if ( this.options.wrapAround ) {
this.x = utils.modulo( this.x, this.slideableWidth );
}
this.positionCells();
this._getWrapShiftCells();
this.setGallerySize();
this.emitEvent('resize');
// update selected index for group slides, instant
// TODO: position can be lost between groups of various numbers
var selectedElement = this.selectedElements && this.selectedElements[0];
this.selectCell( selectedElement, false, true );
};
// watches the :after property, activates/deactivates
proto.watchCSS = function() {
var watchOption = this.options.watchCSS;
if ( !watchOption ) {
return;
}
var afterContent = getComputedStyle( this.element, ':after' ).content;
// activate if :after { content: 'flickity' }
if ( afterContent.indexOf('flickity') != -1 ) {
this.activate();
} else {
this.deactivate();
}
};
// ----- keydown ----- //
// go previous/next if left/right keys pressed
proto.onkeydown = function( event ) {
// only work if element is in focus
var isNotFocused = document.activeElement && document.activeElement != this.element;
if ( !this.options.accessibility || isNotFocused ) {
return;
}
var handler = Flickity.keyboardHandlers[ event.keyCode ];
if ( handler ) {
handler.call( this );
}
};
Flickity.keyboardHandlers = {
// left arrow
37: function() {
var leftMethod = this.options.rightToLeft ? 'next' : 'previous';
this.uiChange();
this[ leftMethod ]();
},
// right arrow
39: function() {
var rightMethod = this.options.rightToLeft ? 'previous' : 'next';
this.uiChange();
this[ rightMethod ]();
},
};
// ----- focus ----- //
proto.focus = function() {
// TODO remove scrollTo once focus options gets more support
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus ...
// #Browser_compatibility
var prevScrollY = window.pageYOffset;
this.element.focus({ preventScroll: true });
// hack to fix scroll jump after focus, #76
if ( window.pageYOffset != prevScrollY ) {
window.scrollTo( window.pageXOffset, prevScrollY );
}
};
// -------------------------- destroy -------------------------- //
// deactivate all Flickity functionality, but keep stuff available
proto.deactivate = function() {
if ( !this.isActive ) {
return;
}
this.element.classList.remove('flickity-enabled');
this.element.classList.remove('flickity-rtl');
this.unselectSelectedSlide();
// destroy cells
this.cells.forEach( function( cell ) {
cell.destroy();
} );
this.element.removeChild( this.viewport );
// move child elements back into element
moveElements( this.slider.children, this.element );
if ( this.options.accessibility ) {
this.element.removeAttribute('tabIndex');
this.element.removeEventListener( 'keydown', this );
}
// set flags
this.isActive = false;
this.emitEvent('deactivate');
};
proto.destroy = function() {
this.deactivate();
window.removeEventListener( 'resize', this );
this.allOff();
this.emitEvent('destroy');
if ( jQuery && this.$element ) {
jQuery.removeData( this.element, 'flickity' );
}
delete this.element.flickityGUID;
delete instances[ this.guid ];
};
// -------------------------- prototype -------------------------- //
utils.extend( proto, animatePrototype );
// -------------------------- extras -------------------------- //
/**
* get Flickity instance from element
* @param {[Element, String]} elem - element or selector string
* @returns {Flickity} - Flickity instance
*/
Flickity.data = function( elem ) {
elem = utils.getQueryElement( elem );
var id = elem && elem.flickityGUID;
return id && instances[ id ];
};
utils.htmlInit( Flickity, 'flickity' );
if ( jQuery && jQuery.bridget ) {
jQuery.bridget( 'flickity', Flickity );
}
// set internal jQuery, for Webpack + jQuery v3, #478
Flickity.setJQuery = function( jq ) {
jQuery = jq;
};
Flickity.Cell = Cell;
Flickity.Slide = Slide;
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/index.js":
/*!*******************************************!*\
!*** ./node_modules/flickity/js/index.js ***!
\*******************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* Flickity v2.2.2
* Touch, responsive, flickable carousels
*
* Licensed GPLv3 for open source use
* or Flickity Commercial License for commercial use
*
* https://flickity.metafizzy.co
* Copyright 2015-2021 Metafizzy
*/
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! ./drag */ "./node_modules/flickity/js/drag.js"),
__webpack_require__(/*! ./prev-next-button */ "./node_modules/flickity/js/prev-next-button.js"),
__webpack_require__(/*! ./page-dots */ "./node_modules/flickity/js/page-dots.js"),
__webpack_require__(/*! ./player */ "./node_modules/flickity/js/player.js"),
__webpack_require__(/*! ./add-remove-cell */ "./node_modules/flickity/js/add-remove-cell.js"),
__webpack_require__(/*! ./lazyload */ "./node_modules/flickity/js/lazyload.js"),
], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
} )( window, function factory( Flickity ) {
return Flickity;
} );
/***/ }),
/***/ "./node_modules/flickity/js/lazyload.js":
/*!**********************************************!*\
!*** ./node_modules/flickity/js/lazyload.js ***!
\**********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// lazyload
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Flickity, utils ) {
return factory( window, Flickity, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Flickity, utils ) {
'use strict';
Flickity.createMethods.push('_createLazyload');
var proto = Flickity.prototype;
proto._createLazyload = function() {
this.on( 'select', this.lazyLoad );
};
proto.lazyLoad = function() {
var lazyLoad = this.options.lazyLoad;
if ( !lazyLoad ) {
return;
}
// get adjacent cells, use lazyLoad option for adjacent count
var adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0;
var cellElems = this.getAdjacentCellElements( adjCount );
// get lazy images in those cells
var lazyImages = [];
cellElems.forEach( function( cellElem ) {
var lazyCellImages = getCellLazyImages( cellElem );
lazyImages = lazyImages.concat( lazyCellImages );
} );
// load lazy images
lazyImages.forEach( function( img ) {
new LazyLoader( img, this );
}, this );
};
function getCellLazyImages( cellElem ) {
// check if cell element is lazy image
if ( cellElem.nodeName == 'IMG' ) {
var lazyloadAttr = cellElem.getAttribute('data-flickity-lazyload');
var srcAttr = cellElem.getAttribute('data-flickity-lazyload-src');
var srcsetAttr = cellElem.getAttribute('data-flickity-lazyload-srcset');
if ( lazyloadAttr || srcAttr || srcsetAttr ) {
return [ cellElem ];
}
}
// select lazy images in cell
var lazySelector = 'img[data-flickity-lazyload], ' +
'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]';
var imgs = cellElem.querySelectorAll( lazySelector );
return utils.makeArray( imgs );
}
// -------------------------- LazyLoader -------------------------- //
/**
* class to handle loading images
* @param {Image} img - Image element
* @param {Flickity} flickity - Flickity instance
*/
function LazyLoader( img, flickity ) {
this.img = img;
this.flickity = flickity;
this.load();
}
LazyLoader.prototype.handleEvent = utils.handleEvent;
LazyLoader.prototype.load = function() {
this.img.addEventListener( 'load', this );
this.img.addEventListener( 'error', this );
// get src & srcset
var src = this.img.getAttribute('data-flickity-lazyload') ||
this.img.getAttribute('data-flickity-lazyload-src');
var srcset = this.img.getAttribute('data-flickity-lazyload-srcset');
// set src & serset
this.img.src = src;
if ( srcset ) {
this.img.setAttribute( 'srcset', srcset );
}
// remove attr
this.img.removeAttribute('data-flickity-lazyload');
this.img.removeAttribute('data-flickity-lazyload-src');
this.img.removeAttribute('data-flickity-lazyload-srcset');
};
LazyLoader.prototype.onload = function( event ) {
this.complete( event, 'flickity-lazyloaded' );
};
LazyLoader.prototype.onerror = function( event ) {
this.complete( event, 'flickity-lazyerror' );
};
LazyLoader.prototype.complete = function( event, className ) {
// unbind events
this.img.removeEventListener( 'load', this );
this.img.removeEventListener( 'error', this );
var cell = this.flickity.getParentCell( this.img );
var cellElem = cell && cell.element;
this.flickity.cellSizeChange( cellElem );
this.img.classList.add( className );
this.flickity.dispatchEvent( 'lazyLoad', event, cellElem );
};
// ----- ----- //
Flickity.LazyLoader = LazyLoader;
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/page-dots.js":
/*!***********************************************!*\
!*** ./node_modules/flickity/js/page-dots.js ***!
\***********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// page dots
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! unipointer/unipointer */ "./node_modules/unipointer/unipointer.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Flickity, Unipointer, utils ) {
return factory( window, Flickity, Unipointer, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Flickity, Unipointer, utils ) {
// -------------------------- PageDots -------------------------- //
'use strict';
function PageDots( parent ) {
this.parent = parent;
this._create();
}
PageDots.prototype = Object.create( Unipointer.prototype );
PageDots.prototype._create = function() {
// create holder element
this.holder = document.createElement('ol');
this.holder.className = 'flickity-page-dots';
// create dots, array of elements
this.dots = [];
// events
this.handleClick = this.onClick.bind( this );
this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );
};
PageDots.prototype.activate = function() {
this.setDots();
this.holder.addEventListener( 'click', this.handleClick );
this.bindStartEvent( this.holder );
// add to DOM
this.parent.element.appendChild( this.holder );
};
PageDots.prototype.deactivate = function() {
this.holder.removeEventListener( 'click', this.handleClick );
this.unbindStartEvent( this.holder );
// remove from DOM
this.parent.element.removeChild( this.holder );
};
PageDots.prototype.setDots = function() {
// get difference between number of slides and number of dots
var delta = this.parent.slides.length - this.dots.length;
if ( delta > 0 ) {
this.addDots( delta );
} else if ( delta < 0 ) {
this.removeDots( -delta );
}
};
PageDots.prototype.addDots = function( count ) {
var fragment = document.createDocumentFragment();
var newDots = [];
var length = this.dots.length;
var max = length + count;
for ( var i = length; i < max; i++ ) {
var dot = document.createElement('li');
dot.className = 'dot';
dot.setAttribute( 'aria-label', 'Page dot ' + ( i + 1 ) );
fragment.appendChild( dot );
newDots.push( dot );
}
this.holder.appendChild( fragment );
this.dots = this.dots.concat( newDots );
};
PageDots.prototype.removeDots = function( count ) {
// remove from this.dots collection
var removeDots = this.dots.splice( this.dots.length - count, count );
// remove from DOM
removeDots.forEach( function( dot ) {
this.holder.removeChild( dot );
}, this );
};
PageDots.prototype.updateSelected = function() {
// remove selected class on previous
if ( this.selectedDot ) {
this.selectedDot.className = 'dot';
this.selectedDot.removeAttribute('aria-current');
}
// don't proceed if no dots
if ( !this.dots.length ) {
return;
}
this.selectedDot = this.dots[ this.parent.selectedIndex ];
this.selectedDot.className = 'dot is-selected';
this.selectedDot.setAttribute( 'aria-current', 'step' );
};
PageDots.prototype.onTap = // old method name, backwards-compatible
PageDots.prototype.onClick = function( event ) {
var target = event.target;
// only care about dot clicks
if ( target.nodeName != 'LI' ) {
return;
}
this.parent.uiChange();
var index = this.dots.indexOf( target );
this.parent.select( index );
};
PageDots.prototype.destroy = function() {
this.deactivate();
this.allOff();
};
Flickity.PageDots = PageDots;
// -------------------------- Flickity -------------------------- //
utils.extend( Flickity.defaults, {
pageDots: true,
} );
Flickity.createMethods.push('_createPageDots');
var proto = Flickity.prototype;
proto._createPageDots = function() {
if ( !this.options.pageDots ) {
return;
}
this.pageDots = new PageDots( this );
// events
this.on( 'activate', this.activatePageDots );
this.on( 'select', this.updateSelectedPageDots );
this.on( 'cellChange', this.updatePageDots );
this.on( 'resize', this.updatePageDots );
this.on( 'deactivate', this.deactivatePageDots );
};
proto.activatePageDots = function() {
this.pageDots.activate();
};
proto.updateSelectedPageDots = function() {
this.pageDots.updateSelected();
};
proto.updatePageDots = function() {
this.pageDots.setDots();
};
proto.deactivatePageDots = function() {
this.pageDots.deactivate();
};
// ----- ----- //
Flickity.PageDots = PageDots;
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/player.js":
/*!********************************************!*\
!*** ./node_modules/flickity/js/player.js ***!
\********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// player & autoPlay
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ev-emitter/ev-emitter */ "./node_modules/ev-emitter/ev-emitter.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( EvEmitter, utils, Flickity ) {
return factory( EvEmitter, utils, Flickity );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( EvEmitter, utils, Flickity ) {
'use strict';
// -------------------------- Player -------------------------- //
function Player( parent ) {
this.parent = parent;
this.state = 'stopped';
// visibility change event handler
this.onVisibilityChange = this.visibilityChange.bind( this );
this.onVisibilityPlay = this.visibilityPlay.bind( this );
}
Player.prototype = Object.create( EvEmitter.prototype );
// start play
Player.prototype.play = function() {
if ( this.state == 'playing' ) {
return;
}
// do not play if page is hidden, start playing when page is visible
var isPageHidden = document.hidden;
if ( isPageHidden ) {
document.addEventListener( 'visibilitychange', this.onVisibilityPlay );
return;
}
this.state = 'playing';
// listen to visibility change
document.addEventListener( 'visibilitychange', this.onVisibilityChange );
// start ticking
this.tick();
};
Player.prototype.tick = function() {
// do not tick if not playing
if ( this.state != 'playing' ) {
return;
}
var time = this.parent.options.autoPlay;
// default to 3 seconds
time = typeof time == 'number' ? time : 3000;
var _this = this;
// HACK: reset ticks if stopped and started within interval
this.clear();
this.timeout = setTimeout( function() {
_this.parent.next( true );
_this.tick();
}, time );
};
Player.prototype.stop = function() {
this.state = 'stopped';
this.clear();
// remove visibility change event
document.removeEventListener( 'visibilitychange', this.onVisibilityChange );
};
Player.prototype.clear = function() {
clearTimeout( this.timeout );
};
Player.prototype.pause = function() {
if ( this.state == 'playing' ) {
this.state = 'paused';
this.clear();
}
};
Player.prototype.unpause = function() {
// re-start play if paused
if ( this.state == 'paused' ) {
this.play();
}
};
// pause if page visibility is hidden, unpause if visible
Player.prototype.visibilityChange = function() {
var isPageHidden = document.hidden;
this[ isPageHidden ? 'pause' : 'unpause' ]();
};
Player.prototype.visibilityPlay = function() {
this.play();
document.removeEventListener( 'visibilitychange', this.onVisibilityPlay );
};
// -------------------------- Flickity -------------------------- //
utils.extend( Flickity.defaults, {
pauseAutoPlayOnHover: true,
} );
Flickity.createMethods.push('_createPlayer');
var proto = Flickity.prototype;
proto._createPlayer = function() {
this.player = new Player( this );
this.on( 'activate', this.activatePlayer );
this.on( 'uiChange', this.stopPlayer );
this.on( 'pointerDown', this.stopPlayer );
this.on( 'deactivate', this.deactivatePlayer );
};
proto.activatePlayer = function() {
if ( !this.options.autoPlay ) {
return;
}
this.player.play();
this.element.addEventListener( 'mouseenter', this );
};
// Player API, don't hate the ... thanks I know where the door is
proto.playPlayer = function() {
this.player.play();
};
proto.stopPlayer = function() {
this.player.stop();
};
proto.pausePlayer = function() {
this.player.pause();
};
proto.unpausePlayer = function() {
this.player.unpause();
};
proto.deactivatePlayer = function() {
this.player.stop();
this.element.removeEventListener( 'mouseenter', this );
};
// ----- mouseenter/leave ----- //
// pause auto-play on hover
proto.onmouseenter = function() {
if ( !this.options.pauseAutoPlayOnHover ) {
return;
}
this.player.pause();
this.element.addEventListener( 'mouseleave', this );
};
// resume auto-play on hover off
proto.onmouseleave = function() {
this.player.unpause();
this.element.removeEventListener( 'mouseleave', this );
};
// ----- ----- //
Flickity.Player = Player;
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/prev-next-button.js":
/*!******************************************************!*\
!*** ./node_modules/flickity/js/prev-next-button.js ***!
\******************************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// prev/next buttons
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ./flickity */ "./node_modules/flickity/js/flickity.js"),
__webpack_require__(/*! unipointer/unipointer */ "./node_modules/unipointer/unipointer.js"),
__webpack_require__(/*! fizzy-ui-utils/utils */ "./node_modules/fizzy-ui-utils/utils.js"),
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Flickity, Unipointer, utils ) {
return factory( window, Flickity, Unipointer, utils );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Flickity, Unipointer, utils ) {
'use strict';
var svgURI = 'http://www.w3.org/2000/svg';
// -------------------------- PrevNextButton -------------------------- //
function PrevNextButton( direction, parent ) {
this.direction = direction;
this.parent = parent;
this._create();
}
PrevNextButton.prototype = Object.create( Unipointer.prototype );
PrevNextButton.prototype._create = function() {
// properties
this.isEnabled = true;
this.isPrevious = this.direction == -1;
var leftDirection = this.parent.options.rightToLeft ? 1 : -1;
this.isLeft = this.direction == leftDirection;
var element = this.element = document.createElement('button');
element.className = 'flickity-button flickity-prev-next-button';
element.className += this.isPrevious ? ' previous' : ' next';
// prevent button from submitting form http://stackoverflow.com/a/10836076/182183
element.setAttribute( 'type', 'button' );
// init as disabled
this.disable();
element.setAttribute( 'aria-label', this.isPrevious ? 'Previous' : 'Next' );
// create arrow
var svg = this.createSVG();
element.appendChild( svg );
// events
this.parent.on( 'select', this.update.bind( this ) );
this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );
};
PrevNextButton.prototype.activate = function() {
this.bindStartEvent( this.element );
this.element.addEventListener( 'click', this );
// add to DOM
this.parent.element.appendChild( this.element );
};
PrevNextButton.prototype.deactivate = function() {
// remove from DOM
this.parent.element.removeChild( this.element );
// click events
this.unbindStartEvent( this.element );
this.element.removeEventListener( 'click', this );
};
PrevNextButton.prototype.createSVG = function() {
var svg = document.createElementNS( svgURI, 'svg' );
svg.setAttribute( 'class', 'flickity-button-icon' );
svg.setAttribute( 'viewBox', '0 0 100 100' );
var path = document.createElementNS( svgURI, 'path' );
var pathMovements = getArrowMovements( this.parent.options.arrowShape );
path.setAttribute( 'd', pathMovements );
path.setAttribute( 'class', 'arrow' );
// rotate arrow
if ( !this.isLeft ) {
path.setAttribute( 'transform', 'translate(100, 100) rotate(180) ' );
}
svg.appendChild( path );
return svg;
};
// get SVG path movmement
function getArrowMovements( shape ) {
// use shape as movement if string
if ( typeof shape == 'string' ) {
return shape;
}
// create movement string
return 'M ' + shape.x0 + ',50' +
' L ' + shape.x1 + ',' + ( shape.y1 + 50 ) +
' L ' + shape.x2 + ',' + ( shape.y2 + 50 ) +
' L ' + shape.x3 + ',50 ' +
' L ' + shape.x2 + ',' + ( 50 - shape.y2 ) +
' L ' + shape.x1 + ',' + ( 50 - shape.y1 ) +
' Z';
}
PrevNextButton.prototype.handleEvent = utils.handleEvent;
PrevNextButton.prototype.onclick = function() {
if ( !this.isEnabled ) {
return;
}
this.parent.uiChange();
var method = this.isPrevious ? 'previous' : 'next';
this.parent[ method ]();
};
// ----- ----- //
PrevNextButton.prototype.enable = function() {
if ( this.isEnabled ) {
return;
}
this.element.disabled = false;
this.isEnabled = true;
};
PrevNextButton.prototype.disable = function() {
if ( !this.isEnabled ) {
return;
}
this.element.disabled = true;
this.isEnabled = false;
};
PrevNextButton.prototype.update = function() {
// index of first or last slide, if previous or next
var slides = this.parent.slides;
// enable is wrapAround and at least 2 slides
if ( this.parent.options.wrapAround && slides.length > 1 ) {
this.enable();
return;
}
var lastIndex = slides.length ? slides.length - 1 : 0;
var boundIndex = this.isPrevious ? 0 : lastIndex;
var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable';
this[ method ]();
};
PrevNextButton.prototype.destroy = function() {
this.deactivate();
this.allOff();
};
// -------------------------- Flickity prototype -------------------------- //
utils.extend( Flickity.defaults, {
prevNextButtons: true,
arrowShape: {
x0: 10,
x1: 60, y1: 50,
x2: 70, y2: 40,
x3: 30,
},
} );
Flickity.createMethods.push('_createPrevNextButtons');
var proto = Flickity.prototype;
proto._createPrevNextButtons = function() {
if ( !this.options.prevNextButtons ) {
return;
}
this.prevButton = new PrevNextButton( -1, this );
this.nextButton = new PrevNextButton( 1, this );
this.on( 'activate', this.activatePrevNextButtons );
};
proto.activatePrevNextButtons = function() {
this.prevButton.activate();
this.nextButton.activate();
this.on( 'deactivate', this.deactivatePrevNextButtons );
};
proto.deactivatePrevNextButtons = function() {
this.prevButton.deactivate();
this.nextButton.deactivate();
this.off( 'deactivate', this.deactivatePrevNextButtons );
};
// -------------------------- -------------------------- //
Flickity.PrevNextButton = PrevNextButton;
return Flickity;
} ) );
/***/ }),
/***/ "./node_modules/flickity/js/slide.js":
/*!*******************************************!*\
!*** ./node_modules/flickity/js/slide.js ***!
\*******************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// slide
( function( window, factory ) {
// universal module definition
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory() {
'use strict';
function Slide( parent ) {
this.parent = parent;
this.isOriginLeft = parent.originSide == 'left';
this.cells = [];
this.outerWidth = 0;
this.height = 0;
}
var proto = Slide.prototype;
proto.addCell = function( cell ) {
this.cells.push( cell );
this.outerWidth += cell.size.outerWidth;
this.height = Math.max( cell.size.outerHeight, this.height );
// first cell stuff
if ( this.cells.length == 1 ) {
this.x = cell.x; // x comes from first cell
var beginMargin = this.isOriginLeft ? 'marginLeft' : 'marginRight';
this.firstMargin = cell.size[ beginMargin ];
}
};
proto.updateTarget = function() {
var endMargin = this.isOriginLeft ? 'marginRight' : 'marginLeft';
var lastCell = this.getLastCell();
var lastMargin = lastCell ? lastCell.size[ endMargin ] : 0;
var slideWidth = this.outerWidth - ( this.firstMargin + lastMargin );
this.target = this.x + this.firstMargin + slideWidth * this.parent.cellAlign;
};
proto.getLastCell = function() {
return this.cells[ this.cells.length - 1 ];
};
proto.select = function() {
this.cells.forEach( function( cell ) {
cell.select();
} );
};
proto.unselect = function() {
this.cells.forEach( function( cell ) {
cell.unselect();
} );
};
proto.getCellElements = function() {
return this.cells.map( function( cell ) {
return cell.element;
} );
};
return Slide;
} ) );
/***/ }),
/***/ "./node_modules/get-size/get-size.js":
/*!*******************************************!*\
!*** ./node_modules/get-size/get-size.js ***!
\*******************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* getSize v2.0.3
* measure size of elements
* MIT license
*/
/* jshint browser: true, strict: true, undef: true, unused: true */
/* globals console: false */
( function( window, factory ) {
/* jshint strict: false */ /* globals define, module */
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
})( window, function factory() {
'use strict';
// -------------------------- helpers -------------------------- //
// get a number from a string, not a percentage
function getStyleSize( value ) {
var num = parseFloat( value );
// not a percent like '100%', and a number
var isValid = value.indexOf('%') == -1 && !isNaN( num );
return isValid && num;
}
function noop() {}
var logError = typeof console == 'undefined' ? noop :
function( message ) {
console.error( message );
};
// -------------------------- measurements -------------------------- //
var measurements = [
'paddingLeft',
'paddingRight',
'paddingTop',
'paddingBottom',
'marginLeft',
'marginRight',
'marginTop',
'marginBottom',
'borderLeftWidth',
'borderRightWidth',
'borderTopWidth',
'borderBottomWidth'
];
var measurementsLength = measurements.length;
function getZeroSize() {
var size = {
width: 0,
height: 0,
innerWidth: 0,
innerHeight: 0,
outerWidth: 0,
outerHeight: 0
};
for ( var i=0; i < measurementsLength; i++ ) {
var measurement = measurements[i];
size[ measurement ] = 0;
}
return size;
}
// -------------------------- getStyle -------------------------- //
/**
* getStyle, get style of element, check for Firefox bug
* https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
function getStyle( elem ) {
var style = getComputedStyle( elem );
if ( !style ) {
logError( 'Style returned ' + style +
'. Are you running this code in a hidden iframe on Firefox? ' +
'See https://bit.ly/getsizebug1' );
}
return style;
}
// -------------------------- setup -------------------------- //
var isSetup = false;
var isBoxSizeOuter;
/**
* setup
* check isBoxSizerOuter
* do on first getSize() rather than on page load for Firefox bug
*/
function setup() {
// setup once
if ( isSetup ) {
return;
}
isSetup = true;
// -------------------------- box sizing -------------------------- //
/**
* Chrome & Safari measure the outer-width on style.width on border-box elems
* IE11 & Firefox<29 measures the inner-width
*/
var div = document.createElement('div');
div.style.width = '200px';
div.style.padding = '1px 2px 3px 4px';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px 2px 3px 4px';
div.style.boxSizing = 'border-box';
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
// round value for browser zoom. desandro/masonry#928
isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
getSize.isBoxSizeOuter = isBoxSizeOuter;
body.removeChild( div );
}
// -------------------------- getSize -------------------------- //
function getSize( elem ) {
setup();
// use querySeletor if elem is string
if ( typeof elem == 'string' ) {
elem = document.querySelector( elem );
}
// do not proceed on non-objects
if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
return;
}
var style = getStyle( elem );
// if hidden, everything is 0
if ( style.display == 'none' ) {
return getZeroSize();
}
var size = {};
size.width = elem.offsetWidth;
size.height = elem.offsetHeight;
var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
// get all measurements
for ( var i=0; i < measurementsLength; i++ ) {
var measurement = measurements[i];
var value = style[ measurement ];
var num = parseFloat( value );
// any 'auto', 'medium' value will be 0
size[ measurement ] = !isNaN( num ) ? num : 0;
}
var paddingWidth = size.paddingLeft + size.paddingRight;
var paddingHeight = size.paddingTop + size.paddingBottom;
var marginWidth = size.marginLeft + size.marginRight;
var marginHeight = size.marginTop + size.marginBottom;
var borderWidth = size.borderLeftWidth + size.borderRightWidth;
var borderHeight = size.borderTopWidth + size.borderBottomWidth;
var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
// overwrite width and height if we can get it from style
var styleWidth = getStyleSize( style.width );
if ( styleWidth !== false ) {
size.width = styleWidth +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
}
var styleHeight = getStyleSize( style.height );
if ( styleHeight !== false ) {
size.height = styleHeight +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
}
size.innerWidth = size.width - ( paddingWidth + borderWidth );
size.innerHeight = size.height - ( paddingHeight + borderHeight );
size.outerWidth = size.width + marginWidth;
size.outerHeight = size.height + marginHeight;
return size;
}
return getSize;
});
/***/ }),
/***/ "./src/vCarousel.ts":
/*!**************************!*\
!*** ./src/vCarousel.ts ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "vCarousel": () => (/* binding */ vCarousel)
/* harmony export */ });
var errors = __webpack_require__(/*! ./errors.js */ "./src/errors.js");
var vCarousel = (function () {
function vCarousel() {
this._vContainers = [];
this._firstVideoId = undefined;
this._playFirstVideo = false;
this._playNextVideos = false;
this._noStop = false;
this.nbVContainers = 0;
this._currentVideo = undefined;
}
Object.defineProperty(vCarousel.prototype, "vContainers", {
set: function (vContainersIds) {
for (var _i = 0, vContainersIds_1 = vContainersIds; _i < vContainersIds_1.length; _i++) {
var containerId = vContainersIds_1[_i];
var checkContainerExist = document.getElementById(containerId);
if (checkContainerExist === null)
throw new Error(errors.elementNotFound + containerId);
else {
var checkVideoExist = document.querySelector("#" + containerId + " video");
if (checkVideoExist === null)
throw new Error(errors.videoNotFound + containerId);
else
this._vContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist });
}
}
this.nbVContainers = this._vContainers.length;
if (this.nbVContainers < 2)
throw new Error(errors.need2Videos);
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "firstVideoId", {
get: function () {
return this._firstVideoId;
},
set: function (firstVideo) {
if ((firstVideo !== "" && this._vContainers.findIndex(function (video) { return video.id === firstVideo; }) !== -1) || (firstVideo === ""))
this._firstVideoId = firstVideo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "playFirstVideo", {
set: function (playFirstVideo) {
this._playFirstVideo = playFirstVideo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "playNextVideos", {
set: function (playNextVideos) {
this._playNextVideos = playNextVideos;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "noStop", {
set: function (noStop) {
this._noStop = noStop;
},
enumerable: false,
configurable: true
});
Object.defineProperty(vCarousel.prototype, "currentVideo", {
get: function () {
return this._currentVideo;
},
enumerable: false,
configurable: true
});
vCarousel.prototype.run = function () {
var vCarousel = this;
if (vCarousel.nbVContainers < 2)
throw new Error(errors.needVideosProvided);
var _loop_1 = function (i) {
var vContainer = vCarousel._vContainers[i].containerElt;
var video = vCarousel._vContainers[i].videoElt;
if ((vCarousel._firstVideoId !== undefined && vCarousel._vContainers[i].id !== vCarousel._firstVideoId) || (vCarousel._firstVideoId === undefined && i !== 0) || vCarousel._firstVideoId === "")
vContainer.style.display = "none";
else {
if (vCarousel._currentVideo !== undefined && !vCarousel._currentVideo.paused)
vCarousel._currentVideo.pause();
vContainer.style.display = "block";
vCarousel._currentVideo = video;
if (vCarousel._playFirstVideo === true)
video.play();
}
nbTurn = 0;
video.addEventListener("ended", function () {
if (nbTurn < (vCarousel.nbVContainers - 1) || vCarousel._noStop === true) {
vContainer.style.display = "none";
var nextVContainer = void 0, nextVideo = void 0, nextHash = void 0;
if (i < (vCarousel.nbVContainers - 1)) {
nextVContainer = vCarousel._vContainers[i + 1].containerElt;
nextVideo = vCarousel._vContainers[i + 1].videoElt;
nextHash = vCarousel._vContainers[i + 1].id;
}
else {
nextVContainer = vCarousel._vContainers[0].containerElt;
nextVideo = vCarousel._vContainers[0].videoElt;
nextHash = vCarousel._vContainers[0].id;
}
nextVContainer.style.display = "block";
vCarousel._currentVideo = nextVideo;
window.location.assign("#" + nextHash);
if (vCarousel._playNextVideos === true)
nextVideo.play();
nbTurn++;
}
});
};
var nbTurn;
for (var i = 0; i < vCarousel.nbVContainers; i++) {
_loop_1(i);
}
};
return vCarousel;
}());
/***/ }),
/***/ "./node_modules/unidragger/unidragger.js":
/*!***********************************************!*\
!*** ./node_modules/unidragger/unidragger.js ***!
\***********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* Unidragger v2.3.1
* Draggable base class
* MIT license
*/
/*jshint browser: true, unused: true, undef: true, strict: true */
( function( window, factory ) {
// universal module definition
/*jshint strict: false */ /*globals define, module, require */
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! unipointer/unipointer */ "./node_modules/unipointer/unipointer.js")
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( Unipointer ) {
return factory( window, Unipointer );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, Unipointer ) {
'use strict';
// -------------------------- Unidragger -------------------------- //
function Unidragger() {}
// inherit Unipointer & EvEmitter
var proto = Unidragger.prototype = Object.create( Unipointer.prototype );
// ----- bind start ----- //
proto.bindHandles = function() {
this._bindHandles( true );
};
proto.unbindHandles = function() {
this._bindHandles( false );
};
/**
* Add or remove start event
* @param {Boolean} isAdd
*/
proto._bindHandles = function( isAdd ) {
// munge isAdd, default to true
isAdd = isAdd === undefined ? true : isAdd;
// bind each handle
var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';
var touchAction = isAdd ? this._touchActionValue : '';
for ( var i=0; i < this.handles.length; i++ ) {
var handle = this.handles[i];
this._bindStartEvent( handle, isAdd );
handle[ bindMethod ]( 'click', this );
// touch-action: none to override browser touch gestures. metafizzy/flickity#540
if ( window.PointerEvent ) {
handle.style.touchAction = touchAction;
}
}
};
// prototype so it can be overwriteable by Flickity
proto._touchActionValue = 'none';
// ----- start event ----- //
/**
* pointer start
* @param {Event} event
* @param {Event or Touch} pointer
*/
proto.pointerDown = function( event, pointer ) {
var isOkay = this.okayPointerDown( event );
if ( !isOkay ) {
return;
}
// track start event position
// Safari 9 overrides pageX and pageY. These values needs to be copied. flickity#842
this.pointerDownPointer = {
pageX: pointer.pageX,
pageY: pointer.pageY,
};
event.preventDefault();
this.pointerDownBlur();
// bind move and end events
this._bindPostStartEvents( event );
this.emitEvent( 'pointerDown', [ event, pointer ] );
};
// nodes that have text fields
var cursorNodes = {
TEXTAREA: true,
INPUT: true,
SELECT: true,
OPTION: true,
};
// input types that do not have text fields
var clickTypes = {
radio: true,
checkbox: true,
button: true,
submit: true,
image: true,
file: true,
};
// dismiss inputs with text fields. flickity#403, flickity#404
proto.okayPointerDown = function( event ) {
var isCursorNode = cursorNodes[ event.target.nodeName ];
var isClickType = clickTypes[ event.target.type ];
var isOkay = !isCursorNode || isClickType;
if ( !isOkay ) {
this._pointerReset();
}
return isOkay;
};
// kludge to blur previously focused input
proto.pointerDownBlur = function() {
var focused = document.activeElement;
// do not blur body for IE10, metafizzy/flickity#117
var canBlur = focused && focused.blur && focused != document.body;
if ( canBlur ) {
focused.blur();
}
};
// ----- move event ----- //
/**
* drag move
* @param {Event} event
* @param {Event or Touch} pointer
*/
proto.pointerMove = function( event, pointer ) {
var moveVector = this._dragPointerMove( event, pointer );
this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );
this._dragMove( event, pointer, moveVector );
};
// base pointer move logic
proto._dragPointerMove = function( event, pointer ) {
var moveVector = {
x: pointer.pageX - this.pointerDownPointer.pageX,
y: pointer.pageY - this.pointerDownPointer.pageY
};
// start drag if pointer has moved far enough to start drag
if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {
this._dragStart( event, pointer );
}
return moveVector;
};
// condition if pointer has moved far enough to start drag
proto.hasDragStarted = function( moveVector ) {
return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;
};
// ----- end event ----- //
/**
* pointer up
* @param {Event} event
* @param {Event or Touch} pointer
*/
proto.pointerUp = function( event, pointer ) {
this.emitEvent( 'pointerUp', [ event, pointer ] );
this._dragPointerUp( event, pointer );
};
proto._dragPointerUp = function( event, pointer ) {
if ( this.isDragging ) {
this._dragEnd( event, pointer );
} else {
// pointer didn't move enough for drag to start
this._staticClick( event, pointer );
}
};
// -------------------------- drag -------------------------- //
// dragStart
proto._dragStart = function( event, pointer ) {
this.isDragging = true;
// prevent clicks
this.isPreventingClicks = true;
this.dragStart( event, pointer );
};
proto.dragStart = function( event, pointer ) {
this.emitEvent( 'dragStart', [ event, pointer ] );
};
// dragMove
proto._dragMove = function( event, pointer, moveVector ) {
// do not drag if not dragging yet
if ( !this.isDragging ) {
return;
}
this.dragMove( event, pointer, moveVector );
};
proto.dragMove = function( event, pointer, moveVector ) {
event.preventDefault();
this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );
};
// dragEnd
proto._dragEnd = function( event, pointer ) {
// set flags
this.isDragging = false;
// re-enable clicking async
setTimeout( function() {
delete this.isPreventingClicks;
}.bind( this ) );
this.dragEnd( event, pointer );
};
proto.dragEnd = function( event, pointer ) {
this.emitEvent( 'dragEnd', [ event, pointer ] );
};
// ----- onclick ----- //
// handle all clicks and prevent clicks when dragging
proto.onclick = function( event ) {
if ( this.isPreventingClicks ) {
event.preventDefault();
}
};
// ----- staticClick ----- //
// triggered after pointer down & up with no/tiny movement
proto._staticClick = function( event, pointer ) {
// ignore emulated mouse up clicks
if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {
return;
}
this.staticClick( event, pointer );
// set flag for emulated clicks 300ms after touchend
if ( event.type != 'mouseup' ) {
this.isIgnoringMouseUp = true;
// reset flag after 300ms
setTimeout( function() {
delete this.isIgnoringMouseUp;
}.bind( this ), 400 );
}
};
proto.staticClick = function( event, pointer ) {
this.emitEvent( 'staticClick', [ event, pointer ] );
};
// ----- utils ----- //
Unidragger.getPointerPoint = Unipointer.getPointerPoint;
// ----- ----- //
return Unidragger;
}));
/***/ }),
/***/ "./node_modules/unipointer/unipointer.js":
/*!***********************************************!*\
!*** ./node_modules/unipointer/unipointer.js ***!
\***********************************************/
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* Unipointer v2.3.0
* base class for doing one thing with pointer event
* MIT license
*/
/*jshint browser: true, undef: true, unused: true, strict: true */
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*global define, module, require */
if ( true ) {
// AMD
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [
__webpack_require__(/*! ev-emitter/ev-emitter */ "./node_modules/ev-emitter/ev-emitter.js")
], __WEBPACK_AMD_DEFINE_RESULT__ = (function( EvEmitter ) {
return factory( window, EvEmitter );
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}( window, function factory( window, EvEmitter ) {
'use strict';
function noop() {}
function Unipointer() {}
// inherit EvEmitter
var proto = Unipointer.prototype = Object.create( EvEmitter.prototype );
proto.bindStartEvent = function( elem ) {
this._bindStartEvent( elem, true );
};
proto.unbindStartEvent = function( elem ) {
this._bindStartEvent( elem, false );
};
/**
* Add or remove start event
* @param {Boolean} isAdd - remove if falsey
*/
proto._bindStartEvent = function( elem, isAdd ) {
// munge isAdd, default to true
isAdd = isAdd === undefined ? true : isAdd;
var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';
// default to mouse events
var startEvent = 'mousedown';
if ( window.PointerEvent ) {
// Pointer Events
startEvent = 'pointerdown';
} else if ( 'ontouchstart' in window ) {
// Touch Events. iOS Safari
startEvent = 'touchstart';
}
elem[ bindMethod ]( startEvent, this );
};
// trigger handler methods for events
proto.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
// returns the touch that we're keeping track of
proto.getTouch = function( touches ) {
for ( var i=0; i < touches.length; i++ ) {
var touch = touches[i];
if ( touch.identifier == this.pointerIdentifier ) {
return touch;
}
}
};
// ----- start event ----- //
proto.onmousedown = function( event ) {
// dismiss clicks from right or middle buttons
var button = event.button;
if ( button && ( button !== 0 && button !== 1 ) ) {
return;
}
this._pointerDown( event, event );
};
proto.ontouchstart = function( event ) {
this._pointerDown( event, event.changedTouches[0] );
};
proto.onpointerdown = function( event ) {
this._pointerDown( event, event );
};
/**
* pointer start
* @param {Event} event
* @param {Event or Touch} pointer
*/
proto._pointerDown = function( event, pointer ) {
// dismiss right click and other pointers
// button = 0 is okay, 1-4 not
if ( event.button || this.isPointerDown ) {
return;
}
this.isPointerDown = true;
// save pointer identifier to match up touch events
this.pointerIdentifier = pointer.pointerId !== undefined ?
// pointerId for pointer events, touch.indentifier for touch events
pointer.pointerId : pointer.identifier;
this.pointerDown( event, pointer );
};
proto.pointerDown = function( event, pointer ) {
this._bindPostStartEvents( event );
this.emitEvent( 'pointerDown', [ event, pointer ] );
};
// hash of events to be bound after start event
var postStartEvents = {
mousedown: [ 'mousemove', 'mouseup' ],
touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],
pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],
};
proto._bindPostStartEvents = function( event ) {
if ( !event ) {
return;
}
// get proper events to match start event
var events = postStartEvents[ event.type ];
// bind events to node
events.forEach( function( eventName ) {
window.addEventListener( eventName, this );
}, this );
// save these arguments
this._boundPointerEvents = events;
};
proto._unbindPostStartEvents = function() {
// check for _boundEvents, in case dragEnd triggered twice (old IE8 bug)
if ( !this._boundPointerEvents ) {
return;
}
this._boundPointerEvents.forEach( function( eventName ) {
window.removeEventListener( eventName, this );
}, this );
delete this._boundPointerEvents;
};
// ----- move event ----- //
proto.onmousemove = function( event ) {
this._pointerMove( event, event );
};
proto.onpointermove = function( event ) {
if ( event.pointerId == this.pointerIdentifier ) {
this._pointerMove( event, event );
}
};
proto.ontouchmove = function( event ) {
var touch = this.getTouch( event.changedTouches );
if ( touch ) {
this._pointerMove( event, touch );
}
};
/**
* pointer move
* @param {Event} event
* @param {Event or Touch} pointer
* @private
*/
proto._pointerMove = function( event, pointer ) {
this.pointerMove( event, pointer );
};
// public
proto.pointerMove = function( event, pointer ) {
this.emitEvent( 'pointerMove', [ event, pointer ] );
};
// ----- end event ----- //
proto.onmouseup = function( event ) {
this._pointerUp( event, event );
};
proto.onpointerup = function( event ) {
if ( event.pointerId == this.pointerIdentifier ) {
this._pointerUp( event, event );
}
};
proto.ontouchend = function( event ) {
var touch = this.getTouch( event.changedTouches );
if ( touch ) {
this._pointerUp( event, touch );
}
};
/**
* pointer up
* @param {Event} event
* @param {Event or Touch} pointer
* @private
*/
proto._pointerUp = function( event, pointer ) {
this._pointerDone();
this.pointerUp( event, pointer );
};
// public
proto.pointerUp = function( event, pointer ) {
this.emitEvent( 'pointerUp', [ event, pointer ] );
};
// ----- pointer done ----- //
// triggered on pointer up & pointer cancel
proto._pointerDone = function() {
this._pointerReset();
this._unbindPostStartEvents();
this.pointerDone();
};
proto._pointerReset = function() {
// reset properties
this.isPointerDown = false;
delete this.pointerIdentifier;
};
proto.pointerDone = noop;
// ----- pointer cancel ----- //
proto.onpointercancel = function( event ) {
if ( event.pointerId == this.pointerIdentifier ) {
this._pointerCancel( event, event );
}
};
proto.ontouchcancel = function( event ) {
var touch = this.getTouch( event.changedTouches );
if ( touch ) {
this._pointerCancel( event, touch );
}
};
/**
* pointer cancel
* @param {Event} event
* @param {Event or Touch} pointer
* @private
*/
proto._pointerCancel = function( event, pointer ) {
this._pointerDone();
this.pointerCancel( event, pointer );
};
// public
proto.pointerCancel = function( event, pointer ) {
this.emitEvent( 'pointerCancel', [ event, pointer ] );
};
// ----- ----- //
// utility function for getting x/y coords from event
Unipointer.getPointerPoint = function( pointer ) {
return {
x: pointer.pageX,
y: pointer.pageY
};
};
// ----- ----- //
return Unipointer;
}));
/***/ }),
/***/ "./src/errors.js":
/*!***********************!*\
!*** ./src/errors.js ***!
\***********************/
/***/ ((module) => {
module.exports =
{
elementNotFound : "Aucun élément HTML trouvé dans la page pour l'id : ",
videoNotFound: "Aucune balise vidéo trouvée dans l'élément HTML ayant comme id : ",
need2Videos: "Il vous faut fournir au moins deux conteneurs de vidéo valides pour pouvoir lancer le carrousel.",
needVideosProvided: "vCarousel ne peut être lancé sans avoir fourni les vidéos concernées."
};
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!********************************!*\
!*** ./src/exampleFlickity.ts ***!
\********************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _vCarousel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vCarousel */ "./src/vCarousel.ts");
var Flickity = __webpack_require__(/*! flickity */ "./node_modules/flickity/js/index.js");
var selectFlickityForHash = function (flickityCarousel, urlHash) {
var nb = 0, find = false;
for (var _i = 0, _a = flickityCarousel.cells; _i < _a.length; _i++) {
var cel = _a[_i];
var childrens = cel.element.childNodes;
for (var i = 0, c = childrens.length; i < c; i++) {
if (childrens[i].nodeType === Node.ELEMENT_NODE) {
if (childrens[i].hash != undefined && childrens[i].hash === urlHash) {
flickityCarousel.select(nb);
find = true;
break;
}
}
}
nb++;
}
if (find === false)
console.error("L'ancre fournie par l'url n'a pas été trouvée dans le carrousel Flickity.");
};
try {
var imgCarousel = document.querySelector(".img-carousel");
var flktyCarousel_1 = new Flickity(imgCarousel, {
accessibility: true,
cellAlign: "center",
contain: true,
rightToLeft: true,
wrapAround: true,
});
var videosContainers = ["vFunanbule", "vForgeron", "vCircuit"];
var testvCarousel_1 = new _vCarousel__WEBPACK_IMPORTED_MODULE_0__.vCarousel();
testvCarousel_1.vContainers = videosContainers;
if (window.location.hash !== undefined && window.location.hash !== "") {
testvCarousel_1.firstVideoId = window.location.hash.replace("#", "");
selectFlickityForHash(flktyCarousel_1, location.hash);
}
else
testvCarousel_1.firstVideoId = "";
testvCarousel_1.run();
var selectLinks = document.querySelectorAll(".selectVideo");
var _loop_1 = function (i) {
var link = selectLinks[i];
link.addEventListener("click", function (e) {
testvCarousel_1.firstVideoId = link.hash.replace("#", "");
testvCarousel_1.playFirstVideo = true;
testvCarousel_1.playNextVideos = true;
testvCarousel_1.run();
});
};
for (var i = 0; i < selectLinks.length; i++) {
_loop_1(i);
}
window.addEventListener('hashchange', function () {
selectFlickityForHash(flktyCarousel_1, location.hash);
});
}
catch (e) {
console.error(e);
}
})();
/******/ })()
;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9KUy9leGFtcGx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leHRWaWRlb3MgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fbm9TdG9wID0gZmFsc2U7XG4gICAgICAgIHRoaXMubmJWQ29udGFpbmVycyA9IDA7XG4gICAgICAgIHRoaXMuX2N1cnJlbnRWaWRlbyA9IHVuZGVmaW5lZDtcbiAgICB9XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHZDYXJvdXNlbC5wcm90b3R5cGUsIFwidkNvbnRhaW5lcnNcIiwge1xuICAgICAgICBzZXQ6IGZ1bmN0aW9uICh2Q29udGFpbmVyc0lkcykge1xuICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwLCB2Q29udGFpbmVyc0lkc18xID0gdkNvbnRhaW5lcnNJZHM7IF9pIDwgdkNvbnRhaW5lcnNJZHNfMS5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgY29udGFpbmVySWQgPSB2Q29udGFpbmVyc0lkc18xW19pXTtcbiAgICAgICAgICAgICAgICB2YXIgY2hlY2tDb250YWluZXJFeGlzdCA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKGNvbnRhaW5lcklkKTtcbiAgICAgICAgICAgICAgICBpZiAoY2hlY2tDb250YWluZXJFeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5lbGVtZW50Tm90Rm91bmQgKyBjb250YWluZXJJZCk7XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBjaGVja1ZpZGVvRXhpc3QgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKFwiI1wiICsgY29udGFpbmVySWQgKyBcIiB2aWRlb1wiKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoZWNrVmlkZW9FeGlzdCA9PT0gbnVsbClcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMudmlkZW9Ob3RGb3VuZCArIGNvb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dXJyZW50VmlkZW8ucGF1c2VkKVxuICAgICAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlby5wYXVzZSgpO1xuICAgICAgICAgICAgICAgIHZDb250YWluZXIuc3R5bGUuZGlzcGxheSA9IFwiYmxvY2tcIjtcbiAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlbyA9IHZpZGVvO1xuICAgICAgICAgICAgICAgIGlmICh2Q2Fyb3VzZWwuX3BsYXlGaXJzdFZpZGVvID09PSB0cnVlKVxuICAgICAgICAgICAgICAgICAgICB2aWRlby5wbGF5KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuYlR1cm4gPSAwO1xuICAgICAgICAgICAgdmlkZW8uYWRkRXZlbnRMaXN0ZW5lcihcImVuZGVkXCIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAobmJUdXJuIDwgKHZDYXJvdXNlbC5uYlZDb250YWluZXJzIC0gMSkgfHwgdkNhcm91c2VsLl9ub1N0b3AgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJub25lXCI7XG4gICAgICAgICAgICAgICAgICAgIHZhciBuZXh0VkNvbnRhaW5lciA9IHZvaWQgMCwgbmV4dFZpZGVvID0gdm9pZCAwLCBuZXh0SGFzaCA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCAodkNhcm91c2VsLm5iVkNvbnRhaW5lcnMgLSAxKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZDb250YWluZXIgPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS5jb250YWluZXJFbHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VmlkZW8gPSB2Q2Fyb3VzZWwuX3ZDb250YWluZXJzW2kgKyAxXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1tpICsgMV0uaWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lciA9IHZDYXJvdXNlbC5fdkNvbnRhaW5lcnNbMF0uY29udGFpbmVyRWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFZpZGVvID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS52aWRlb0VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRIYXNoID0gdkNhcm91c2VsLl92Q29udGFpbmVyc1swXS5pZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBuZXh0VkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gXCJibG9ja1wiO1xuICAgICAgICAgICAgICAgICAgICB2Q2Fyb3VzZWwuX2N1cnJlbnRWaWRlbyA9IG5leHRWaWRlbztcbiAgICAgICAgICAgICAgICAgICAgd2luZG93LmxvY2F0aW9uLmFzc2lnbihcIiNcIiArIG5leHRIYXNoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZDYXJvdXNlbC5fcGxheU5leHRWaWRlb3MgPT09IHRydWUpXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0VmlkZW8ucGxheSgpO1xuICAgICAgICAgICAgICAgICAgICBuYlR1cm4rKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIG5iVHVybjtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB2Q2Fyb3VzZWwubmJWQ29udGFpbmVyczsgaSsrKSB7XG4gICAgICAgICAgICBfbG9vcF8xKGkpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4gdkNhcm91c2VsO1xufSgpKTtcbmV4cG9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