@egjs/flicking 4.4.2 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TODO.md +3 -0
- package/declaration/Flicking.d.ts +15 -2
- package/declaration/camera/Camera.d.ts +28 -26
- package/declaration/camera/index.d.ts +2 -4
- package/declaration/camera/mode/BoundCameraMode.d.ts +13 -0
- package/declaration/camera/mode/CameraMode.d.ts +19 -0
- package/declaration/camera/mode/CircularCameraMode.d.ts +18 -0
- package/declaration/camera/mode/LinearCameraMode.d.ts +9 -0
- package/declaration/camera/mode/index.d.ts +6 -0
- package/declaration/const/external.d.ts +4 -0
- package/declaration/control/StrictControl.d.ts +1 -0
- package/declaration/core/AutoResizer.d.ts +3 -0
- package/declaration/core/ResizeWatcher.d.ts +33 -0
- package/declaration/renderer/Renderer.d.ts +13 -0
- package/declaration/type/external.d.ts +1 -3
- package/{css → dist/css}/flicking-inline.css +20 -13
- package/dist/css/flicking-inline.min.css +1 -0
- package/dist/css/flicking.css +44 -0
- package/dist/css/flicking.min.css +1 -0
- package/dist/flicking.esm.js +1491 -1251
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +1494 -1253
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +1466 -1225
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +17 -7
- package/sass/flicking-inline.sass +30 -0
- package/sass/flicking.sass +23 -0
- package/src/Flicking.ts +127 -35
- package/src/camera/Camera.ts +162 -81
- package/src/camera/index.ts +3 -7
- package/src/camera/{BoundCamera.ts → mode/BoundCameraMode.ts} +46 -43
- package/src/camera/mode/CameraMode.ts +77 -0
- package/src/camera/mode/CircularCameraMode.ts +171 -0
- package/src/camera/mode/LinearCameraMode.ts +23 -0
- package/src/camera/mode/index.ts +14 -0
- package/src/cfc/sync.ts +29 -23
- package/src/cfc/withFlickingMethods.ts +3 -2
- package/src/const/external.ts +12 -0
- package/src/control/StrictControl.ts +10 -0
- package/src/core/AutoResizer.ts +33 -0
- package/src/core/ResizeWatcher.ts +133 -0
- package/src/renderer/Renderer.ts +92 -43
- package/css/flicking.css +0 -28
- package/declaration/camera/BoundCamera.d.ts +0 -9
- package/declaration/camera/CircularCamera.d.ts +0 -37
- package/declaration/camera/LinearCamera.d.ts +0 -5
- package/dist/flicking-inline.css +0 -2
- package/dist/flicking-inline.css.map +0 -1
- package/dist/flicking.css +0 -2
- package/dist/flicking.css.map +0 -1
- package/src/camera/CircularCamera.ts +0 -268
- package/src/camera/LinearCamera.ts +0 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egjs/flicking",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
|
|
5
5
|
"main": "dist/flicking.js",
|
|
6
6
|
"module": "dist/flicking.esm.js",
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
"types": "declaration/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "concurrently \"rollup -w --config ./rollup.config.dev.js\" \"http-serve\"",
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "run-s build:bundle build:declaration build:css printsizes",
|
|
13
|
+
"build:bundle": "rm -rf ./dist && rollup -c",
|
|
14
|
+
"build:declaration": "rm -rf ./declaration && tsc -p tsconfig.declaration.json",
|
|
15
|
+
"build:css": "run-s build:css-clear build:sass build:css-prefix build:css-min",
|
|
16
|
+
"build:css-clear": "rm -rf ./dist/css",
|
|
17
|
+
"build:sass": "node-sass sass/ -o dist/css/ -x --output-style expanded",
|
|
18
|
+
"build:css-prefix": "postcss dist/css/*.css --replace --use autoprefixer --no-map",
|
|
19
|
+
"build:css-min": "postcss dist/css/*.css --ext .min.css --use postcss-clean -d dist/css/ --no-map",
|
|
13
20
|
"declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
|
|
14
21
|
"css": "postcss css/*.css --use autoprefixer postcss-clean -d dist/ -m",
|
|
15
22
|
"printsizes": "print-sizes ./dist --exclude=\\.map",
|
|
@@ -22,7 +29,7 @@
|
|
|
22
29
|
"jsdoc:watch": "npm-watch jsdoc",
|
|
23
30
|
"docs:build": "jsdoc-to-mdx -c ./jsdoc-to-mdx.json",
|
|
24
31
|
"docs:version": "node ./config/docs-version-up",
|
|
25
|
-
"docs:release": "npm run docs:build && npm run docs:version &&
|
|
32
|
+
"docs:release": "npm run docs:build && npm run docs:version && npm run build --prefix docs",
|
|
26
33
|
"demo:prebuild-version": "cpx 'dist/**/*' docs/build/release/$npm_package_version/dist --clean",
|
|
27
34
|
"demo:prebuild-latest": "cpx 'dist/**/*' docs/build/release/latest/dist --clean",
|
|
28
35
|
"demo:deploy": "npm run docs:release && npm run build && npm run demo:prebuild-version && npm run demo:prebuild-latest && gh-pages -d docs/build/ --add --remote upstream",
|
|
@@ -79,10 +86,11 @@
|
|
|
79
86
|
"@rollup/plugin-replace": "^2.4.1",
|
|
80
87
|
"@types/fs-extra": "^9.0.11",
|
|
81
88
|
"@types/node": "^14.14.35",
|
|
89
|
+
"@types/resize-observer-browser": "^0.1.6",
|
|
82
90
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
83
91
|
"@typescript-eslint/eslint-plugin-tslint": "^4.18.0",
|
|
84
92
|
"@typescript-eslint/parser": "^4.18.0",
|
|
85
|
-
"autoprefixer": "^9.8.
|
|
93
|
+
"autoprefixer": "^9.8.8",
|
|
86
94
|
"babel-loader": "^8.2.2",
|
|
87
95
|
"babel-preset-env": "^1.7.0",
|
|
88
96
|
"concurrently": "^6.0.0",
|
|
@@ -102,11 +110,13 @@
|
|
|
102
110
|
"husky": "^1.3.1",
|
|
103
111
|
"jsdoc-to-mdx": "^1.0.5",
|
|
104
112
|
"karma-typescript-es6-transform": "^5.5.2",
|
|
113
|
+
"node-sass": "^7.0.1",
|
|
114
|
+
"npm-run-all": "^4.1.5",
|
|
105
115
|
"postcss-clean": "^1.2.2",
|
|
106
|
-
"postcss-cli": "^7.1.
|
|
116
|
+
"postcss-cli": "^7.1.2",
|
|
107
117
|
"print-coveralls": "^1.2.2",
|
|
108
118
|
"print-sizes": "0.0.3",
|
|
109
|
-
"pvu": "^0.
|
|
119
|
+
"pvu": "^0.6.1",
|
|
110
120
|
"rollup": "^2.41.5",
|
|
111
121
|
"rollup-plugin-livereload": "^1.3.0",
|
|
112
122
|
"rollup-plugin-postcss": "^3.1.3",
|
|
@@ -121,7 +131,7 @@
|
|
|
121
131
|
"tslib": "^2.1.0",
|
|
122
132
|
"tslint": "^5.12.1",
|
|
123
133
|
"ttypescript": "^1.5.12",
|
|
124
|
-
"typescript": "^
|
|
134
|
+
"typescript": "^3.9.10",
|
|
125
135
|
"typescript-transform-paths": "^2.2.3"
|
|
126
136
|
},
|
|
127
137
|
"dependencies": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.flicking-viewport
|
|
2
|
+
position: relative
|
|
3
|
+
overflow: hidden
|
|
4
|
+
&:not(.vertical)
|
|
5
|
+
width: 100%
|
|
6
|
+
height: 100%
|
|
7
|
+
&.vertical,
|
|
8
|
+
&.vertical>.flicking-camera
|
|
9
|
+
display: inline-block
|
|
10
|
+
&.vertical
|
|
11
|
+
&.middle>.flicking-camera>*
|
|
12
|
+
vertical-align: middle
|
|
13
|
+
&.bottom>.flicking-camera>*
|
|
14
|
+
vertical-align: bottom
|
|
15
|
+
>.flicking-camera>*
|
|
16
|
+
display: block
|
|
17
|
+
&.flicking-hidden>.flicking-camera>*
|
|
18
|
+
visibility: hidden
|
|
19
|
+
|
|
20
|
+
.flicking-camera
|
|
21
|
+
width: 100%
|
|
22
|
+
height: 100%
|
|
23
|
+
position: relative
|
|
24
|
+
z-index: 1
|
|
25
|
+
white-space: nowrap
|
|
26
|
+
will-change: transform
|
|
27
|
+
>*
|
|
28
|
+
display: inline-block
|
|
29
|
+
white-space: normal
|
|
30
|
+
vertical-align: top
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.flicking-viewport
|
|
2
|
+
position: relative
|
|
3
|
+
overflow: hidden
|
|
4
|
+
&.vertical
|
|
5
|
+
display: inline-flex
|
|
6
|
+
>.flicking-camera
|
|
7
|
+
display: inline-flex
|
|
8
|
+
flex-direction: column
|
|
9
|
+
&.flicking-hidden
|
|
10
|
+
>.flicking-camera
|
|
11
|
+
>*
|
|
12
|
+
visibility: hidden
|
|
13
|
+
|
|
14
|
+
.flicking-camera
|
|
15
|
+
width: 100%
|
|
16
|
+
height: 100%
|
|
17
|
+
display: flex
|
|
18
|
+
position: relative
|
|
19
|
+
flex-direction: row
|
|
20
|
+
z-index: 1
|
|
21
|
+
will-change: transform
|
|
22
|
+
>*
|
|
23
|
+
flex-shrink: 0
|
package/src/Flicking.ts
CHANGED
|
@@ -11,9 +11,9 @@ import { Panel } from "./core/panel";
|
|
|
11
11
|
import { VanillaElementProvider } from "./core/panel/provider";
|
|
12
12
|
import VirtualManager, { VirtualOptions } from "./core/VirtualManager";
|
|
13
13
|
import { Control, SnapControl, SnapControlOptions, FreeControl, StrictControl, FreeControlOptions, StrictControlOptions } from "./control";
|
|
14
|
-
import {
|
|
14
|
+
import { Camera } from "./camera";
|
|
15
15
|
import { Renderer, VanillaRenderer, ExternalRenderer, RendererOptions, NormalRenderingStrategy, VirtualRenderingStrategy } from "./renderer";
|
|
16
|
-
import { EVENTS, ALIGN, MOVE_TYPE, DIRECTION } from "./const/external";
|
|
16
|
+
import { EVENTS, ALIGN, MOVE_TYPE, DIRECTION, CIRCULAR_FALLBACK } from "./const/external";
|
|
17
17
|
import * as ERROR from "./const/error";
|
|
18
18
|
import { findIndex, getElement, includes, parseElement } from "./utils";
|
|
19
19
|
import { HoldStartEvent, HoldEndEvent, MoveStartEvent, SelectEvent, MoveEvent, MoveEndEvent, WillChangeEvent, WillRestoreEvent, NeedPanelEvent, VisibleChangeEvent, ReachEdgeEvent, ReadyEvent, AfterResizeEvent, BeforeResizeEvent, ChangedEvent, RestoredEvent, PanelChangeEvent } from "./type/event";
|
|
@@ -52,18 +52,22 @@ export interface FlickingOptions {
|
|
|
52
52
|
defaultIndex: number;
|
|
53
53
|
horizontal: boolean;
|
|
54
54
|
circular: boolean;
|
|
55
|
+
circularFallback: LiteralUnion<ValueOf<typeof CIRCULAR_FALLBACK>>;
|
|
55
56
|
bound: boolean;
|
|
56
57
|
adaptive: boolean;
|
|
57
58
|
panelsPerView: number;
|
|
58
59
|
noPanelStyleOverride: boolean;
|
|
59
60
|
resizeOnContentsReady: boolean;
|
|
61
|
+
|
|
60
62
|
// EVENT
|
|
61
63
|
needPanelThreshold: number;
|
|
62
64
|
preventEventsBeforeInit: boolean;
|
|
65
|
+
|
|
63
66
|
// ANIMATION
|
|
64
67
|
deceleration: number;
|
|
65
68
|
duration: number;
|
|
66
69
|
easing: (x: number) => number;
|
|
70
|
+
|
|
67
71
|
// INPUT
|
|
68
72
|
inputType: string[];
|
|
69
73
|
moveType: ValueOf<typeof MOVE_TYPE> | MoveTypeOptions<ValueOf<typeof MOVE_TYPE>>;
|
|
@@ -73,14 +77,19 @@ export interface FlickingOptions {
|
|
|
73
77
|
iOSEdgeSwipeThreshold: number;
|
|
74
78
|
preventClickOnDrag: boolean;
|
|
75
79
|
disableOnInit: boolean;
|
|
80
|
+
|
|
76
81
|
// PERFORMANCE
|
|
77
82
|
renderOnlyVisible: boolean;
|
|
78
83
|
virtual: VirtualOptions | null;
|
|
84
|
+
|
|
79
85
|
// OTHERS
|
|
80
86
|
autoInit: boolean;
|
|
81
87
|
autoResize: boolean;
|
|
82
88
|
useResizeObserver: boolean;
|
|
89
|
+
resizeDebounce: number;
|
|
90
|
+
maxResizeDebounce: number;
|
|
83
91
|
externalRenderer: ExternalRenderer | null;
|
|
92
|
+
|
|
84
93
|
// @deprecated
|
|
85
94
|
renderExternal: {
|
|
86
95
|
renderer: new (options: RendererOptions) => ExternalRenderer;
|
|
@@ -120,6 +129,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
120
129
|
private _defaultIndex: FlickingOptions["defaultIndex"];
|
|
121
130
|
private _horizontal: FlickingOptions["horizontal"];
|
|
122
131
|
private _circular: FlickingOptions["circular"];
|
|
132
|
+
private _circularFallback: FlickingOptions["circularFallback"];
|
|
123
133
|
private _bound: FlickingOptions["bound"];
|
|
124
134
|
private _adaptive: FlickingOptions["adaptive"];
|
|
125
135
|
private _panelsPerView: FlickingOptions["panelsPerView"];
|
|
@@ -148,6 +158,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
148
158
|
private _autoInit: FlickingOptions["autoInit"];
|
|
149
159
|
private _autoResize: FlickingOptions["autoResize"];
|
|
150
160
|
private _useResizeObserver: FlickingOptions["useResizeObserver"];
|
|
161
|
+
private _resizeDebounce: FlickingOptions["resizeDebounce"];
|
|
162
|
+
private _maxResizeDebounce: FlickingOptions["maxResizeDebounce"];
|
|
151
163
|
private _externalRenderer: FlickingOptions["externalRenderer"];
|
|
152
164
|
private _renderExternal: FlickingOptions["renderExternal"];
|
|
153
165
|
|
|
@@ -218,7 +230,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
218
230
|
* @default false
|
|
219
231
|
* @readonly
|
|
220
232
|
*/
|
|
221
|
-
public get circularEnabled() { return this._camera.
|
|
233
|
+
public get circularEnabled() { return this._camera.circularEnabled; }
|
|
222
234
|
/**
|
|
223
235
|
* Whether the `virtual` option is enabled.
|
|
224
236
|
* The {@link Flicking#virtual virtual} option can't be enabled when {@link Flicking#panelsPerView panelsPerView} is less or equal than zero.
|
|
@@ -348,6 +360,18 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
348
360
|
* @default false
|
|
349
361
|
*/
|
|
350
362
|
public get circular() { return this._circular; }
|
|
363
|
+
/**
|
|
364
|
+
* Set panel control mode for the case when circular cannot be enabled.
|
|
365
|
+
* "linear" will set the view's range from the top of the first panel to the top of the last panel.
|
|
366
|
+
* "bound" will prevent the view from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel.
|
|
367
|
+
* @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
|
|
368
|
+
* "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
|
|
369
|
+
* "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
|
|
370
|
+
* @see CIRCULAR_FALLBACK
|
|
371
|
+
* @type {string}
|
|
372
|
+
* @default "linear"
|
|
373
|
+
*/
|
|
374
|
+
public get circularFallback() { return this._circularFallback; }
|
|
351
375
|
/**
|
|
352
376
|
* Prevent the view(camera element) from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel
|
|
353
377
|
* Only can be enabled when `circular=false`
|
|
@@ -599,6 +623,26 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
599
623
|
* @default true
|
|
600
624
|
*/
|
|
601
625
|
public get useResizeObserver() { return this._useResizeObserver; }
|
|
626
|
+
/**
|
|
627
|
+
* Delays size recalculation from `autoResize` by the given time in milisecond.
|
|
628
|
+
* If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
|
|
629
|
+
* This can increase performance by preventing `resize` being called too often.
|
|
630
|
+
* @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
|
|
631
|
+
* 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
|
|
632
|
+
* 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
|
|
633
|
+
* @type {number}
|
|
634
|
+
* @default 0
|
|
635
|
+
*/
|
|
636
|
+
public get resizeDebounce() { return this._resizeDebounce; }
|
|
637
|
+
/**
|
|
638
|
+
* The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
|
|
639
|
+
* This guarantees that size recalculation is performed at least once every (n)ms.
|
|
640
|
+
* @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
|
|
641
|
+
* 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
|
|
642
|
+
* @type {number}
|
|
643
|
+
* @default 100
|
|
644
|
+
*/
|
|
645
|
+
public get maxResizeDebounce() { return this._maxResizeDebounce; }
|
|
602
646
|
/**
|
|
603
647
|
* This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
|
|
604
648
|
* @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
|
|
@@ -718,6 +762,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
718
762
|
defaultIndex = 0,
|
|
719
763
|
horizontal = true,
|
|
720
764
|
circular = false,
|
|
765
|
+
circularFallback = CIRCULAR_FALLBACK.LINEAR,
|
|
721
766
|
bound = false,
|
|
722
767
|
adaptive = false,
|
|
723
768
|
panelsPerView = -1,
|
|
@@ -741,6 +786,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
741
786
|
autoInit = true,
|
|
742
787
|
autoResize = true,
|
|
743
788
|
useResizeObserver = true,
|
|
789
|
+
resizeDebounce = 0,
|
|
790
|
+
maxResizeDebounce = 100,
|
|
744
791
|
externalRenderer = null,
|
|
745
792
|
renderExternal = null
|
|
746
793
|
}: Partial<FlickingOptions> = {}) {
|
|
@@ -755,6 +802,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
755
802
|
this._defaultIndex = defaultIndex;
|
|
756
803
|
this._horizontal = horizontal;
|
|
757
804
|
this._circular = circular;
|
|
805
|
+
this._circularFallback = circularFallback;
|
|
758
806
|
this._bound = bound;
|
|
759
807
|
this._adaptive = adaptive;
|
|
760
808
|
this._panelsPerView = panelsPerView;
|
|
@@ -778,6 +826,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
778
826
|
this._autoInit = autoInit;
|
|
779
827
|
this._autoResize = autoResize;
|
|
780
828
|
this._useResizeObserver = useResizeObserver;
|
|
829
|
+
this._resizeDebounce = resizeDebounce;
|
|
830
|
+
this._maxResizeDebounce = maxResizeDebounce;
|
|
781
831
|
this._externalRenderer = externalRenderer;
|
|
782
832
|
this._renderExternal = renderExternal;
|
|
783
833
|
|
|
@@ -800,10 +850,10 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
800
850
|
* @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
|
|
801
851
|
* 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
|
|
802
852
|
* @fires Flicking#ready
|
|
803
|
-
* @return {
|
|
853
|
+
* @return {Promise<void>}
|
|
804
854
|
*/
|
|
805
|
-
public
|
|
806
|
-
if (this._initialized) return;
|
|
855
|
+
public init(): Promise<void> {
|
|
856
|
+
if (this._initialized) return Promise.resolve();
|
|
807
857
|
|
|
808
858
|
const camera = this._camera;
|
|
809
859
|
const renderer = this._renderer;
|
|
@@ -812,7 +862,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
812
862
|
const originalTrigger = this.trigger;
|
|
813
863
|
const preventEventsBeforeInit = this._preventEventsBeforeInit;
|
|
814
864
|
|
|
815
|
-
camera.init(
|
|
865
|
+
camera.init();
|
|
816
866
|
virtualManager.init();
|
|
817
867
|
renderer.init(this);
|
|
818
868
|
control.init(this);
|
|
@@ -821,10 +871,10 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
821
871
|
this.trigger = () => this;
|
|
822
872
|
}
|
|
823
873
|
|
|
824
|
-
|
|
874
|
+
this._initialResize();
|
|
825
875
|
|
|
826
876
|
// Look at initial panel
|
|
827
|
-
|
|
877
|
+
this._moveToInitialPanel();
|
|
828
878
|
|
|
829
879
|
if (this._autoResize) {
|
|
830
880
|
this._autoResizer.enable();
|
|
@@ -837,16 +887,15 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
837
887
|
}
|
|
838
888
|
renderer.checkPanelContentsReady(renderer.panels);
|
|
839
889
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
return;
|
|
890
|
+
return renderer.render().then(() => {
|
|
891
|
+
// Done initializing & emit ready event
|
|
892
|
+
this._plugins.forEach(plugin => plugin.init(this));
|
|
893
|
+
this._initialized = true;
|
|
894
|
+
if (preventEventsBeforeInit) {
|
|
895
|
+
this.trigger = originalTrigger;
|
|
896
|
+
}
|
|
897
|
+
this.trigger(new ComponentEvent(EVENTS.READY));
|
|
898
|
+
});
|
|
850
899
|
}
|
|
851
900
|
|
|
852
901
|
/**
|
|
@@ -1358,19 +1407,14 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1358
1407
|
}
|
|
1359
1408
|
|
|
1360
1409
|
private _createCamera(): Camera {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
if (this._bound) {
|
|
1365
|
-
// eslint-disable-next-line no-console
|
|
1366
|
-
console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
|
|
1367
|
-
}
|
|
1368
|
-
return new CircularCamera(cameraOption);
|
|
1369
|
-
} else if (this._bound) {
|
|
1370
|
-
return new BoundCamera(cameraOption);
|
|
1371
|
-
} else {
|
|
1372
|
-
return new LinearCamera(cameraOption);
|
|
1410
|
+
if (this._circular && this._bound) {
|
|
1411
|
+
// eslint-disable-next-line no-console
|
|
1412
|
+
console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
|
|
1373
1413
|
}
|
|
1414
|
+
|
|
1415
|
+
return new Camera(this, {
|
|
1416
|
+
align: this._align
|
|
1417
|
+
});
|
|
1374
1418
|
}
|
|
1375
1419
|
|
|
1376
1420
|
private _createRenderer(): Renderer {
|
|
@@ -1409,18 +1453,66 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1409
1453
|
});
|
|
1410
1454
|
}
|
|
1411
1455
|
|
|
1412
|
-
private
|
|
1456
|
+
private _moveToInitialPanel(): void {
|
|
1413
1457
|
const renderer = this._renderer;
|
|
1414
1458
|
const control = this._control;
|
|
1459
|
+
const camera = this._camera;
|
|
1415
1460
|
const initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
|
|
1416
1461
|
|
|
1417
1462
|
if (!initialPanel) return;
|
|
1418
1463
|
|
|
1464
|
+
const nearestAnchor = camera.findNearestAnchor(initialPanel.position);
|
|
1419
1465
|
control.setActive(initialPanel, null, false);
|
|
1420
1466
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
}
|
|
1467
|
+
if (!nearestAnchor) {
|
|
1468
|
+
throw new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), ERROR.CODE.POSITION_NOT_REACHABLE);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
let position = initialPanel.position;
|
|
1472
|
+
|
|
1473
|
+
if (!camera.canReach(initialPanel)) {
|
|
1474
|
+
position = nearestAnchor.position;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
camera.lookAt(position);
|
|
1478
|
+
control.updateInput();
|
|
1479
|
+
camera.updateOffset();
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
private _initialResize() {
|
|
1483
|
+
const viewport = this._viewport;
|
|
1484
|
+
const renderer = this._renderer;
|
|
1485
|
+
const camera = this._camera;
|
|
1486
|
+
const control = this._control;
|
|
1487
|
+
|
|
1488
|
+
this.trigger(new ComponentEvent(EVENTS.BEFORE_RESIZE, {
|
|
1489
|
+
width: 0,
|
|
1490
|
+
height: 0,
|
|
1491
|
+
element: viewport.element
|
|
1492
|
+
}));
|
|
1493
|
+
|
|
1494
|
+
viewport.resize();
|
|
1495
|
+
renderer.updatePanelSize();
|
|
1496
|
+
camera.updateAlignPos();
|
|
1497
|
+
camera.updateRange();
|
|
1498
|
+
camera.updateAnchors();
|
|
1499
|
+
camera.updateOffset();
|
|
1500
|
+
control.updateInput();
|
|
1501
|
+
|
|
1502
|
+
const newWidth = viewport.width;
|
|
1503
|
+
const newHeight = viewport.height;
|
|
1504
|
+
const sizeChanged = newWidth !== 0 || newHeight !== 0;
|
|
1505
|
+
|
|
1506
|
+
this.trigger(new ComponentEvent(EVENTS.AFTER_RESIZE, {
|
|
1507
|
+
width: viewport.width,
|
|
1508
|
+
height: viewport.height,
|
|
1509
|
+
prev: {
|
|
1510
|
+
width: 0,
|
|
1511
|
+
height: 0
|
|
1512
|
+
},
|
|
1513
|
+
sizeChanged,
|
|
1514
|
+
element: viewport.element
|
|
1515
|
+
}));
|
|
1424
1516
|
}
|
|
1425
1517
|
}
|
|
1426
1518
|
|