@@ -118,6 +118,8 @@ export interface FlickingOptions {
118118 | MoveTypeOptions < ValueOf < typeof MOVE_TYPE > > ;
119119 threshold : number ;
120120 dragThreshold : number ;
121+ animationThreshold : number ;
122+ useCSSOrder : boolean ;
121123 interruptable : boolean ;
122124 bounce : number | string | [ number | string , number | string ] ;
123125 iOSEdgeSwipeThreshold : number ;
@@ -200,6 +202,9 @@ class Flicking extends Component<FlickingEvents> {
200202 private _moveType : FlickingOptions [ "moveType" ] ;
201203 private _threshold : FlickingOptions [ "threshold" ] ;
202204 private _dragThreshold : FlickingOptions [ "dragThreshold" ] ;
205+ private _animationThreshold : FlickingOptions [ "animationThreshold" ] ;
206+ private _useCSSOrder : FlickingOptions [ "useCSSOrder" ] ;
207+
203208 private _interruptable : FlickingOptions [ "interruptable" ] ;
204209 private _bounce : FlickingOptions [ "bounce" ] ;
205210 private _iOSEdgeSwipeThreshold : FlickingOptions [ "iOSEdgeSwipeThreshold" ] ;
@@ -225,6 +230,7 @@ class Flicking extends Component<FlickingEvents> {
225230 private _initialized : boolean ;
226231 private _plugins : Plugin [ ] ;
227232 private _isResizing : boolean ;
233+ private _scheduleResize = false ;
228234
229235 // Components
230236 /**
@@ -703,6 +709,30 @@ class Flicking extends Component<FlickingEvents> {
703709 public get dragThreshold ( ) {
704710 return this . _dragThreshold ;
705711 }
712+ /**
713+ * The minimum distance for animation to proceed. If the distance to be moved is less than `animationThreshold`, the movement proceeds immediately without animation (duration: 0).
714+ * @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
715+ * @type {number }
716+ * @default 0.5
717+ * @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options ) }
718+ */
719+ public get animationThreshold ( ) {
720+ return this . _animationThreshold ;
721+ }
722+ /**
723+ * Using `useCSSOrder` does not change the DOM order, but the `order` CSS property changes the order on the screen. (When `circular` is used, the DOM order changes depending on the position.)
724+ * When using `iframe`, you can prevent reloading when the DOM order changes.
725+ * In svelte, CSS order is always used.
726+ * @ko `useCSSOrder`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다. (`circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다.)
727+ * `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
728+ * svelte에서는 css order를 무조건 사용한다.
729+ * @type {boolean }
730+ * @default false
731+ * @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrder useCSSOrder ( Options ) }
732+ */
733+ public get useCSSOrder ( ) {
734+ return this . _useCSSOrder ;
735+ }
706736
707737 /**
708738 * Set animation to be interruptable by click/touch.
@@ -1117,6 +1147,12 @@ class Flicking extends Component<FlickingEvents> {
11171147 panInput . options . threshold = val ;
11181148 }
11191149 }
1150+ public set animationThreshold ( val : FlickingOptions [ "animationThreshold" ] ) {
1151+ this . _animationThreshold = val ;
1152+ }
1153+ public set useCSSOrder ( val : FlickingOptions [ "useCSSOrder" ] ) {
1154+ this . _useCSSOrder = val ;
1155+ }
11201156
11211157 public set interruptable ( val : FlickingOptions [ "interruptable" ] ) {
11221158 this . _interruptable = val ;
@@ -1291,7 +1327,9 @@ class Flicking extends Component<FlickingEvents> {
12911327 useFractionalSize = false ,
12921328 externalRenderer = null ,
12931329 renderExternal = null ,
1294- optimizeSizeUpdate = false
1330+ optimizeSizeUpdate = false ,
1331+ animationThreshold = 0.5 ,
1332+ useCSSOrder = false ,
12951333 } : Partial < FlickingOptions > = { } ) {
12961334 super ( ) ;
12971335
@@ -1340,6 +1378,8 @@ class Flicking extends Component<FlickingEvents> {
13401378 this . _externalRenderer = externalRenderer ;
13411379 this . _renderExternal = renderExternal ;
13421380 this . _optimizeSizeUpdate = optimizeSizeUpdate ;
1381+ this . _animationThreshold = animationThreshold ;
1382+ this . _useCSSOrder = useCSSOrder ;
13431383
13441384 // Create core components
13451385 this . _viewport = new Viewport ( this , getElement ( root ) ) ;
@@ -1423,7 +1463,9 @@ class Flicking extends Component<FlickingEvents> {
14231463
14241464 this . _plugins . forEach ( ( plugin ) => plugin . destroy ( ) ) ;
14251465
1466+ this . _scheduleResize = false ;
14261467 this . _initialized = false ;
1468+ this . _isResizing = false ;
14271469 }
14281470
14291471 /**
@@ -1821,11 +1863,20 @@ class Flicking extends Component<FlickingEvents> {
18211863 * @method
18221864 * @fires Flicking#beforeResize
18231865 * @fires Flicking#afterResize
1824- * @return {this }
1866+ * @return {boolean }
18251867 */
18261868 public async resize ( ) : Promise < void > {
1827- if ( this . _isResizing ) return ;
1869+ if ( ! this . _initialized ) {
1870+ return ;
1871+ }
1872+ if ( this . _isResizing ) {
1873+ // resize를 연속으로 발생하면 무시하기에 마지막 viewport를 사이즈를 알 수 없음.
1874+ // resize를 1번 더 실행할 수 잇는 스케줄링 등록
1875+ this . _scheduleResize = true ;
1876+ return ;
1877+ }
18281878
1879+ this . _scheduleResize = false ;
18291880 this . _isResizing = true ;
18301881
18311882 const viewport = this . _viewport ;
@@ -1872,6 +1923,7 @@ class Flicking extends Component<FlickingEvents> {
18721923 camera . updatePanelOrder ( ) ;
18731924 camera . updateOffset ( ) ;
18741925 await renderer . render ( ) ;
1926+
18751927 if ( ! this . _initialized ) {
18761928 return ;
18771929 }
@@ -1901,6 +1953,12 @@ class Flicking extends Component<FlickingEvents> {
19011953 ) ;
19021954
19031955 this . _isResizing = false ;
1956+
1957+ // 연속으로 resize를 호출하는 경우를 대비하기 위해서 스케줄링 반영
1958+ if ( this . _scheduleResize ) {
1959+ this . resize ( ) ;
1960+ }
1961+ return ;
19041962 }
19051963
19061964 /**
@@ -2098,8 +2156,8 @@ class Flicking extends Component<FlickingEvents> {
20982156 const nearestAnchor = camera . findNearestAnchor ( defaultPanel . position ) ;
20992157 const initialPanel =
21002158 nearestAnchor &&
2101- defaultPanel . position !== nearestAnchor . panel . position &&
2102- defaultPanel . index !== nearestAnchor . panel . index
2159+ defaultPanel . position !== nearestAnchor . panel . position &&
2160+ defaultPanel . index !== nearestAnchor . panel . index
21032161 ? nearestAnchor . panel
21042162 : defaultPanel ;
21052163 control . setActive ( initialPanel , null , false ) ;
0 commit comments