@egjs/flicking
Advanced tools
Comparing version 2.0.0-rc.2 to 2.0.0
/*! | ||
* Copyright (c) 2017 NAVER Corp. | ||
* @egjs/flicking projects are licensed under the MIT <https://naver.github.io/egjs/license.txt> license | ||
* @egjs/flicking project is licensed under the MIT <https://naver.github.io/egjs/license.txt> license | ||
* | ||
@@ -8,5 +8,5 @@ * @egjs/flicking JavaScript library | ||
* | ||
* @version 2.0.0-rc.2 | ||
* @version 2.0.0 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@egjs/component"),require("@egjs/movablecoord")):"function"==typeof define&&define.amd?define(["@egjs/component","@egjs/movablecoord"],e):"object"==typeof exports?exports.Flicking=e(require("@egjs/component"),require("@egjs/movablecoord")):(t.eg=t.eg||{},t.eg.Flicking=e(t.eg.Component,t.eg.MovableCoord))}(this,function(t,e){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),o=i.document;e.window=i,e.document=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DATA_HEIGHT=e.IS_ANDROID2=e.SUPPORT_WILLCHANGE=e.SUPPORT_TRANSFORM=e.EVENTS=void 0;var i=n(0),o={beforeFlickStart:"beforeFlickStart",beforeRestore:"beforeRestore",flick:"flick",flickEnd:"flickEnd",restore:"restore"},r=function(){var t=i.document.documentElement.style;return"transform"in t||"webkitTransform"in t}(),s=i.window.CSS&&i.window.CSS.supports&&i.window.CSS.supports("will-change","transform"),a=/Android 2\./.test(navigator.userAgent);e.EVENTS=o,e.SUPPORT_TRANSFORM=r,e.SUPPORT_WILLCHANGE=s,e.IS_ANDROID2=a,e.DATA_HEIGHT="data-height"},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=n(7),l=i(a),u=n(8),c=i(u),h=n(6),p=n(1),d=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(p),f=n(3),_=n(0),g=n(4),v=i(g),y=function(t){function e(n,i,s){o(this,e);var a=r(this,t.call(this));a.$wrapper=h.utils.$(n);var l=a.$wrapper&&a.$wrapper.children;if(!a.$wrapper||!l||!l.length)throw new Error("Given base element doesn't exist or it hasn't proper DOM structure to be initialized.");return a._setOptions(i),a._setConfig(l,s),!h.utils.hasClickBug()&&(a._setPointerEvents=function(){}),a._build(),a._bindEvents(!0),a._applyPanelsCss(),a._arrangePanels(),a.options.hwAccelerable&&d.SUPPORT_WILLCHANGE&&a._setHint(),a.options.adaptiveHeight&&a._setAdaptiveHeight(),a._adjustContainerCss("end"),a}return s(e,t),e.prototype._setOptions=function(t){var e={previewPadding:[0,0],bounce:[10,10]};this.options=h.utils.extend(h.utils.extend({},f.OPTIONS),e,t);for(var n in e){var i=this.options[n];"number"==typeof i?i=[i,i]:h.utils.isArray(i)||(i=e[n]),this.options[n]=i}},e.prototype._setConfig=function(t,e){var n=this.options,i=n.previewPadding,o=t;o[0].classList.contains(n.prefix+"-container")&&(o=o[0],this.$container=o,o=o.children),o=[].slice.call(o);var r=this._conf=h.utils.extend(h.utils.extend({},f.CONFIG),{panel:{$list:o,minCount:i[0]+i[1]>0?5:3},origPanelStyle:{wrapper:{className:this.$wrapper.getAttribute("class")||null,style:this.$wrapper.getAttribute("style")||null},container:{className:this.$container&&this.$container.getAttribute("class")||null,style:this.$container&&this.$container.getAttribute("style")||null},list:o.map(function(t){return{className:t.getAttribute("class")||null,style:t.getAttribute("style")||null}})},useLayerHack:n.hwAccelerable&&!d.SUPPORT_WILLCHANGE,eventPrefix:e||""});[["LEFT","RIGHT"],["UP","DOWN"]][+!n.horizontal].forEach(function(t){return r.dirData.push(c.default["DIRECTION_"+t])})},e.prototype._build=function(){var t=this._conf.panel,e=this.options,n=t.$list,i=e.previewPadding.concat(),o=e.prefix,r=e.horizontal,s=t.count=t.origCount=n.length,a=e.bounce;this._setPadding(i,!0);var l=this._getDataByDirection([t.size,"100%"]),u={position:"relative",zIndex:2e3,width:"100%",height:"100%"};if(r&&(u.top="0px"),this.$container)h.utils.css(this.$container,u);else{var p=n[0].parentNode,d=_.document.createElement("div");d.className=o+"-container",h.utils.css(d,u),n.forEach(function(t){return d.appendChild(t)}),p.appendChild(d),this.$container=d}n.forEach(function(t){t.classList.add(o+"-panel"),h.utils.css(t,{position:"absolute",width:h.utils.getUnitValue(l[0]),height:h.utils.getUnitValue(l[1]),boxSizing:"border-box",top:0,left:0})}),this._addClonePanels()&&(s=t.count=(t.$list=[].slice.call(this.$container.children)).length),this._mcInst=new c.default({min:[0,0],max:this._getDataByDirection([t.size*(s-1),0]),margin:0,circular:!1,easing:e.panelEffect,deceleration:e.deceleration,bounce:this._getDataByDirection([0,a[1],0,a[0]])}),this._setDefaultPanel(e.defaultIndex)},e.prototype._setPadding=function(t,e){var n=this.options.horizontal,i=this._conf.panel,o=t[0]+t[1],r={};!o&&e||(r.padding=n?"0 "+t.reverse().join("px 0 ")+"px":t.join("px 0 ")+"px"),e&&(r.overflow="hidden",r.boxSizing="border-box"),Object.keys(r).length&&h.utils.css(this.$wrapper,r);var s=getComputedStyle(this.$wrapper),a=n?["Left","Right"]:["Top","Bottom"];i.size=h.utils.getNumValue(s[n?"width":"height"])-(h.utils.getNumValue(s["padding"+a[0]])+h.utils.getNumValue(s["padding"+a[1]]))},e.prototype._addClonePanels=function(){var t=this,e=this._conf.panel,n=e.origCount,i=e.minCount-n,o=e.$list,r=void 0;if(this.options.circular&&n<e.minCount){for(r=o.map(function(t){return t.cloneNode(!0)});r.length<i;)r=r.concat(o.map(function(t){return t.cloneNode(!0)}));return r.forEach(function(e){return t.$container.appendChild(e)}),!!r.length}return!1},e.prototype._movePanelPosition=function(t,e){var n=this._conf.panel,i=n.$list,o=i.splice(e?0:n.count-t,t);n.$list=e?i.concat(o):o.concat(i)},e.prototype._setDefaultPanel=function(t){var e=this._conf.panel,n=e.count-1,i=void 0,o=void 0;this.options.circular?(t>0&&t<=n&&this._movePanelPosition(t,!0),o=this._getBasePositionIndex(),this._movePanelPosition(o,!1),this._setPanelNo({no:t,currNo:t})):t>0&&t<=n&&(this._setPanelNo({index:t,no:t,currIndex:t,currNo:t}),i=[-e.size*t,0],this._setTranslate(i),this._setMovableCoord("setTo",[Math.abs(i[0]),Math.abs(i[1])],!0,0))},e.prototype._arrangePanels=function(t,e){var n=this._conf,i=n.panel,o=n.touch,r=n.dirData,s=void 0;this.options.circular&&(n.customEvent.flick=!1,t&&(e&&(o.direction=r[+!(e>0)]),this._arrangePanelPosition(o.direction,e)),s=this._getBasePositionIndex(),this._setPanelNo({index:s,currIndex:s}),n.customEvent.flick=!!this._setMovableCoord("setTo",[i.size*i.index,0],!0,0)),this._applyPanelsPos()},e.prototype._applyPanelsPos=function(){this._conf.panel.$list.forEach(this._applyPanelsCss.bind(this))},e.prototype._setMoveStyle=function(t,e){this._setMoveStyle=d.SUPPORT_TRANSFORM?function(t,e){h.utils.css(t,{transform:h.utils.translate(e[0],e[1],this._conf.useLayerHack)})}:function(t,e){h.utils.css(t,{left:e[0],top:e[1]})},this._setMoveStyle(t,e)},e.prototype._applyPanelsCss=function(){var t=this._conf;d.IS_ANDROID2?(t.$dummyAnchor=h.utils.$(".__dummy_anchor"),!t.$dummyAnchor&&this.$wrapper.appendChild(t.$dummyAnchor=h.utils.$('<a href="javascript:void(0)" class="__dummy_anchor" style="position:absolute;height:0px;width:0px">')),this._applyPanelsCss=function(t,e){var n=this._getDataByDirection([this._conf.panel.size*e+"px",0]);h.utils.css(t,{left:n[0],top:n[1]})}):this._applyPanelsCss=function(t,e){var n=this._getDataByDirection([d.SUPPORT_TRANSFORM?100*e+"%":this._conf.panel.size*e+"px",0]);this._setMoveStyle(t,n)}},e.prototype._adjustContainerCss=function(t,e){var n=this._conf,i=n.panel,o=this.options,r=o.horizontal,s=o.previewPadding[0],a=this.$container,l=e,u=void 0;d.IS_ANDROID2&&(l||(l=[-i.size*i.index,0]),"start"===t?(a=a.style,u=parseInt(a[r?"left":"top"],10),r?u&&(a.left="0px"):u!==s&&(a.top="0px"),this._setTranslate([-l[+!o.horizontal],0])):"end"===t&&(l=this._getCoordsValue(l),h.utils.css(a,{left:l.x,top:l.y,transform:h.utils.translate(0,0,n.useLayerHack)}),n.$dummyAnchor.focus()))},e.prototype._setMovableCoord=function(t,e,n,i){var o=e;return n&&(o=this._getDataByDirection(o)),this._mcInst[t](o[0],o[1],i)},e.prototype._setHint=function(){var t={willChange:"transform"};h.utils.css(this.$container,t),h.utils.css(this._conf.panel.$list,t)},e.prototype._getDataByDirection=function(t){var e=t.concat();return!this.options.horizontal&&e.reverse(),e},e.prototype._arrangePanelPosition=function(t,e){var n=t===this._conf.dirData[0];this._movePanelPosition(Math.abs(e||1),n)},e.prototype._getBasePositionIndex=function(){return Math.floor(this._conf.panel.count/2-.1)},e.prototype._bindEvents=function(t){var e=this.options,n=this.$wrapper,i=this._mcInst;t?i.bind(n,{scale:this._getDataByDirection([-1,0]),direction:c.default["DIRECTION_"+(e.horizontal?"HORIZONTAL":"VERTICAL")],interruptable:!1,inputType:e.inputType,thresholdAngle:e.thresholdAngle}).on({hold:this._holdHandler.bind(this),change:this._changeHandler.bind(this),release:this._releaseHandler.bind(this),animationStart:this._animationStartHandler.bind(this),animationEnd:this._animationEndHandler.bind(this)}):i.unbind(n).off()},e.prototype._setAdaptiveHeight=function(t){var e=this._conf,n=e.indexToMove,i=void 0,o=void 0,r=0===n?this["get"+(t===c.default.DIRECTION_LEFT&&"Next"||t===c.default.DIRECTION_RIGHT&&"Prev"||"")+"Element"]():e.panel.$list[e.panel.currIndex+n],s=r.querySelector(":first-child");o=s.getAttribute(d.DATA_HEIGHT),o||(i=r.children,o=h.utils.outerHeight(i.length>1?(r.style.height="auto",r):s),s.setAttribute(d.DATA_HEIGHT,o)),this.$wrapper.style.height=o+"px"},e.prototype._triggerBeforeRestore=function(t){var e=this._conf,n=e.touch;n.direction=~~e.dirData.join("").replace(n.direction,""),e.customEvent.restore=this._triggerEvent(d.EVENTS.beforeRestore,{depaPos:t.depaPos,destPos:t.destPos}),e.customEvent.restore||("stop"in t&&t.stop(),e.panel.animating=!1)},e.prototype._triggerRestore=function(){var t=this._conf.customEvent;t.restore&&this._triggerEvent(d.EVENTS.restore),t.restoreCall=!1},e.prototype._setPhaseValue=function(t,e){var n=this._conf,i=this.options,o=n.panel;if("start"===t&&(o.changed=this._isMovable())){if(!this._triggerEvent(d.EVENTS.beforeFlickStart,e))return o.changed=o.animating=!1,!1;i.adaptiveHeight&&this._setAdaptiveHeight(n.touch.direction),0===n.indexToMove&&this._setPanelNo()}else"end"===t&&(i.circular&&o.changed&&this._arrangePanels(!0,n.indexToMove),!d.IS_ANDROID2&&this._setTranslate([-o.size*o.index,0]),n.touch.distance=n.indexToMove=0,o.changed&&this._triggerEvent(d.EVENTS.flickEnd));return this._adjustContainerCss(t),!0},e.prototype._getNumByDirection=function(){var t=this._conf;return t.touch.direction===t.dirData[0]?1:-1},e.prototype._revertPanelNo=function(){var t=this._conf.panel,e=this._getNumByDirection(),n=t.currIndex>=0?t.currIndex:t.index-e,i=t.currNo>=0?t.currNo:t.no-e;this._setPanelNo({index:n,no:i})},e.prototype._setPanelNo=function(t){var e=this._conf.panel,n=e.origCount-1,i=this._getNumByDirection();if(h.utils.isObject(t))for(var o in t)e[o]=t[o];else e.currIndex=e.index,e.currNo=e.no,e.index+=i,e.no+=i;e.no>n?e.no=0:e.no<0&&(e.no=n)},e.prototype._setPointerEvents=function(t){var e=h.utils.css(this.$container,"pointerEvents"),n=void 0;t&&t.holding&&t.hammerEvent&&t.hammerEvent.preventSystemEvent&&"none"!==e?n="none":t||"auto"===e||(n="auto"),n&&h.utils.css(this.$container,{pointerEvents:n})},e.prototype._getCoordsValue=function(t){var e=this._getDataByDirection(t);return{x:h.utils.getUnitValue(e[0]),y:h.utils.getUnitValue(e[1])}},e.prototype._setTranslate=function(t){var e=this._getCoordsValue(t);this._setMoveStyle(this.$container,[e.x,e.y])},e.prototype._isMovable=function(){var t=this.options,e=this._mcInst,n=Math.abs(this._conf.touch.distance)>=t.threshold,i=void 0,o=void 0;return!(!t.circular&&n&&(i=this._getDataByDirection(e.options.max)[0],(o=this._getDataByDirection(e.get())[0])<0||o>i))&&n},e.prototype._triggerEvent=function(t,e){var n=this._conf,i=n.panel;return t===d.EVENTS.flickEnd&&(i.currNo=i.no,i.currIndex=i.index),this.trigger(n.eventPrefix+t,h.utils.extend({eventType:t,index:i.currIndex,no:i.currNo,direction:n.touch.direction},e))},e.prototype._getElement=function(t,e,n){var i=this._conf.panel,o=this.options.circular,r=i.currIndex,s=t===this._conf.dirData[0],a=null,l=void 0,u=void 0;n?(l=i.count,u=r):(l=i.origCount,u=i.currNo);var c=u;return s?u<l-1?u++:o&&(u=0):u>0?u--:o&&(u=l-1),c!==u&&(a=e?i.$list[s?r+1:r-1]:u),a},e.prototype._setValueToMove=function(t){var e=this._conf;e.touch.distance=this.options.threshold+1,e.touch.direction=e.dirData[+!t]},e.prototype.getIndex=function(t){return this._conf.panel[t?"currIndex":"currNo"]},e.prototype.getElement=function(){var t=this._conf.panel;return t.$list[t.currIndex]},e.prototype.getNextElement=function(){return this._getElement(this._conf.dirData[0],!0)},e.prototype.getNextIndex=function(t){return this._getElement(this._conf.dirData[0],!1,t)},e.prototype.getAllElements=function(){return this._conf.panel.$list},e.prototype.getPrevElement=function(){return this._getElement(this._conf.dirData[1],!0)},e.prototype.getPrevIndex=function(t){return this._getElement(this._conf.dirData[1],!1,t)},e.prototype.getTotalCount=function(t){return this._conf.panel[t?"count":"origCount"]},e.prototype.isPlaying=function(){return this._conf.panel.animating},e.prototype._movePanel=function(t,e){var n=this._conf,i=n.panel,o=this.options;if(!i.animating&&!n.touch.holding)return this._setValueToMove(t),(o.circular||null!=this[t?"getNextIndex":"getPrevIndex"]())&&this._movePanelByPhase("setBy",[i.size*(t?1:-1),0],e),this},e.prototype._movePanelByPhase=function(t,e,n){var i=h.utils.getNumValue(n,this.options.duration);!1!==this._setPhaseValue("start")&&(this._setMovableCoord(t,e,!0,i),!i&&this._setPhaseValue("end"))},e.prototype.next=function(t){return this._movePanel(!0,t)},e.prototype.prev=function(t){return this._movePanel(!1,t)},e.prototype.moveTo=function(t,e){var n=this._conf,i=n.panel,o=this.options.circular,r=i.index,s=void 0,a=void 0,l=t;return(l=h.utils.getNumValue(l,-1))<0||l>=i.origCount||l===i.no||i.animating||n.touch.holding?this:(s=l-(o?i.no:r),a=s>0,o&&Math.abs(s)>(a?i.count-(r+1):r)&&(s+=(a?-1:1)*i.count,a=s>0),this._setPanelNo(o?{no:l}:{no:l,index:l}),this._conf.indexToMove=s,this._setValueToMove(a),this._movePanelByPhase(o?"setBy":"setTo",[i.size*(o?s:l),0],e),this)},e.prototype._checkPadding=function(){var t=this.options,e=t.previewPadding.concat(),n=h.utils.css(this.$wrapper,"padding").split(" ");t.horizontal&&n.reverse(),n=[n[0]],n.push(n[2===n.length?0:2]),n=n.map(Number),(2===e.length&&e[0]!==n[0]||e[1]!==n[1])&&this._setPadding(e)},e.prototype.resize=function(){var t,e=this._conf,n=this.options,i=e.panel,o=n.horizontal,r=void 0;~~n.previewPadding.join("")?(this._checkPadding(),r=i.size):o&&(r=i.size=h.utils.css(this.$wrapper,"width",!0));var s=this._getDataByDirection([r*(i.count-1),0]);if(o&&h.utils.css(this.$container,{width:s[0]+r+"px"}),h.utils.css(i.$list,(t={},t[o?"width":"height"]=h.utils.getUnitValue(r),t)),n.adaptiveHeight){var a=this.$container.querySelectorAll("["+d.DATA_HEIGHT+"]");a.length&&([].slice.call(a).forEach(function(t){return t.removeAttribute(d.DATA_HEIGHT)}),this._setAdaptiveHeight())}return this._mcInst.options.max=s,this._setMovableCoord("setTo",[r*i.index,0],!0,0),d.IS_ANDROID2&&(this._applyPanelsPos(),this._adjustContainerCss("end")),this},e.prototype.restore=function(t){var e=this._conf,n=e.panel,i=this._getDataByDirection(this._mcInst.get()),o=t,r=void 0;return i[0]!==n.currIndex*n.size?(e.customEvent.restoreCall=!0,o=h.utils.getNumValue(o,this.options.duration),this._revertPanelNo(),r=this._getDataByDirection([n.size*n.index,0]),this._triggerBeforeRestore({depaPos:i,destPos:r}),this._setMovableCoord("setTo",r,!0,o),o||(this._adjustContainerCss("end"),this._triggerRestore())):n.changed&&(this._revertPanelNo(),e.touch.distance=e.indexToMove=0),this},e.prototype.enableInput=function(){return this._mcInst.enableInput(),this},e.prototype.disableInput=function(){return this._mcInst.disableInput(),this},e.prototype.destroy=function(){var t=this._conf,e=t.origPanelStyle,n=e.wrapper,i=e.container,o=e.list,r=this.$wrapper;r.setAttribute("class",n.className),r[n.style?"setAttribute":"removeAttribute"]("style",n.style);var s=this.$container,a=[].slice.call(s.children);e.container.className?(s.setAttribute("class",i.className),s[i.style?"setAttribute":"removeAttribute"]("style",i.style)):(a.forEach(function(t){return r.appendChild(t)}),s.parentNode.removeChild(s));for(var l,u=0;l=a[u];u++){if(u>o.length-1){l.parentNode.removeChild(l);break}var c=o[u].className,h=o[u].style;l[c?"setAttribute":"removeAttribute"]("class",c),l[h?"setAttribute":"removeAttribute"]("style",h)}this._bindEvents(!1),this.off();for(var p in this)this[p]=null},e}((0,h.Mixin)(l.default).with(v.default));e.default=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={panel:{$list:null,index:0,no:0,currIndex:0,currNo:0,size:0,count:0,origCount:0,changed:!1,animating:!1,minCount:3},touch:{holdPos:[0,0],destPos:[0,0],distance:0,direction:null,lastPos:0,holding:!1},customEvent:{flick:!0,restore:!1,restoreCall:!1},dirData:[],indexToMove:0,$dummyAnchor:null},o={hwAccelerable:!0,prefix:"eg-flick",deceleration:6e-4,horizontal:!0,circular:!1,previewPadding:null,bounce:null,threshold:40,duration:100,panelEffect:function(t){return 1-Math.pow(1-t,3)},defaultIndex:0,inputType:["touch","mouse"],thresholdAngle:45,adaptiveHeight:!1};e.CONFIG=i,e.OPTIONS=o},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=n(1),a=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(s);e.default=function(t){return function(t){function e(){return i(this,e),o(this,t.apply(this,arguments))}return r(e,t),e.prototype._holdHandler=function(t){var e=this._conf;e.touch.holdPos=t.pos,e.touch.holding=!0,e.panel.changed=!1,this._adjustContainerCss("start",t.pos)},e.prototype._changeHandler=function(t){var e=this._conf,n=e.touch,i=+!this.options.horizontal,o=t.pos[i],r=n.holdPos[i],s=void 0,l=null,u=void 0;this._setPointerEvents(t),t.hammerEvent?(s=t.hammerEvent.direction,u=t.hammerEvent[this.options.horizontal?"deltaX":"deltaY"],~e.dirData.indexOf(s)||(s=e.dirData[+(Math.abs(n.lastPos)<=u)]),n.lastPos=u):n.lastPos=null,e.customEvent.flick&&(l=this._triggerEvent(a.EVENTS.flick,{pos:t.pos,holding:t.holding,direction:s||n.direction,distance:o-(r||(n.holdPos[i]=o))})),(l||null===l)&&this._setTranslate([-o,0])},e.prototype._releaseHandler=function(t){var e=this._conf.touch,n=t.destPos,i=+!this.options.horizontal,o=e.holdPos[i],r=this._conf.panel.size;e.distance=t.depaPos[i]-e.holdPos[i],e.direction=this._conf.dirData[+!(e.holdPos[i]<t.depaPos[i])],n[i]=Math.max(o-r,Math.min(o,n[i])),e.destPos[i]=n[i]=Math.round(n[i]/r)*r,0===e.distance&&this._adjustContainerCss("end"),e.holding=!1,this._setPointerEvents()},e.prototype._animationStartHandler=function(t){var e=this._conf,n=e.panel,i=e.customEvent;n.animating=!0,!i.restoreCall&&t.hammerEvent&&!1===this._setPhaseValue("start",{depaPos:t.depaPos,destPos:t.destPos})&&t.stop(),t.hammerEvent&&(t.duration=this.options.duration,t.destPos[+!this.options.horizontal]=n.size*(n.index+e.indexToMove)),this._isMovable()?!i.restoreCall&&(i.restore=!1):this._triggerBeforeRestore(t)},e.prototype._animationEndHandler=function(){this._setPhaseValue("end"),this._conf.panel.animating=!1,this._triggerRestore()},e}(t)}},function(t,e,n){"use strict";var i=n(2),o=function(t){return t&&t.__esModule?t:{default:t}}(i);t.exports=o.default},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Mixin=e.utils=void 0;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=n(0),s={$:function(t){var e=null;if("string"==typeof t){var n=t.match(/^<([a-z]+)\s*([^>]*)>/);n?(e=r.document.createElement(n[1]),3===n.length&&n[2].split(" ").forEach(function(t){var n=t.split("=");e.setAttribute(n[0],n[1].trim().replace(/(^["']|["']$)/g,""))})):(e=r.document.querySelectorAll(t),e.length?1===e.length&&(e=e[0]):e=null)}else t.nodeName&&1===t.nodeType&&(e=t);return e},isArray:function(t){return t&&t.constructor===Array},isObject:function(t){return t&&!t.nodeType&&"object"===(void 0===t?"undefined":o(t))&&!this.isArray(t)},extend:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];if(!i.length||1===i.length&&!i[0])return t;var r=i.shift();return this.isObject(t)&&this.isObject(r)&&Object.keys(r).forEach(function(n){var i=r[n];e.isObject(i)?(!t[n]&&(t[n]={}),t[n]=e.extend(t[n],i)):t[n]=e.isArray(i)?i.concat():i}),this.extend.apply(this,[t].concat(i))},css:function(t,e,n){if("string"==typeof e){var i=r.window.getComputedStyle(t)[e];return n?this.getNumValue(i):i}var o=function(t,e){return Object.keys(e).forEach(function(n){t[n]=e[n]})};return this.isArray(t)?t.forEach(function(t){return o(t.style,e)}):o(t.style,e),t},getNumValue:function(t,e){var n=t;return isNaN(n=parseInt(n,10))?e:n},getUnitValue:function(t){return(parseInt(t,10)||0)+(String(t).match(/(?:[a-z]{2,}|%)$/)||"px")},getOuter:function(t,e){var n=r.window.getComputedStyle(t),i="outerWidth"===e?["marginLeft","marginRight"]:["marginTop","marginBottom"];return this.getNumValue(n[e.replace("outer","").toLocaleLowerCase()])+this.getNumValue(n[i[0]])+this.getNumValue(n[i[1]])},outerWidth:function(t){return this.getOuter(t,"outerWidth")},outerHeight:function(t){return this.getOuter(t,"outerHeight")},isHWAccelerable:function(){var t=r.window.navigator.userAgent,e=!1,n=void 0;if(n=t.match(/Chrome\/(\d+)/))e=n[1]>="25";else if(/ie|edge|firefox|safari|inapp/.test(t))e=!0;else if(n=t.match(/Android ([\d.]+)/)){var i=n[1],o=(t.match(/\(.*\)/)||[null])[0];e=i>="4.1.0"&&!/EK-GN120|SM-G386F/.test(o)||i>="4.0.3"&&/SHW-|SHV-|GT-|SCH-|SGH-|SPH-|LG-F160|LG-F100|LG-F180|LG-F200|EK-|IM-A|LG-F240|LG-F260/.test(o)&&!/SHW-M420|SHW-M200|GT-S7562/.test(o)}return this.isHWAccelerable=function(){return e},e},translate:function(t,e,n){return n?"translate3d("+t+","+e+",0)":"translate("+t+","+e+")"},hasClickBug:function(){var t=r.window.navigator.userAgent,e=/Safari/.test(t);return this.hasClickBug=function(){return e},e}},a=function(){function t(e){i(this,t),this.superclass=e||function(){function t(){i(this,t)}return t}()}return t.prototype.with=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce(function(t,e){return e(t)},this.superclass)},t}(),l=function(t){return new a(t)};e.utils=s,e.Mixin=l},function(e,n){e.exports=t},function(t,n){t.exports=e}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@egjs/component"),require("@egjs/axes")):"function"==typeof define&&define.amd?define("Flicking",["@egjs/component","@egjs/axes"],e):"object"==typeof exports?exports.Flicking=e(require("@egjs/component"),require("@egjs/axes")):(t.eg=t.eg||{},t.eg.Flicking=e(t.eg.Component,t.eg.Axes))}(this,function(t,e){return function(t){function __webpack_require__(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,__webpack_require__),i.l=!0,i.exports}var e={};return __webpack_require__.m=t,__webpack_require__.c=e,__webpack_require__.d=function(t,e,n){__webpack_require__.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},__webpack_require__.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return __webpack_require__.d(e,"a",e),e},__webpack_require__.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=2)}([function(t,e,n){"use strict";e.__esModule=!0;var i="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),o=i.document;e.window=i,e.document=o},function(t,e,n){"use strict";e.__esModule=!0,e.DATA_HEIGHT=e.IS_ANDROID2=e.SUPPORT_WILLCHANGE=e.TRANSFORM=e.EVENTS=undefined;var i=n(0),o={beforeFlickStart:"beforeFlickStart",beforeRestore:"beforeRestore",flick:"flick",flickEnd:"flickEnd",restore:"restore"},r={name:"transform"};r.support=function(){var t=i.document.documentElement.style;return r.name in t||(r.name="webkitTransform")in t}();var s=i.window.CSS&&i.window.CSS.supports&&i.window.CSS.supports("will-change","transform"),a=/Android 2\./.test(navigator.userAgent);e.EVENTS=o,e.TRANSFORM=r,e.SUPPORT_WILLCHANGE=s,e.IS_ANDROID2=a,e.DATA_HEIGHT="data-height"},function(t,e,n){"use strict";var i=n(3),o=function(t){return t&&t.__esModule?t:{"default":t}}(i);o["default"].VERSION="2.0.0",t.exports=o["default"]},function(t,e,n){"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{"default":t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var i=n(4),o=_interopRequireDefault(i),r=n(5),s=_interopRequireDefault(r),a=n(6),l=n(1),c=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}(l),u=n(7),p=n(0),h=n(8),d=_interopRequireDefault(h),f=function(t){function Flicking(e,n,i){_classCallCheck(this,Flicking);var o=_possibleConstructorReturn(this,t.call(this));o.$wrapper=a.utils.$(e);var r=o.$wrapper&&o.$wrapper.children;if(!o.$wrapper||!r||!r.length)throw new Error("Given base element doesn't exist or it hasn't proper DOM structure to be initialized.");return o._setOptions(n),o._setConfig(r,i),!a.utils.hasClickBug()&&(o._setPointerEvents=function(){}),o._build(),o._bindEvents(!0),o._applyPanelsCss(),o._arrangePanels(),o.options.hwAccelerable&&c.SUPPORT_WILLCHANGE&&o._setHint(),o.options.adaptiveHeight&&o._setAdaptiveHeight(),o._adjustContainerCss("end"),o}return _inherits(Flicking,t),Flicking.prototype._setOptions=function(t){var e={previewPadding:[0,0],bounce:[10,10]};this.options=a.utils.extend(a.utils.extend({},u.OPTIONS),e,t);for(var n in e){var i=this.options[n];"number"==typeof i?i=[i,i]:a.utils.isArray(i)||(i=e[n]),this.options[n]=i}},Flicking.prototype._setConfig=function(t,e){var n=this.options,i=n.previewPadding,o=t;a.utils.classList(o[0],n.prefix+"-container")&&(o=o[0],this.$container=o,o=o.children),o=[].slice.call(o);var r=this._conf=a.utils.extend(a.utils.extend({},u.CONFIG),{panel:{$list:o,minCount:i[0]+i[1]>0?5:3},origPanelStyle:{wrapper:{className:this.$wrapper.getAttribute("class")||null,style:this.$wrapper.getAttribute("style")||null},container:{className:this.$container&&this.$container.getAttribute("class")||null,style:this.$container&&this.$container.getAttribute("style")||null},list:o.map(function(t){return{className:t.getAttribute("class")||null,style:t.getAttribute("style")||null}})},useLayerHack:n.hwAccelerable&&!c.SUPPORT_WILLCHANGE,eventPrefix:e||""});[["LEFT","RIGHT"],["UP","DOWN"]][+!n.horizontal].forEach(function(t){return r.dirData.push(s["default"]["DIRECTION_"+t])})},Flicking.prototype._build=function(){var t=this._conf.panel,e=this.options,n=t.$list,i=e.previewPadding.concat(),o=e.prefix,r=e.horizontal,l=t.count=t.origCount=n.length,c=e.bounce;this._setPadding(i,!0);var u=this._getDataByDirection([t.size,"100%"]),h={position:"relative",zIndex:2e3,width:"100%",height:"100%"};if(r&&(h.top="0px"),this.$container)a.utils.css(this.$container,h);else{var d=n[0].parentNode,f=p.document.createElement("div");f.className=o+"-container",a.utils.css(f,h),n.forEach(function(t){return f.appendChild(t)}),d.appendChild(f),this.$container=f}n.forEach(function(t){a.utils.classList(t,o+"-panel",!0),a.utils.css(t,{position:"absolute",width:a.utils.getUnitValue(u[0]),height:a.utils.getUnitValue(u[1]),boxSizing:"border-box",top:0,left:0})}),this._addClonePanels()&&(l=t.count=(t.$list=[].slice.call(this.$container.children)).length),this._axesInst=new s["default"]({flick:{range:[0,t.size*(l-1)],bounce:c}},{easing:e.panelEffect,deceleration:e.deceleration,interruptable:!1}),this._setDefaultPanel(e.defaultIndex)},Flicking.prototype._setPadding=function(t,e){var n=this.options.horizontal,i=this._conf.panel,o=t[0]+t[1],r={};!o&&e||(r.padding=n?"0 "+t.reverse().join("px 0 ")+"px":t.join("px 0 ")+"px"),e&&(r.overflow="hidden",r.boxSizing="border-box"),Object.keys(r).length&&a.utils.css(this.$wrapper,r);var s=getComputedStyle(this.$wrapper),l=n?["Left","Right"]:["Top","Bottom"],c=Math.max(this.$wrapper["offset"+(n?"Width":"Height")],a.utils.getNumValue(s[n?"width":"height"]));i.size=c-(a.utils.getNumValue(s["padding"+l[0]])+a.utils.getNumValue(s["padding"+l[1]]))},Flicking.prototype._addClonePanels=function(){var t=this,e=this._conf.panel,n=e.origCount,i=e.minCount-n,o=e.$list,r=void 0;if(this.options.circular&&n<e.minCount){for(r=o.map(function(t){return t.cloneNode(!0)});r.length<i;)r=r.concat(o.map(function(t){return t.cloneNode(!0)}));return r.forEach(function(e){return t.$container.appendChild(e)}),!!r.length}return!1},Flicking.prototype._movePanelPosition=function(t,e){var n=this._conf.panel,i=n.$list,o=i.splice(e?0:n.count-t,t);n.$list=e?i.concat(o):o.concat(i)},Flicking.prototype._setDefaultPanel=function(t){var e=this._conf.panel,n=e.count-1,i=void 0,o=void 0;this.options.circular?(t>0&&t<=n&&this._movePanelPosition(t,!0),o=this._getBasePositionIndex(),this._movePanelPosition(o,!1),this._setPanelNo({no:t,currNo:t})):t>0&&t<=n&&(this._setPanelNo({index:t,no:t,currIndex:t,currNo:t}),i=[-e.size*t,0],this._setTranslate(i),this._setAxes("setTo",Math.abs(i[0]),0))},Flicking.prototype._arrangePanels=function(t,e){var n=this._conf,i=n.panel,o=n.touch,r=n.dirData,s=void 0;this.options.circular&&(n.customEvent.flick=!1,t&&(e&&(o.direction=r[+!(e>0)]),this._arrangePanelPosition(o.direction,e)),s=this._getBasePositionIndex(),this._setPanelNo({index:s,currIndex:s}),n.customEvent.flick=!!this._setAxes("setTo",i.size*i.index,0)),this._applyPanelsPos()},Flicking.prototype._applyPanelsPos=function(){this._conf.panel.$list.forEach(this._applyPanelsCss.bind(this))},Flicking.prototype._setMoveStyle=function(t,e){var n=c.TRANSFORM;this._setMoveStyle=n.support?function(t,e){var i;a.utils.css(t,(i={},i[n.name]=a.utils.translate(e[0],e[1],this._conf.useLayerHack),i))}:function(t,e){a.utils.css(t,{left:e[0],top:e[1]})},this._setMoveStyle(t,e)},Flicking.prototype._applyPanelsCss=function(){var t=this._conf;c.IS_ANDROID2?(t.$dummyAnchor=a.utils.$(".__dummy_anchor"),!t.$dummyAnchor&&this.$wrapper.appendChild(t.$dummyAnchor=a.utils.$('<a href="javascript:void(0)" class="__dummy_anchor" style="position:absolute;height:0px;width:0px">')),this._applyPanelsCss=function(t,e){var n=this._getDataByDirection([this._conf.panel.size*e+"px",0]);a.utils.css(t,{left:n[0],top:n[1]})}):this._applyPanelsCss=function(t,e){var n=this._getDataByDirection([c.TRANSFORM.support?100*e+"%":this._conf.panel.size*e+"px",0]);this._setMoveStyle(t,n)}},Flicking.prototype._adjustContainerCss=function(t,e){var n=this._conf,i=n.panel,o=this.options,r=o.horizontal,s=o.previewPadding[0],l=this.$container,u=e,p=void 0;if(c.IS_ANDROID2)if(u||(u=-i.size*i.index),"start"===t)l=l.style,p=parseInt(l[r?"left":"top"],10),r?p&&(l.left="0px"):p!==s&&(l.top="0px"),this._setTranslate([-u,0]);else if("end"===t){var h;u=this._getCoordsValue([u,0]),a.utils.css(l,(h={left:u.x,top:u.y},h[c.TRANSFORM.name]=a.utils.translate(0,0,n.useLayerHack),h)),n.$dummyAnchor.focus()}},Flicking.prototype._setAxes=function(t,e,n){return this._axesInst[t]({flick:e},n)},Flicking.prototype._setHint=function(){var t={willChange:"transform"};a.utils.css(this.$container,t),a.utils.css(this._conf.panel.$list,t)},Flicking.prototype._getDataByDirection=function(t){var e=t.concat();return!this.options.horizontal&&e.reverse(),e},Flicking.prototype._arrangePanelPosition=function(t,e){var n=t===this._conf.dirData[0];this._movePanelPosition(Math.abs(e||1),n)},Flicking.prototype._getBasePositionIndex=function(){return Math.floor(this._conf.panel.count/2-.1)},Flicking.prototype._bindEvents=function(t){var e=this.options,n=this.$wrapper,i=this._axesInst;t?(this._panInput=new s["default"].PanInput(n,{inputType:e.inputType,thresholdAngle:e.thresholdAngle,scale:this._getDataByDirection([-1,0])}),i.on({hold:this._holdHandler.bind(this),change:this._changeHandler.bind(this),release:this._releaseHandler.bind(this),animationStart:this._animationStartHandler.bind(this),animationEnd:this._animationEndHandler.bind(this)}).connect(this._getDataByDirection(["flick",""]),this._panInput)):(this.disableInput(),i.off())},Flicking.prototype._setAdaptiveHeight=function(t){var e=this._conf,n=e.indexToMove,i=void 0,o=void 0,r=0===n?this["get"+(t===s["default"].DIRECTION_LEFT&&"Next"||t===s["default"].DIRECTION_RIGHT&&"Prev"||"")+"Element"]():e.panel.$list[e.panel.currIndex+n],l=r.querySelector(":first-child");l&&(o=l.getAttribute(c.DATA_HEIGHT),o||(i=r.children,(o=a.utils.outerHeight(i.length>1?(r.style.height="auto",r):l))>0&&l.setAttribute(c.DATA_HEIGHT,o)),o>0&&(this.$wrapper.style.height=o+"px"))},Flicking.prototype._triggerBeforeRestore=function(t){var e=this._conf,n=e.touch;n.direction=+e.dirData.join("").replace(n.direction,""),e.customEvent.restore=this._triggerEvent(c.EVENTS.beforeRestore,{depaPos:t.depaPos.flick,destPos:t.destPos.flick}),e.customEvent.restore||("stop"in t&&t.stop(),e.panel.animating=!1)},Flicking.prototype._triggerRestore=function(){var t=this._conf.customEvent;t.restore&&this._triggerEvent(c.EVENTS.restore),t.restoreCall=!1},Flicking.prototype._setPhaseValue=function(t,e){var n=this._conf,i=this.options,o=n.panel;if("start"===t&&(o.changed=this._isMovable())){if(!this._triggerEvent(c.EVENTS.beforeFlickStart,e))return o.changed=o.animating=!1,!1;i.adaptiveHeight&&this._setAdaptiveHeight(n.touch.direction),0===n.indexToMove&&this._setPanelNo()}else"end"===t&&(i.circular&&o.changed&&this._arrangePanels(!0,n.indexToMove),!c.IS_ANDROID2&&this._setTranslate([-o.size*o.index,0]),n.touch.distance=n.indexToMove=0,o.changed&&this._triggerEvent(c.EVENTS.flickEnd));return this._adjustContainerCss(t),!0},Flicking.prototype._getNumByDirection=function(){var t=this._conf;return t.touch.direction===t.dirData[0]?1:-1},Flicking.prototype._revertPanelNo=function(){var t=this._conf.panel,e=this._getNumByDirection(),n=t.currIndex>=0?t.currIndex:t.index-e,i=t.currNo>=0?t.currNo:t.no-e;this._setPanelNo({index:n,no:i})},Flicking.prototype._setPanelNo=function(t){var e=this._conf.panel,n=e.origCount-1,i=this._getNumByDirection();if(a.utils.isObject(t))for(var o in t)e[o]=t[o];else e.currIndex=e.index,e.currNo=e.no,e.index+=i,e.no+=i;e.no>n?e.no=0:e.no<0&&(e.no=n)},Flicking.prototype._setPointerEvents=function(t){var e=a.utils.css(this.$container,"pointerEvents"),n=void 0;t&&t.holding&&t.inputEvent&&t.inputEvent.preventSystemEvent&&"none"!==e?n="none":t||"auto"===e||(n="auto"),n&&a.utils.css(this.$container,{pointerEvents:n})},Flicking.prototype._getCoordsValue=function(t){var e=this._getDataByDirection(t);return{x:a.utils.getUnitValue(e[0]),y:a.utils.getUnitValue(e[1])}},Flicking.prototype._setTranslate=function(t){var e=this._getCoordsValue(t);this._setMoveStyle(this.$container,[e.x,e.y])},Flicking.prototype._isMovable=function(){var t=this.options,e=this._axesInst,n=Math.abs(this._conf.touch.distance)>=t.threshold,i=void 0,o=void 0;return!(!t.circular&&n&&(i=e.axis.flick.range[1],(o=e.get().flick)<0||o>i))&&n},Flicking.prototype._triggerEvent=function(t,e){var n=this._conf,i=n.panel;return t===c.EVENTS.flickEnd&&(i.currNo=i.no,i.currIndex=i.index),this.trigger(n.eventPrefix+t,a.utils.extend({eventType:t,index:i.currIndex,no:i.currNo,direction:n.touch.direction},e))},Flicking.prototype._getElement=function(t,e,n){var i=this._conf.panel,o=this.options.circular,r=i.currIndex,s=t===this._conf.dirData[0],a=null,l=void 0,c=void 0;n?(l=i.count,c=r):(l=i.origCount,c=i.currNo);var u=c;return s?c<l-1?c++:o&&(c=0):c>0?c--:o&&(c=l-1),u!==c&&(a=e?i.$list[s?r+1:r-1]:c),a},Flicking.prototype._setValueToMove=function(t){var e=this._conf;e.touch.distance=this.options.threshold+1,e.touch.direction=e.dirData[+!t]},Flicking.prototype.getIndex=function(t){return this._conf.panel[t?"currIndex":"currNo"]},Flicking.prototype.getElement=function(){var t=this._conf.panel;return t.$list[t.currIndex]},Flicking.prototype.getNextElement=function(){return this._getElement(this._conf.dirData[0],!0)},Flicking.prototype.getNextIndex=function(t){return this._getElement(this._conf.dirData[0],!1,t)},Flicking.prototype.getAllElements=function(){return this._conf.panel.$list},Flicking.prototype.getPrevElement=function(){return this._getElement(this._conf.dirData[1],!0)},Flicking.prototype.getPrevIndex=function(t){return this._getElement(this._conf.dirData[1],!1,t)},Flicking.prototype.getTotalCount=function(t){return this._conf.panel[t?"count":"origCount"]},Flicking.prototype.isPlaying=function(){return this._conf.panel.animating},Flicking.prototype._movePanel=function(t,e){var n=this._conf,i=n.panel,o=this.options;return i.animating||n.touch.holding?undefined:(this._setValueToMove(t),(o.circular||null!==this["get"+(t?"Next":"Prev")+"Index"]())&&this._movePanelByPhase("setBy",i.size*(t?1:-1),e),this)},Flicking.prototype._movePanelByPhase=function(t,e,n){var i=a.utils.getNumValue(n,this.options.duration);!1!==this._setPhaseValue("start")&&(this._setAxes(t,e,i),!i&&this._setPhaseValue("end"))},Flicking.prototype.next=function(t){return this._movePanel(!0,t)},Flicking.prototype.prev=function(t){return this._movePanel(!1,t)},Flicking.prototype.moveTo=function(t,e){var n=this._conf,i=n.panel,o=this.options.circular,r=i.index,s=void 0,l=void 0,c=t;return(c=a.utils.getNumValue(c,-1))<0||c>=i.origCount||c===i.no||i.animating||n.touch.holding?this:(s=c-(o?i.no:r),l=s>0,o&&Math.abs(s)>(l?i.count-(r+1):r)&&(s+=(l?-1:1)*i.count,l=s>0),this._setPanelNo(o?{no:c}:{no:c,index:c}),this._conf.indexToMove=s,this._setValueToMove(l),this._movePanelByPhase(o?"setBy":"setTo",i.size*(o?s:c),e),this)},Flicking.prototype.resize=function(){var t=this._conf,e=this.options,n=t.panel,i=e.horizontal,o=void 0;if(!this.isPlaying()){var r;a.utils.isArray(e.previewPadding)&&"number"==typeof+e.previewPadding.join("")?(this._setPadding(e.previewPadding.concat()),o=n.size):i&&(o=n.size=a.utils.css(this.$wrapper,"width",!0));var s=o*(n.count-1),l=this._getDataByDirection([s,0]);if(i&&a.utils.css(this.$container,{width:l[0]+o+"px"}),a.utils.css(n.$list,(r={},r[i?"width":"height"]=a.utils.getUnitValue(o),r)),e.adaptiveHeight){var u=this.$container.querySelectorAll("["+c.DATA_HEIGHT+"]");u.length&&([].slice.call(u).forEach(function(t){return t.removeAttribute(c.DATA_HEIGHT)}),this._setAdaptiveHeight())}this._axesInst.axis.flick.range=[0,s],this._setAxes("setTo",o*n.index,0),c.IS_ANDROID2&&(this._applyPanelsPos(),this._adjustContainerCss("end"))}return this},Flicking.prototype.restore=function(t){var e=this._conf,n=e.panel,i=this._axesInst.get().flick,o=t,r=void 0;return i!==n.currIndex*n.size?(e.customEvent.restoreCall=!0,o=a.utils.getNumValue(o,this.options.duration),this._revertPanelNo(),r=n.size*n.index,this._triggerBeforeRestore({depaPos:i,destPos:r}),this._setAxes("setTo",r,o),o||(this._adjustContainerCss("end"),this._triggerRestore())):n.changed&&(this._revertPanelNo(),e.touch.distance=e.indexToMove=0),this},Flicking.prototype.enableInput=function(){return this._panInput.enable(),this},Flicking.prototype.disableInput=function(){return this._panInput.disable(),this},Flicking.prototype.getStatus=function(t){var e=this._conf.panel,n=/((?:-webkit-)?transform|left|top|will-change|box-sizing|width):[^;]*;/g,i={panel:{index:e.index,no:e.no,currIndex:e.currIndex,currNo:e.currNo},$list:e.$list.map(function(t){return{style:t.style.cssText.replace(n,"").trim(),className:t.className,html:t.innerHTML}})};return t?JSON.stringify(i):i},Flicking.prototype.setStatus=function(t){var e=this._conf.panel,n=this.options.adaptiveHeight,i="string"==typeof t?JSON.parse(t):t;if(i){for(var o in i.panel)o in e&&(e[o]=i.panel[o]);e.$list.forEach(function(t,e){var n=i.$list[e],o=n.style,r=n.className,s=n.html;o&&(t.style.cssText+=o),r&&(t.className=r),s&&(t.innerHTML=s)}),n&&this._setAdaptiveHeight()}},Flicking.prototype.destroy=function(){var t=this._conf,e=t.origPanelStyle,n=e.wrapper,i=e.container,o=e.list,r=this.$wrapper;r.setAttribute("class",n.className),r[n.style?"setAttribute":"removeAttribute"]("style",n.style);var s=this.$container,a=[].slice.call(s.children);e.container.className?(s.setAttribute("class",i.className),s[i.style?"setAttribute":"removeAttribute"]("style",i.style)):(a.forEach(function(t){return r.appendChild(t)}),s.parentNode.removeChild(s));for(var l,c=0;l=a[c];c++)if(c>o.length-1)l.parentNode.removeChild(l);else{var u=o[c].className,p=o[c].style;l[u?"setAttribute":"removeAttribute"]("class",u),l[p?"setAttribute":"removeAttribute"]("style",p)}this._bindEvents(!1),this.off();for(var h in this)this[h]=null},Flicking}((0,a.Mixin)(o["default"])["with"](d["default"]));f.DIRECTION_NONE=s["default"].DIRECTION_NONE,f.DIRECTION_LEFT=s["default"].DIRECTION_LEFT,f.DIRECTION_RIGHT=s["default"].DIRECTION_RIGHT,f.DIRECTION_UP=s["default"].DIRECTION_UP,f.DIRECTION_DOWN=s["default"].DIRECTION_DOWN,f.DIRECTION_HORIZONTAL=s["default"].DIRECTION_HORIZONTAL,f.DIRECTION_VERTICAL=s["default"].DIRECTION_VERTICAL,f.DIRECTION_ALL=s["default"].DIRECTION_ALL,e["default"]=f,t.exports=e["default"]},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Mixin=e.utils=undefined;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=n(0),r={$:function(t){var e=null;if("string"==typeof t){var n=t.match(/^<([a-z]+)\s*([^>]*)>/);n?(e=o.document.createElement(n[1]),3===n.length&&n[2].split(" ").forEach(function(t){var n=t.split("=");e.setAttribute(n[0],n[1].trim().replace(/(^["']|["']$)/g,""))})):(e=o.document.querySelectorAll(t),e.length?1===e.length&&(e=e[0]):e=null)}else t.nodeName&&1===t.nodeType&&(e=t);return e},isArray:function(t){return t&&t.constructor===Array},isObject:function(t){return t&&!t.nodeType&&"object"===(void 0===t?"undefined":i(t))&&!this.isArray(t)},extend:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];if(!i.length||1===i.length&&!i[0])return t;var r=i.shift();return this.isObject(t)&&this.isObject(r)&&Object.keys(r).forEach(function(n){var i=r[n];e.isObject(i)?(!t[n]&&(t[n]={}),t[n]=e.extend(t[n],i)):t[n]=e.isArray(i)?i.concat():i}),this.extend.apply(this,[t].concat(i))},css:function(t,e,n){if("string"==typeof e){var i=o.window.getComputedStyle(t)[e];return n?this.getNumValue(i):i}var r=function(t,e){return Object.keys(e).forEach(function(n){t[n]=e[n]})};return this.isArray(t)?t.forEach(function(t){return r(t.style,e)}):r(t.style,e),t},classList:function(t,e,n){var i="boolean"==typeof n,o=void 0;return t.classList?o=t.classList[i&&(n?"add":"remove")||"contains"](e):(o=t.className,i?n&&-1===o.indexOf(e)?o=t.className=(o+" "+e).replace(/\s{2,}/g," "):n||(o=t.className=o.replace(e,"")):o=new RegExp("\\b"+e+"\\b").test(o)),o},getNumValue:function(t,e){var n=t;return isNaN(n=parseInt(n,10))?e:n},getUnitValue:function(t){var e=/(?:[a-z]{2,}|%)$/;return(parseInt(t,10)||0)+(String(t).match(e)||"px")},getOuter:function(t,e){var n=o.window.getComputedStyle(t),i="outerWidth"===e?["marginLeft","marginRight"]:["marginTop","marginBottom"];return this.getNumValue(n[e.replace("outer","").toLocaleLowerCase()])+this.getNumValue(n[i[0]])+this.getNumValue(n[i[1]])},outerWidth:function(t){return this.getOuter(t,"outerWidth")},outerHeight:function(t){return this.getOuter(t,"outerHeight")},isHWAccelerable:function(){var t=o.window.navigator.userAgent,e=!1,n=void 0;if(n=t.match(/Chrome\/(\d+)/))e=n[1]>="25";else if(/ie|edge|firefox|safari|inapp/.test(t))e=!0;else if(n=t.match(/Android ([\d.]+)/)){var i=n[1],r=(t.match(/\(.*\)/)||[null])[0];e=i>="4.1.0"&&!/EK-GN120|SM-G386F/.test(r)||i>="4.0.3"&&/SHW-|SHV-|GT-|SCH-|SGH-|SPH-|LG-F160|LG-F100|LG-F180|LG-F200|EK-|IM-A|LG-F240|LG-F260/.test(r)&&!/SHW-M420|SHW-M200|GT-S7562/.test(r)}return this.isHWAccelerable=function(){return e},e},translate:function(t,e,n){return n?"translate3d("+t+","+e+",0)":"translate("+t+","+e+")"},hasClickBug:function(){var t=o.window.navigator.userAgent,e=/Safari/.test(t);return this.hasClickBug=function(){return e},e}},s=function(){function MixinBuilder(t){_classCallCheck(this,MixinBuilder),this.superclass=t||function(){function _class(){_classCallCheck(this,_class)}return _class}()}return MixinBuilder.prototype["with"]=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce(function(t,e){return e(t)},this.superclass)},MixinBuilder}(),a=function(t){return new s(t)};e.utils=r,e.Mixin=a},function(t,e,n){"use strict";e.__esModule=!0;var i={panel:{$list:null,index:0,no:0,currIndex:0,currNo:0,size:0,count:0,origCount:0,changed:!1,animating:!1,minCount:3},touch:{holdPos:0,destPos:0,distance:0,direction:null,lastPos:0,holding:!1},customEvent:{flick:!0,restore:!1,restoreCall:!1},dirData:[],indexToMove:0,$dummyAnchor:null},o={hwAccelerable:!0,prefix:"eg-flick",deceleration:6e-4,horizontal:!0,circular:!1,previewPadding:null,bounce:null,threshold:40,duration:100,panelEffect:function(t){return 1-Math.pow(1-t,3)},defaultIndex:0,inputType:["touch","mouse"],thresholdAngle:45,adaptiveHeight:!1};e.CONFIG=i,e.OPTIONS=o},function(t,e,n){"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var i=n(1),o=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}(i);e["default"]=function(t){return function(t){function _class(){return _classCallCheck(this,_class),_possibleConstructorReturn(this,t.apply(this,arguments))}return _inherits(_class,t),_class.prototype._holdHandler=function(t){var e=this._conf,n=t.pos.flick;e.touch.holdPos=n,e.touch.holding=!0,e.panel.changed=!1,this._adjustContainerCss("start",n)},_class.prototype._changeHandler=function(t){var e=this._conf,n=e.touch,i=t.pos.flick,r=n.holdPos,s=void 0,a=null,l=void 0;this._setPointerEvents(t),t.inputEvent?(s=t.inputEvent.direction,l=t.inputEvent[this.options.horizontal?"deltaX":"deltaY"],~e.dirData.indexOf(s)||(s=e.dirData[+(Math.abs(n.lastPos)<=l)]),n.lastPos=l):n.lastPos=null,e.customEvent.flick&&(a=this._triggerEvent(o.EVENTS.flick,{pos:i,holding:t.holding,direction:s||n.direction,distance:i-r})),(a||null===a)&&this._setTranslate([-i,0])},_class.prototype._releaseHandler=function(t){var e=this._conf,n=e.touch,i=n.holdPos,o=e.panel.size,r=e.customEvent,s=n.holdPos<t.depaPos.flick;n.distance=t.depaPos.flick-i,n.direction=e.dirData[+!s],n.destPos=i+(s?o:-o);var a=n.distance,l=this.options.duration,c=i;this._isMovable()?(!r.restoreCall&&(r.restore=!1),c=n.destPos):Math.abs(a)>0?this._triggerBeforeRestore(t):l=0,t.setTo({flick:c},l),0===a&&this._adjustContainerCss("end"),n.holding=!1,this._setPointerEvents()},_class.prototype._animationStartHandler=function(t){var e=this._conf,n=e.panel,i=e.customEvent,o=t.inputEvent||e.touch.lastPos;n.animating=!0,!i.restoreCall&&o&&!1===this._setPhaseValue("start",{depaPos:t.depaPos.flick,destPos:t.destPos.flick})&&t.stop(),o&&(t.duration=this.options.duration,t.destPos.flick=n.size*(n.index+e.indexToMove))},_class.prototype._animationEndHandler=function(){this._setPhaseValue("end"),this._conf.panel.animating=!1,this._triggerRestore()},_class}(t)},t.exports=e["default"]}])}); | ||
//# sourceMappingURL=flicking.min.js.map |
{ | ||
"name": "@egjs/flicking", | ||
"version": "2.0.0-rc.2", | ||
"version": "2.0.0", | ||
"main": "dist/flicking.js", | ||
"es2015": "src/Flicking.js", | ||
"scripts": { | ||
"start": "webpack-dev-server --env.mode server", | ||
"build": "webpack --display-error-details --env.mode production && webpack --env.mode pkgd", | ||
"start": "webpack-dev-server --open", | ||
"build": "webpack --env production && webpack --env packaged", | ||
"test": "karma start", | ||
@@ -13,4 +14,13 @@ "test:chrome": "karma start --chrome", | ||
"coverage": "karma start --coverage", | ||
"demo:start": "npm run demo:prebuild-latest && npm run demo:updateVersion && jekyll serve --host=0.0.0.0 -s demo", | ||
"demo:build": "npm run demo:updateVersion && jekyll build -s demo", | ||
"demo:prebuild-version": "cpx 'dist/**/*' demo/release/$npm_package_version/dist --clean && cpx 'doc/**/*' demo/release/$npm_package_version/doc --clean", | ||
"demo:prebuild-latest": "cpx 'dist/**/*' demo/release/latest/dist --clean && cpx 'doc/**/*' demo/release/latest/doc --clean", | ||
"demo:deploy": "npm run build && npm run jsdoc && npm run demo:prebuild-version && npm run demo:prebuild-latest && npm run demo:build && gh-pages -d demo/_site --remote upstream", | ||
"demo:updateVersion": "echo $npm_package_version > demo/_data/version.yml", | ||
"demo:setup": "cpx 'node_modules/@egjs/common-demo/**/*' 'demo/' && rm demo/package.json", | ||
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"prepush": "npm run lint", | ||
"commitmsg": "node config/validate-commit-msg.js" | ||
"commitmsg": "node config/validate-commit-msg.js", | ||
"changelog": "node ./config/changelog.js" | ||
}, | ||
@@ -20,48 +30,59 @@ "author": { | ||
}, | ||
"namespace": { | ||
"eg": "eg" | ||
}, | ||
"homepage": "https://github.com/naver/egjs-flicking", | ||
"license": "MIT <https://naver.github.io/egjs/license.txt>", | ||
"bugs": { | ||
"url" : "https://github.com/naver/egjs-flicking/issues" | ||
}, | ||
"dependencies": { | ||
"@egjs/component": "^2.0.0-rc.1", | ||
"@egjs/movablecoord": "^2.0.0-rc.1" | ||
"@egjs/component": "^2.0.0", | ||
"@egjs/axes": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.24.0", | ||
"babel-loader": "^6.4.1", | ||
"@egjs/common-demo": "github:naver/egjs#common-demo", | ||
"babel-core": "^6.25.0", | ||
"babel-eslint": "^7.2.3", | ||
"babel-loader": "^7.1.1", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-preset-es2015": "^6.24.0", | ||
"chai": "^3.5.0", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0", | ||
"babel-plugin-transform-es3-property-literals": "^6.22.0", | ||
"babel-plugin-transform-object-assign": "^6.22.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"chai": "^4.1.1", | ||
"clean-webpack-plugin": "^0.1.16", | ||
"egjs-jsdoc-template": "^1.3.1", | ||
"eslint": "^3.18.0", | ||
"coveralls": "^2.13.1", | ||
"cpx": "^1.5.0", | ||
"egjs-jsdoc-template": "1.3.3", | ||
"eslint": "^3.19.0", | ||
"eslint-config-naver": "^1.0.0", | ||
"eslint-loader": "^1.7.0", | ||
"eslint-loader": "^1.9.0", | ||
"gh-pages": "^1.0.0", | ||
"hammer-simulator": "0.0.1", | ||
"husky": "^0.13.3", | ||
"inject-loader": "^3.0.0", | ||
"istanbul-instrumenter-loader": "^2.0.0", | ||
"jsdoc": "^3.4.3", | ||
"karma": "^1.5.0", | ||
"husky": "^0.14.3", | ||
"inject-loader": "^3.0.1", | ||
"istanbul-instrumenter-loader": "^3.0.0", | ||
"jsdoc": "^3.5.4", | ||
"karma": "^1.7.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-coverage-istanbul-reporter": "^1.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage-istanbul-reporter": "^1.3.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.3", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"karma-sinon": "^1.0.5", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^2.0.3", | ||
"karma-webpack": "^2.0.4", | ||
"lite-fixture": "^1.0.2", | ||
"mocha": "^3.2.0", | ||
"phantomjs-polyfill": "0.0.2", | ||
"phantomjs-polyfill-object-assign": "0.0.2", | ||
"phantomjs-prebuilt": "^2.1.14", | ||
"sinon": "^2.1.0", | ||
"mocha": "^3.5.0", | ||
"sinon": "^3.2.0", | ||
"string-replace-webpack-plugin": "0.1.3", | ||
"uglify-js": "^2.8.16", | ||
"uglifyjs-webpack-plugin": "^0.3.1", | ||
"webpack": "^2.3.2", | ||
"webpack-dev-server": "^2.4.2", | ||
"uglifyjs-webpack-plugin": "^0.4.6", | ||
"webpack": "^3.5.3", | ||
"webpack-dev-server": "^2.7.1", | ||
"webpack-merge": "^4.1.0", | ||
"write-file-webpack-plugin": "^4.0.0" | ||
"write-file-webpack-plugin": "^4.1.0", | ||
"xml2js": "^0.4.17" | ||
} | ||
} |
120
README.md
@@ -1,11 +0,52 @@ | ||
# egjs-flicking | ||
# egjs-flicking [![npm version](https://badge.fury.io/js/%40egjs%2Fflicking.svg)](https://badge.fury.io/js/%40egjs%2Fflicking) [![Build Status](https://travis-ci.org/naver/egjs-flicking.svg?branch=master)](https://travis-ci.org/naver/egjs-flicking) [![Coverage Status](https://coveralls.io/repos/github/naver/egjs-flicking/badge.svg?branch=master)](https://coveralls.io/github/naver/egjs-flicking?branch=master) | ||
A module used to implement flicking interactions. | ||
With this module, you can make flicking gestures, which are ways to navigate left and right to move between panels arranged side by side. | ||
## Documentation | ||
* API Documentation | ||
- Latest: [http://naver.github.io/egjs/latest/doc/eg.Flicking.html](http://naver.github.io/egjs/latest/doc/eg.Flicking.html) | ||
- Specific version: [http://naver.github.io/egjs/[VERSION]/doc/eg.Flicking.html](http://naver.github.io/egjs/[VERSION]/doc/eg.Flicking.html) | ||
* Variety of demos are available at [Codpen.io](http://codepen.io/collection/ArxyLK). | ||
## Documents | ||
- [Get Started and Demos](https://naver.github.io/egjs-flicking/) | ||
- [API documentation](https://naver.github.io/egjs-flicking/release/latest/doc/) | ||
## Download and Installation | ||
Download dist files from repo directly or install it via npm. | ||
### For development (Uncompressed) | ||
You can download the uncompressed files for development | ||
- Latest : https://naver.github.io/egjs-flicking/release/latest/dist/flicking.js | ||
- Specific version : https://naver.github.io/egjs-flicking/release/[VERSION]/dist/flicking.js | ||
### For production (Compressed) | ||
You can download the compressed files for production | ||
- Latest : https://naver.github.io/egjs-flicking/release/latest/dist/flicking.min.js | ||
- Specific version : https://naver.github.io/egjs-flicking/release/[VERSION]/dist/flicking.min.js | ||
### Packaged version (with Dependencies) | ||
> Packaged version is not an official distribution. | ||
> Is just to provide for ease use of 'egjs-flicking' with dependency. | ||
- **Latest** | ||
- https://naver.github.io/egjs-flicking/release/latest/dist/flicking.pkgd.js | ||
- https://naver.github.io/egjs-flicking/release/latest/dist/flicking.pkgd.min.js | ||
- **Specific version** | ||
- https://naver.github.io/egjs-flicking/release/[VERSION]/dist/flicking.pkgd.js | ||
- https://naver.github.io/egjs-flicking/release/[VERSION]/dist/flicking.pkgd.min.js | ||
### Installation with npm | ||
The following command shows how to install egjs-flicking using npm. | ||
```bash | ||
$ npm install @egjs/flicking | ||
``` | ||
## Supported Browsers | ||
@@ -22,3 +63,70 @@ The following are the supported browsers. | ||
|[eg.Component](https://github.com/naver/egjs-component)|[eg.MovableCoord](https://github.com/naver/egjs-movablecoord)| | ||
|----|----| | ||
|2.0.0+|2.0.0+| | ||
## How to start developing egjs-flicking? | ||
For anyone interested to develop egjs-flicking, follow the instructions below. | ||
### Development Environment | ||
#### 1. Clone the repository | ||
Clone the egjs-flicking repository and install the dependency modules. | ||
```bash | ||
# Clone the repository. | ||
$ git clone https://github.com/naver/egjs-flicking.git | ||
``` | ||
#### 2. Install dependencies | ||
`npm` is supported. | ||
``` | ||
# Install the dependency modules. | ||
$ npm install | ||
``` | ||
#### 3. Build | ||
Use npm script to build billboard.js | ||
```bash | ||
# Run webpack-dev-server for development | ||
$ npm start | ||
# Build | ||
$ npm run build | ||
# Generate jsdoc | ||
$ npm run jsdoc | ||
``` | ||
Two folders will be created after complete build is completed. | ||
- **dist** folder: Includes the **flicking.js** and **flicking.min.js** files. | ||
- **doc** folder: Includes API documentation. The home page for the documentation is **doc/index.html**. | ||
### Linting | ||
To keep the same code style, we adopted [ESLint](http://eslint.org/) to maintain our code quality. The [rules](https://github.com/naver/eslint-config-naver/tree/master/rules) are modified version based on [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript). | ||
Setup your editor for check or run below command for linting. | ||
```bash | ||
$ npm run lint | ||
``` | ||
### Test | ||
Once you created a branch and done with development, you must perform a test running `npm run test` command before you push code to a remote repository. | ||
```bash | ||
$ npm run test | ||
``` | ||
Running a `npm run test` command will start [Mocha](https://mochajs.org/) tests via [Karma-runner](https://karma-runner.github.io/). | ||
## Bug Report | ||
@@ -25,0 +133,0 @@ |
@@ -21,4 +21,4 @@ /** | ||
touch: { | ||
holdPos: [0, 0], // hold x,y coordinate | ||
destPos: [0, 0], // destination x,y coordinate | ||
holdPos: 0, // hold x,y coordinate | ||
destPos: 0, // destination x,y coordinate | ||
distance: 0, // touch distance pixel of start to end touch | ||
@@ -25,0 +25,0 @@ direction: null, // touch direction |
@@ -16,7 +16,11 @@ /** | ||
// check for css transform support | ||
const SUPPORT_TRANSFORM = (() => { | ||
// check for the transform property | ||
const TRANSFORM = { | ||
name: "transform" | ||
}; | ||
TRANSFORM.support = (() => { | ||
const style = doc.documentElement.style; | ||
return "transform" in style || "webkitTransform" in style; | ||
return TRANSFORM.name in style || (TRANSFORM.name = "webkitTransform") in style; | ||
})(); | ||
@@ -36,3 +40,3 @@ | ||
EVENTS, | ||
SUPPORT_TRANSFORM, | ||
TRANSFORM, | ||
SUPPORT_WILLCHANGE, | ||
@@ -39,0 +43,0 @@ IS_ANDROID2, |
@@ -8,3 +8,2 @@ /** | ||
export default superclass => class extends superclass { | ||
/** | ||
@@ -15,8 +14,9 @@ * 'hold' event handler | ||
const conf = this._conf; | ||
const holdPos = e.pos.flick; | ||
conf.touch.holdPos = e.pos; | ||
conf.touch.holdPos = holdPos; | ||
conf.touch.holding = true; | ||
conf.panel.changed = false; | ||
this._adjustContainerCss("start", e.pos); | ||
this._adjustContainerCss("start", holdPos); | ||
} | ||
@@ -30,5 +30,4 @@ | ||
const touch = conf.touch; | ||
const posIndex = +!this.options.horizontal; | ||
const pos = e.pos[posIndex]; | ||
const holdPos = touch.holdPos[posIndex]; | ||
const pos = e.pos.flick; | ||
const holdPos = touch.holdPos; | ||
let direction; | ||
@@ -49,14 +48,12 @@ let eventRes = null; | ||
* @param {Number} param.no Logical index number of the current panel element, which is relative to the panel content <ko>현재 패널 엘리먼트의 논리적 인덱스 번호. 패널 콘텐츠를 기준으로 하는 인덱스 번호다</ko> | ||
* @param {Number} param.direction Direction of the movement (see eg.MovableCoord.DIRECTION_* constant) <ko>이동 방향(eg.MovableCoord.DIRECTION_* constant 참고)</ko> | ||
* @param {Array} param.pos Start coordinate <ko>출발점 좌표</ko> | ||
* @param {Number} param.pos.0 x-coordinate <ko>x 좌표</ko> | ||
* @param {Number} param.pos.1 y-coordinate <ko>y 좌표</ko> | ||
* @param {Number} param.direction Direction of the movement (see eg.Axes.DIRECTION_* constant) <ko>이동 방향(eg.Axes.DIRECTION_* constant 참고)</ko> | ||
* @param {Number} param.pos current coordinate <ko>현재 좌표</ko> | ||
* @param {Boolean} param.holding Indicates whether a user holds an element on the screen of the device. <ko>사용자가 기기의 화면을 누르고 있는지 여부</ko> | ||
* @param {Number} param.distance Distance moved from then starting point. According the move direction, positive on eg.MovableCoord.DIRECTION_LEFT/UP and negative on eg.MovableCoord.DIRECTION_RIGHT/DOWN <ko>시작점부터 이동된 거리의 값. 이동 방향에 따라 eg.MovableCoord.DIRECTION_LEFT/UP의 경우 양수를 eg.MovableCoord.DIRECTION_RIGHT/DOWN의 경우는 음수를 반환</ko> | ||
* @param {Number} param.distance Distance moved from then starting point. According the move direction, positive on eg.Axes.DIRECTION_LEFT/UP and negative on eg.Axes.DIRECTION_RIGHT/DOWN <ko>시작점부터 이동된 거리의 값. 이동 방향에 따라 eg.Axes.DIRECTION_LEFT/UP의 경우 양수를 eg.Axes.DIRECTION_RIGHT/DOWN의 경우는 음수를 반환</ko> | ||
*/ | ||
if (e.hammerEvent) { | ||
direction = e.hammerEvent.direction; | ||
if (e.inputEvent) { | ||
direction = e.inputEvent.direction; | ||
// Adjust direction in case of diagonal touch move | ||
movedPx = e.hammerEvent[this.options.horizontal ? "deltaX" : "deltaY"]; | ||
movedPx = e.inputEvent[this.options.horizontal ? "deltaX" : "deltaY"]; | ||
@@ -74,6 +71,6 @@ if (!~conf.dirData.indexOf(direction)) { | ||
this._triggerEvent(consts.EVENTS.flick, { | ||
pos: e.pos, | ||
pos, | ||
holding: e.holding, | ||
direction: direction || touch.direction, | ||
distance: pos - (holdPos || (touch.holdPos[posIndex] = pos)) | ||
distance: pos - holdPos | ||
} | ||
@@ -89,22 +86,30 @@ )); | ||
_releaseHandler(e) { | ||
const touch = this._conf.touch; | ||
const pos = e.destPos; | ||
const posIndex = +!this.options.horizontal; | ||
const holdPos = touch.holdPos[posIndex]; | ||
const panelSize = this._conf.panel.size; | ||
const conf = this._conf; | ||
const touch = conf.touch; | ||
const holdPos = touch.holdPos; | ||
const panelSize = conf.panel.size; | ||
const customEvent = conf.customEvent; | ||
const isPlusMove = touch.holdPos < e.depaPos.flick; | ||
touch.distance = e.depaPos[posIndex] - touch.holdPos[posIndex]; | ||
touch.distance = e.depaPos.flick - holdPos; | ||
touch.direction = conf.dirData[+!(isPlusMove)]; | ||
touch.destPos = holdPos + (isPlusMove ? panelSize : -panelSize); | ||
touch.direction = this._conf.dirData[ | ||
+!(touch.holdPos[posIndex] < e.depaPos[posIndex]) | ||
]; | ||
const distance = touch.distance; | ||
let duration = this.options.duration; | ||
let moveTo = holdPos; | ||
pos[posIndex] = Math.max( | ||
holdPos - panelSize, Math.min(holdPos, pos[posIndex]) | ||
); | ||
if (this._isMovable()) { | ||
!customEvent.restoreCall && (customEvent.restore = false); | ||
moveTo = touch.destPos; | ||
} else if (Math.abs(distance) > 0) { | ||
this._triggerBeforeRestore(e); | ||
} else { | ||
duration = 0; | ||
} | ||
touch.destPos[posIndex] = | ||
pos[posIndex] = Math.round(pos[posIndex] / panelSize) * panelSize; | ||
// trigger animation | ||
e.setTo({flick: moveTo}, duration); | ||
touch.distance === 0 && this._adjustContainerCss("end"); | ||
distance === 0 && this._adjustContainerCss("end"); | ||
touch.holding = false; | ||
@@ -122,9 +127,11 @@ | ||
const customEvent = conf.customEvent; | ||
const isFromInput = e.inputEvent || conf.touch.lastPos; | ||
panel.animating = true; | ||
if (!customEvent.restoreCall && e.hammerEvent && | ||
// when animation was started by input action | ||
if (!customEvent.restoreCall && isFromInput && | ||
this._setPhaseValue("start", { | ||
depaPos: e.depaPos, | ||
destPos: e.destPos | ||
depaPos: e.depaPos.flick, | ||
destPos: e.destPos.flick | ||
}) === false) { | ||
@@ -134,6 +141,6 @@ e.stop(); | ||
if (e.hammerEvent) { | ||
if (isFromInput) { | ||
e.duration = this.options.duration; | ||
e.destPos[+!this.options.horizontal] = | ||
e.destPos.flick = | ||
panel.size * ( | ||
@@ -143,8 +150,2 @@ panel.index + conf.indexToMove | ||
} | ||
if (this._isMovable()) { | ||
!customEvent.restoreCall && (customEvent.restore = false); | ||
} else { | ||
this._triggerBeforeRestore(e); | ||
} | ||
} | ||
@@ -151,0 +152,0 @@ |
@@ -5,4 +5,5 @@ /** | ||
*/ | ||
import Flicking from "./flicking"; | ||
import Flicking from "./Flicking"; | ||
Flicking.VERSION = "#__VERSION__#"; | ||
module.exports = Flicking; |
@@ -108,3 +108,3 @@ /** | ||
* Object: set style value | ||
* @parma {Boolean} getAsNumber - get the value as number | ||
* @param {Boolean} getAsNumber Get the value as number | ||
* @returns {String|HTMLElement} | ||
@@ -132,2 +132,34 @@ */ | ||
/** | ||
* classList | ||
* @param {HTMLElement} el target DOM element | ||
* @param {String} className class name string to be handled | ||
* @param {Boolean} add Add or remove class - true: Add, false: Remove | ||
* @return {Boolean} if add param is missing, then return existence of class name | ||
*/ | ||
classList(el, className, add) { | ||
const isAddParam = typeof add === "boolean"; | ||
let res; | ||
if (el.classList) { | ||
res = el.classList[ | ||
(isAddParam && (add ? "add" : "remove")) || "contains" | ||
](className); | ||
} else { | ||
res = el.className; | ||
if (isAddParam) { | ||
if (add && res.indexOf(className) === -1) { | ||
res = el.className = (`${res} ${className}`).replace(/\s{2,}/g, " "); | ||
} else if (!add) { | ||
res = el.className = res.replace(className, ""); | ||
} | ||
} else { | ||
res = new RegExp(`\\b${className}\\b`).test(res); | ||
} | ||
} | ||
return res; | ||
}, | ||
/** | ||
* Check and parse value to number | ||
@@ -216,4 +248,4 @@ * @param {Number|String} val | ||
version >= "4.0.3" && | ||
/SHW-|SHV-|GT-|SCH-|SGH-|SPH-|LG-F160|LG-F100|LG-F180|LG-F200|EK-|IM-A|LG-F240|LG-F260/.test(useragent) && | ||
!/SHW-M420|SHW-M200|GT-S7562/.test(useragent) | ||
/SHW-|SHV-|GT-|SCH-|SGH-|SPH-|LG-F160|LG-F100|LG-F180|LG-F200|EK-|IM-A|LG-F240|LG-F260/.test(useragent) && | ||
!/SHW-M420|SHW-M200|GT-S7562/.test(useragent) | ||
); | ||
@@ -220,0 +252,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
21
0
1
160
892598
43
10608
3
+ Added@egjs/axes@^2.0.0
+ Added@egjs/agent@2.4.4(transitive)
+ Added@egjs/axes@2.8.0(transitive)
+ Added@egjs/hammerjs@2.0.17(transitive)
+ Added@types/hammerjs@2.0.46(transitive)
- Removed@egjs/movablecoord@^2.0.0-rc.1
- Removed@egjs/movablecoord@2.0.0-rc.1(transitive)
- Removedhammerjs@2.0.8(transitive)
Updated@egjs/component@^2.0.0