{"version":3,"file":"flicking.min.js","sources":["../src/browser.js","../src/utils.js","../src/consts.js","../src/config.js","../src/eventHandler.js","../src/Flicking.js"],"sourcesContent":["/**\n * Copyright (c) 2015 NAVER Corp.\n * egjs projects are licensed under the MIT license\n */\n/* eslint-disable no-new-func, no-nested-ternary */\n\nlet win;\n\nif (typeof window === \"undefined\") {\n\t// window is undefined in node.js\n\twin = {\n\t\tdocument: {},\n\t\tnavigator: {\n\t\t\tuserAgent: \"\"\n\t\t}\n\t};\n} else {\n\twin = window;\n}\n/* eslint-enable no-new-func, no-nested-ternary */\n\nconst document = win.document;\n\nexport {\n\twin as window,\n\tdocument\n};\n","/**\n * Copyright (c) 2015 NAVER Corp.\n * egjs projects are licensed under the MIT license\n */\nimport {window, document} from \"./browser\";\n\nconst utils = {\n\t/**\n\t * Select or create element\n\t * @param {String|HTMLElement} param\n\t * when string given is as HTML tag, then create element\n\t * otherwise it returns selected elements\n\t * @returns {HTMLElement}\n\t */\n\t$(param) {\n\t\tlet el = null;\n\n\t\tif (typeof param === \"string\") {\n\t\t\t// check if string is HTML tag format\n\t\t\tconst match = param.match(/^<([a-z]+)\\s*([^>]*)>/);\n\n\t\t\t// creating element\n\t\t\tif (match) {\n\t\t\t\tel = document.createElement(match[1]);\n\n\t\t\t\t// attributes\n\t\t\t\tmatch.length === 3 &&\n\t\t\t\t\tmatch[2].split(\" \").forEach(v => {\n\t\t\t\t\t\tconst attr = v.split(\"=\");\n\n\t\t\t\t\t\tel.setAttribute(attr[0], attr[1].trim().replace(/(^[\"']|[\"']$)/g, \"\"));\n\t\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tel = document.querySelectorAll(param);\n\n\t\t\t\tif (!el.length) {\n\t\t\t\t\tel = null;\n\t\t\t\t} else if (el.length === 1) {\n\t\t\t\t\tel = el[0];\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (param.nodeName && param.nodeType === 1) {\n\t\t\tel = param;\n\t\t}\n\n\t\treturn el;\n\t},\n\n\t/**\n\t * Converts to array\n\t * @param {HTMLCollection|HTMLElement} el\n\t * @returns {Array}\n\t */\n\ttoArray(el) {\n\t\treturn [].slice.call(el);\n\t},\n\n\t/**\n\t * Check if is array\n\t * @param arr\n\t * @returns {Boolean}\n\t */\n\tisArray(arr) {\n\t\treturn arr && arr.constructor === Array;\n\t},\n\n\t/**\n\t * Check if is object\n\t * @param {Object} obj\n\t * @returns {Boolean}\n\t */\n\tisObject(obj) {\n\t\treturn obj && !obj.nodeType && typeof obj === \"object\" && !this.isArray(obj);\n\t},\n\n\t/**\n\t * Merge object returning new object\n\t * @param {Object} target\n\t * @param {Object} objectN\n\t * @returns {Object} merged target object\n\t * @example\n\t * var target = { a: 1 };\n\t * utils.extend(target, { b: 2, c: 3 });\n\t * target; // { a: 1, b: 2, c: 3 };\n\t */\n\textend(target, ...objectN) {\n\t\tif (!objectN.length || (objectN.length === 1 && !objectN[0])) {\n\t\t\treturn target;\n\t\t}\n\n\t\tconst source = objectN.shift();\n\n\t\tif (this.isObject(target) && this.isObject(source)) {\n\t\t\tObject.keys(source).forEach(key => {\n\t\t\t\tconst value = source[key];\n\n\t\t\t\tif (this.isObject(value)) {\n\t\t\t\t\t!target[key] && (target[key] = {});\n\n\t\t\t\t\ttarget[key] = this.extend(target[key], value);\n\t\t\t\t} else {\n\t\t\t\t\ttarget[key] = this.isArray(value) ?\n\t\t\t\t\t\tvalue.concat() : value;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn this.extend(target, ...objectN);\n\t},\n\n\t/**\n\t * Get or set the style value or apply\n\t * @param {HTMLElement|Array} el\n\t * @param {String|Object} style\n\t * String: return style property value\n\t * Object: set style value\n\t * @param {Boolean} getAsNumber Get the value as number\n\t * @returns {String|HTMLElement}\n\t */\n\tcss(el, style, getAsNumber) {\n\t\tif (typeof(style) === \"string\") {\n\t\t\tlet value = el.style[style];\n\n\t\t\tif (!value || value === \"auto\" || (/\\d/.test(value) && !/\\d(px)?$/.test(value))) {\n\t\t\t\tvalue = window.getComputedStyle(el)[style];\n\t\t\t}\n\n\t\t\treturn getAsNumber ? this.getNumValue(value) : value;\n\t\t} else {\n\t\t\tconst applyStyle = (target, source) =>\n\t\t\t\tObject.keys(source).forEach(v => {\n\t\t\t\t\ttarget[v] = source[v];\n\t\t\t\t});\n\n\t\t\tthis.isArray(el) ?\n\t\t\t\tel.forEach(v => applyStyle(v.style, style)) :\n\t\t\t\tapplyStyle(el.style, style);\n\t\t}\n\n\t\treturn el;\n\t},\n\n\t/**\n\t * classList\n\t * @param {HTMLElement} el target DOM element\n\t * @param {String} className class name string to be handled\n\t * @param {Boolean} add Add or remove class - true: Add, false: Remove\n\t * @return {Boolean} if add param is missing, then return existence of class name\n\t */\n\tclassList(el, className, add) {\n\t\tconst isAddParam = typeof add === \"boolean\";\n\t\tlet res;\n\n\t\tif (el.classList) {\n\t\t\tres = el.classList[\n\t\t\t\t(isAddParam && (add ? \"add\" : \"remove\")) || \"contains\"\n\t\t\t](className);\n\t\t} else {\n\t\t\tres = el.className;\n\n\t\t\tif (isAddParam) {\n\t\t\t\tif (add && res.indexOf(className) === -1) {\n\t\t\t\t\tres = el.className = (`${res} ${className}`).replace(/\\s{2,}/g, \" \");\n\t\t\t\t} else if (!add) {\n\t\t\t\t\tres = el.className = res.replace(className, \"\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tres = new RegExp(`\\\\b${className}\\\\b`).test(res);\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t},\n\n\t/**\n\t * Check and parse value to number\n\t * @param {Number|String} val\n\t * @param {Number} defVal\n\t * @return {Number}\n\t */\n\tgetNumValue(val, defVal) {\n\t\tlet num = val;\n\n\t\treturn isNaN(num = parseFloat(num)) ? defVal : num;\n\t},\n\n\t/**\n\t * Return unit formatted value\n\t * @param {Number|String} val\n\t * @return {String} val Value formatted with unit\n\t */\n\tgetUnitValue(val) {\n\t\tconst rx = /(?:[a-z]{2,}|%)$/;\n\n\t\treturn (parseFloat(val) || 0) + (String(val).match(rx) || \"px\");\n\t},\n\n\t/**\n\t * Get element's outer value\n\t * @param {HTMLElement} el\n\t * @param {String} type - [outerWidth|outerHeight]\n\t * @returns {Number} outer's value\n\t */\n\tgetOuter(el, type) {\n\t\tlet paddingMargin = 0;\n\n\t\t(type === \"outerWidth\" ?\n\t\t\t[\"Left\", \"Right\"] :\n\t\t\t[\"Top\", \"Bottom\"]\n\t\t).forEach(dir => {\n\t\t\t[\"padding\", \"margin\"].forEach(v => {\n\t\t\t\tpaddingMargin += this.css(el, `${v}${dir}`, true);\n\t\t\t});\n\t\t});\n\n\t\treturn this.css(el, type.replace(\"outer\", \"\").toLocaleLowerCase(), true) + paddingMargin;\n\t},\n\n\t/**\n\t * Get element's outerWidth value with margin\n\t * @param {HTMLElement} el\n\t * @returns {Number}\n\t */\n\touterWidth(el) {\n\t\treturn this.getOuter(el, \"outerWidth\");\n\t},\n\n\t/**\n\t * Get element's outerHeight value with margin\n\t * @param {HTMLElement} el\n\t * @returns {Number}\n\t */\n\touterHeight(el) {\n\t\treturn this.getOuter(el, \"outerHeight\");\n\t},\n\n\t/**\n\t * Returns the syntax of the translate style which is applied to CSS transition properties.\n\t *\n\t * @ko CSS 트랜지션 속성에 적용할 translate 스타일 구문을 반환한다\n\t * @method eg#translate\n\t * @param {String} x Distance to move along the X axis
1. When the user is inputing the move.
2. When moving to the destination panel after you have finished inputing the move in step 1.
3. When the current panel is moving to its original position after the movement is finished in step 1.
4. Moving to the destination panel by calling the `moveTo()`, `prev()`, `next()` method. (Do not prevent the default behavior of the [beforeFlickStart]{@link eg.Flicking#event:beforeFlickStart} event.)\n\t\t * @ko 패널의 좌표값이 변할 때마다 발생하는 이벤트. 아래의 경우에 발생한다.
1. 사용자가 이동(move) 액션 입력중일 때.
2. 1번에서 이동(move) 액션 입력이 끝나고 목적 패널로 이동중일 때.
3. 1번에서 이동(move) 액션 입력이 끝나고 현재 패널의 원래 위치로 이동중일 때.
4. `moveTo()`, `prev()`, `next()`, 메서드를 호출하여 목적 패널로 이동중일 때. ([beforeFlickStart]{@link eg.Flicking#event:beforeFlickStart}이벤트의 기본동작을 막지 않아야 한다.)
5. `restore()` 메서드를 호출하여 현재 패널이 원래 위치로 이동중일 때. ([beforeFlickStart]{@link eg.Flicking#event:beforeFlickStart}이벤트의 기본동작 방지 전제.)\n\t\t * @name eg.Flicking#flick\n\t\t * @event\n\t\t * @property {String} eventType The name of the event
panel 0
panel 1
panel 2
panel 0
panel 1
panel 2
panel 0
panel 1
panel 2
panel 0
panel 0
panel 1
panel 2
panel 3
panel 0
panel 1