@egjs/flicking 3.8.3 → 3.9.2-beta.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/declaration/Flicking.d.ts +2 -1
- package/declaration/components/AutoResizer.d.ts +12 -0
- package/declaration/types.d.ts +1 -0
- package/dist/flicking.esm.js +99 -23
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +99 -23
- 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 +99 -23
- 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/doc/eg.Flicking.html +102 -39
- package/doc/global.html +1 -1
- package/doc/index.html +1 -1
- package/doc/node_modules_@egjs_component_src_Component.ts.html +1 -1
- package/doc/src_Flicking.ts.html +13 -17
- package/doc/src_types.ts.html +2 -1
- package/docs/build/release/3.8.4/dist/flicking.esm.js +5055 -0
- package/docs/build/release/3.8.4/dist/flicking.esm.js.map +1 -0
- package/docs/build/release/3.8.4/dist/flicking.js +5062 -0
- package/docs/build/release/3.8.4/dist/flicking.js.map +1 -0
- package/docs/build/release/3.8.4/dist/flicking.min.js +10 -0
- package/docs/build/release/3.8.4/dist/flicking.min.js.map +1 -0
- package/docs/build/release/3.8.4/dist/flicking.pkgd.js +11391 -0
- package/docs/build/release/3.8.4/dist/flicking.pkgd.js.map +1 -0
- package/docs/build/release/3.8.4/dist/flicking.pkgd.min.js +10 -0
- package/docs/build/release/3.8.4/dist/flicking.pkgd.min.js.map +1 -0
- package/docs/build/release/3.9.0/dist/flicking.esm.js +5124 -0
- package/docs/build/release/3.9.0/dist/flicking.esm.js.map +1 -0
- package/docs/build/release/3.9.0/dist/flicking.js +5131 -0
- package/docs/build/release/3.9.0/dist/flicking.js.map +1 -0
- package/docs/build/release/3.9.0/dist/flicking.min.js +10 -0
- package/docs/build/release/3.9.0/dist/flicking.min.js.map +1 -0
- package/docs/build/release/3.9.0/dist/flicking.pkgd.js +11460 -0
- package/docs/build/release/3.9.0/dist/flicking.pkgd.js.map +1 -0
- package/docs/build/release/3.9.0/dist/flicking.pkgd.min.js +10 -0
- package/docs/build/release/3.9.0/dist/flicking.pkgd.min.js.map +1 -0
- package/docs/build/release/3.9.1/dist/flicking.esm.js +5124 -0
- package/docs/build/release/3.9.1/dist/flicking.esm.js.map +1 -0
- package/docs/build/release/3.9.1/dist/flicking.js +5131 -0
- package/docs/build/release/3.9.1/dist/flicking.js.map +1 -0
- package/docs/build/release/3.9.1/dist/flicking.min.js +10 -0
- package/docs/build/release/3.9.1/dist/flicking.min.js.map +1 -0
- package/docs/build/release/3.9.1/dist/flicking.pkgd.js +11460 -0
- package/docs/build/release/3.9.1/dist/flicking.pkgd.js.map +1 -0
- package/docs/build/release/3.9.1/dist/flicking.pkgd.min.js +10 -0
- package/docs/build/release/3.9.1/dist/flicking.pkgd.min.js.map +1 -0
- package/package.json +8 -12
- package/rollup.config.development.js +26 -0
- package/src/Flicking.ts +12 -16
- package/src/components/AutoResizer.ts +80 -0
- package/src/components/Viewport.ts +14 -6
- package/src/consts.ts +1 -0
- package/src/types.ts +1 -0
- package/src/utils.ts +1 -1
- package/tsconfig.test.json +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from "@egjs/component";
|
|
2
|
-
import { FlickingOptions, FlickingEvent, Direction, EventType, FlickingPanel, FlickingStatus, Plugin, ElementLike, DestroyOption, BeforeSyncResult, SyncResult, ChangeEvent, SelectEvent, NeedPanelEvent, VisibleChangeEvent, ContentErrorEvent } from "./types";
|
|
3
2
|
import { DiffResult } from "@egjs/list-differ";
|
|
3
|
+
import { FlickingOptions, FlickingEvent, Direction, EventType, FlickingPanel, FlickingStatus, Plugin, ElementLike, DestroyOption, BeforeSyncResult, SyncResult, ChangeEvent, SelectEvent, NeedPanelEvent, VisibleChangeEvent, ContentErrorEvent } from "./types";
|
|
4
4
|
declare class Flicking extends Component<{
|
|
5
5
|
holdStart: FlickingEvent;
|
|
6
6
|
holdEnd: FlickingEvent;
|
|
@@ -20,6 +20,7 @@ declare class Flicking extends Component<{
|
|
|
20
20
|
options: FlickingOptions;
|
|
21
21
|
private wrapper;
|
|
22
22
|
private viewport;
|
|
23
|
+
private autoResizer;
|
|
23
24
|
private contentsReadyChecker;
|
|
24
25
|
private eventContext;
|
|
25
26
|
private isPanelChangedAtBeforeSync;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Flicking from "../Flicking";
|
|
2
|
+
declare class AutoResizer {
|
|
3
|
+
private flicking;
|
|
4
|
+
private enabled;
|
|
5
|
+
private resizeObserver;
|
|
6
|
+
private skipFirstResize;
|
|
7
|
+
constructor(flicking: Flicking);
|
|
8
|
+
enable(): this;
|
|
9
|
+
disable(): this;
|
|
10
|
+
private onResize;
|
|
11
|
+
}
|
|
12
|
+
export default AutoResizer;
|
package/declaration/types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface FlickingOptions {
|
|
|
40
40
|
iOSEdgeSwipeThreshold: number;
|
|
41
41
|
resizeOnContentsReady: boolean;
|
|
42
42
|
collectStatistics: boolean;
|
|
43
|
+
useResizeObserver: boolean;
|
|
43
44
|
}
|
|
44
45
|
export declare type MoveTypeObjectOption = MoveTypeSnapOption | MoveTypeFreeScrollOption;
|
|
45
46
|
export declare type MoveTypeStringOption = MoveTypeObjectOption["type"];
|
package/dist/flicking.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ name: @egjs/flicking
|
|
|
4
4
|
license: MIT
|
|
5
5
|
author: NAVER Corp.
|
|
6
6
|
repository: https://github.com/naver/egjs-flicking
|
|
7
|
-
version: 3.
|
|
7
|
+
version: 3.9.2-beta.0
|
|
8
8
|
*/
|
|
9
9
|
import Component from '@egjs/component';
|
|
10
10
|
import ImReady from '@egjs/imready';
|
|
@@ -113,7 +113,8 @@ var DEFAULT_OPTIONS = {
|
|
|
113
113
|
renderExternal: false,
|
|
114
114
|
resizeOnContentsReady: false,
|
|
115
115
|
iOSEdgeSwipeThreshold: 30,
|
|
116
|
-
collectStatistics: true
|
|
116
|
+
collectStatistics: true,
|
|
117
|
+
useResizeObserver: true
|
|
117
118
|
};
|
|
118
119
|
var DEFAULT_VIEWPORT_CSS = {
|
|
119
120
|
position: "relative",
|
|
@@ -375,7 +376,7 @@ function findIndex(iterable, callback) {
|
|
|
375
376
|
for (var i = 0; i < iterable.length; i += 1) {
|
|
376
377
|
var element = iterable[i];
|
|
377
378
|
|
|
378
|
-
if (element && callback(element)) {
|
|
379
|
+
if (element != null && callback(element)) {
|
|
379
380
|
return i;
|
|
380
381
|
}
|
|
381
382
|
}
|
|
@@ -2512,7 +2513,12 @@ function () {
|
|
|
2512
2513
|
__proto.disable = function () {
|
|
2513
2514
|
if (this.panInput) {
|
|
2514
2515
|
this.panInput.destroy();
|
|
2515
|
-
this.panInput = null;
|
|
2516
|
+
this.panInput = null; // Refresh Axes instance
|
|
2517
|
+
|
|
2518
|
+
this.axes.destroy();
|
|
2519
|
+
this.setAxesInstance();
|
|
2520
|
+
this.updateScrollArea();
|
|
2521
|
+
this.updateAxesPosition(this.state.position);
|
|
2516
2522
|
this.stateMachine.transitTo(STATE_TYPE.IDLE);
|
|
2517
2523
|
}
|
|
2518
2524
|
};
|
|
@@ -3211,6 +3217,7 @@ function () {
|
|
|
3211
3217
|
this.applyCSSValue();
|
|
3212
3218
|
this.setMoveType();
|
|
3213
3219
|
this.setAxesInstance();
|
|
3220
|
+
this.createPanInput();
|
|
3214
3221
|
this.refreshPanels();
|
|
3215
3222
|
this.setDefaultPanel();
|
|
3216
3223
|
this.resize();
|
|
@@ -3322,7 +3329,6 @@ function () {
|
|
|
3322
3329
|
deceleration: options.deceleration,
|
|
3323
3330
|
interruptable: true
|
|
3324
3331
|
});
|
|
3325
|
-
this.createPanInput();
|
|
3326
3332
|
};
|
|
3327
3333
|
|
|
3328
3334
|
__proto.refreshPanels = function () {
|
|
@@ -3366,11 +3372,12 @@ function () {
|
|
|
3366
3372
|
var panels = panelManager.originalPanels();
|
|
3367
3373
|
var reversedPanels = panels.concat().reverse();
|
|
3368
3374
|
var sumOriginalPanelSize = lastPanel.getPosition() + lastPanel.getSize() - firstPanel.getPosition() + gap;
|
|
3375
|
+
if (sumOriginalPanelSize <= 0) return;
|
|
3369
3376
|
var relativeAnchorPosition = firstPanel.getRelativeAnchorPosition();
|
|
3370
3377
|
var relativeHangerPosition = this.getRelativeHangerPosition();
|
|
3371
3378
|
var areaPrev = (relativeHangerPosition - relativeAnchorPosition) % sumOriginalPanelSize;
|
|
3372
3379
|
var sizeSum = 0;
|
|
3373
|
-
var panelAtLeftBoundary;
|
|
3380
|
+
var panelAtLeftBoundary = null;
|
|
3374
3381
|
|
|
3375
3382
|
for (var _i = 0, reversedPanels_1 = reversedPanels; _i < reversedPanels_1.length; _i++) {
|
|
3376
3383
|
var panel = reversedPanels_1[_i];
|
|
@@ -3389,7 +3396,7 @@ function () {
|
|
|
3389
3396
|
|
|
3390
3397
|
var areaNext = (viewportSize - relativeHangerPosition + relativeAnchorPosition) % sumOriginalPanelSize;
|
|
3391
3398
|
sizeSum = 0;
|
|
3392
|
-
var panelAtRightBoundary;
|
|
3399
|
+
var panelAtRightBoundary = null;
|
|
3393
3400
|
|
|
3394
3401
|
for (var _a = 0, panels_1 = panels; _a < panels_1.length; _a++) {
|
|
3395
3402
|
var panel = panels_1[_a];
|
|
@@ -3407,7 +3414,7 @@ function () {
|
|
|
3407
3414
|
} // Need one more set of clones on prev area of original panel 0
|
|
3408
3415
|
|
|
3409
3416
|
|
|
3410
|
-
var needCloneOnPrev = panelAtLeftBoundary.getIndex() !== 0 && panelAtLeftBoundary.getIndex() <= panelAtRightBoundary.getIndex(); // Visible count of panel 0 on first screen
|
|
3417
|
+
var needCloneOnPrev = panelAtLeftBoundary && panelAtRightBoundary && panelAtLeftBoundary.getIndex() !== 0 && panelAtLeftBoundary.getIndex() <= panelAtRightBoundary.getIndex(); // Visible count of panel 0 on first screen
|
|
3411
3418
|
|
|
3412
3419
|
var panel0OnFirstscreen = Math.ceil((relativeHangerPosition + firstPanel.getSize() - relativeAnchorPosition) / sumOriginalPanelSize) + Math.ceil((viewportSize - relativeHangerPosition + relativeAnchorPosition) / sumOriginalPanelSize) - 1; // duplication
|
|
3413
3420
|
|
|
@@ -4039,6 +4046,77 @@ function () {
|
|
|
4039
4046
|
return Viewport;
|
|
4040
4047
|
}();
|
|
4041
4048
|
|
|
4049
|
+
var AutoResizer =
|
|
4050
|
+
/*#__PURE__*/
|
|
4051
|
+
function () {
|
|
4052
|
+
function AutoResizer(flicking) {
|
|
4053
|
+
var _this = this;
|
|
4054
|
+
|
|
4055
|
+
this.skipFirstResize = function () {
|
|
4056
|
+
var isFirstResize = true;
|
|
4057
|
+
return function () {
|
|
4058
|
+
if (isFirstResize) {
|
|
4059
|
+
isFirstResize = false;
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
_this.onResize();
|
|
4064
|
+
};
|
|
4065
|
+
}();
|
|
4066
|
+
|
|
4067
|
+
this.onResize = function () {
|
|
4068
|
+
_this.flicking.resize();
|
|
4069
|
+
};
|
|
4070
|
+
|
|
4071
|
+
this.flicking = flicking;
|
|
4072
|
+
this.enabled = false;
|
|
4073
|
+
this.resizeObserver = null;
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
var __proto = AutoResizer.prototype;
|
|
4077
|
+
|
|
4078
|
+
__proto.enable = function () {
|
|
4079
|
+
var flicking = this.flicking;
|
|
4080
|
+
|
|
4081
|
+
if (this.enabled) {
|
|
4082
|
+
this.disable();
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
if (flicking.options.useResizeObserver && !!window.ResizeObserver) {
|
|
4086
|
+
var flickingEl = flicking.getElement();
|
|
4087
|
+
var viewportSizeNot0 = flickingEl.clientWidth !== 0 || flickingEl.clientHeight !== 0;
|
|
4088
|
+
var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this.skipFirstResize) : new ResizeObserver(this.onResize);
|
|
4089
|
+
resizeObserver.observe(flickingEl);
|
|
4090
|
+
this.resizeObserver = resizeObserver;
|
|
4091
|
+
} else {
|
|
4092
|
+
window.addEventListener("resize", this.onResize);
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4095
|
+
this.enabled = true;
|
|
4096
|
+
return this;
|
|
4097
|
+
};
|
|
4098
|
+
|
|
4099
|
+
__proto.disable = function () {
|
|
4100
|
+
if (!this.enabled) {
|
|
4101
|
+
return this;
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
var resizeObserver = this.resizeObserver;
|
|
4105
|
+
|
|
4106
|
+
if (resizeObserver) {
|
|
4107
|
+
resizeObserver.disconnect();
|
|
4108
|
+
this.resizeObserver = null;
|
|
4109
|
+
} else {
|
|
4110
|
+
window.removeEventListener("resize", this.onResize);
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
this.enabled = false;
|
|
4114
|
+
return this;
|
|
4115
|
+
};
|
|
4116
|
+
|
|
4117
|
+
return AutoResizer;
|
|
4118
|
+
}();
|
|
4119
|
+
|
|
4042
4120
|
/**
|
|
4043
4121
|
* Copyright (c) 2015 NAVER Corp.
|
|
4044
4122
|
* egjs projects are licensed under the MIT license
|
|
@@ -4088,6 +4166,7 @@ function (_super) {
|
|
|
4088
4166
|
* @param {boolean} [options.isConstantSize=false] Whether all panels have a constant size that won't be changed after resize. Enabling this option can increase performance while recalculating panel size.<ko>모든 패널의 크기가 불변인지의 여부. 이 옵션을 'true'로 설정하면 패널 크기 재설정시에 성능을 높일 수 있다.</ko>
|
|
4089
4167
|
* @param {boolean} [options.renderExternal=false] Whether to use external rendering. It will delegate DOM manipulation and can synchronize the rendered state by calling `sync()` method. You can use this option to use in frameworks like React, Vue, Angular, which has its states and rendering methods.<ko>외부 렌더링을 사용할 지의 여부. 이 옵션을 사용시 렌더링을 외부에 위임할 수 있고, `sync()`를 호출하여 그 상태를 동기화할 수 있다. 이 옵션을 사용하여, React, Vue, Angular 등 자체적인 상태와 렌더링 방법을 갖는 프레임워크에 대응할 수 있다.</ko>
|
|
4090
4168
|
* @param {boolean} [options.resizeOnContentsReady=false] Whether to resize the Flicking after the image/video elements inside viewport are ready.<br/>Use this property to prevent wrong Flicking layout caused by dynamic image / video sizes.<ko>Flicking 내부의 이미지 / 비디오 엘리먼트들이 전부 로드되었을 때 Flicking의 크기를 재계산하기 위한 옵션.<br/>이미지 / 비디오 크기가 고정 크기가 아닐 경우 사용하여 레이아웃이 잘못되는 것을 방지할 수 있다.</ko>
|
|
4169
|
+
* @param {boolean} [options.useResizeObserver=true] Whether to listen {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}'s event instead of Window's {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} event when using the `autoResize` option<ko>autoResize 옵션 사용시 {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}의 이벤트를 Window객체의 {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} 이벤트 대신 수신할지 여부를 설정합니다</ko>
|
|
4091
4170
|
* @param {boolean} [options.collectStatistics=true] Whether to collect statistics on how you are using `Flicking`. These statistical data do not contain any personal information and are used only as a basis for the development of a user-friendly product.<ko>어떻게 `Flicking`을 사용하고 있는지에 대한 통계 수집 여부를 나타낸다. 이 통계자료는 개인정보를 포함하고 있지 않으며 오직 사용자 친화적인 제품으로 발전시키기 위한 근거자료로서 활용한다.</ko>
|
|
4092
4171
|
*/
|
|
4093
4172
|
|
|
@@ -4255,18 +4334,13 @@ function (_super) {
|
|
|
4255
4334
|
|
|
4256
4335
|
|
|
4257
4336
|
_this.viewport = new Viewport(_this, _this.options, _this.triggerEvent);
|
|
4337
|
+
_this.autoResizer = new AutoResizer(_this);
|
|
4258
4338
|
|
|
4259
4339
|
_this.listenInput();
|
|
4260
4340
|
|
|
4261
4341
|
_this.listenResize();
|
|
4262
4342
|
|
|
4263
|
-
return _this;
|
|
4264
|
-
// sendEvent(
|
|
4265
|
-
// "usage",
|
|
4266
|
-
// "options",
|
|
4267
|
-
// options,
|
|
4268
|
-
// );
|
|
4269
|
-
// }
|
|
4343
|
+
return _this;
|
|
4270
4344
|
}
|
|
4271
4345
|
/**
|
|
4272
4346
|
* Move to the previous panel if it exists.
|
|
@@ -4600,11 +4674,7 @@ function (_super) {
|
|
|
4600
4674
|
}
|
|
4601
4675
|
|
|
4602
4676
|
this.off();
|
|
4603
|
-
|
|
4604
|
-
if (this.options.autoResize) {
|
|
4605
|
-
window.removeEventListener("resize", this.resize);
|
|
4606
|
-
}
|
|
4607
|
-
|
|
4677
|
+
this.autoResizer.disable();
|
|
4608
4678
|
this.viewport.destroy(option);
|
|
4609
4679
|
(_a = this.contentsReadyChecker) === null || _a === void 0 ? void 0 : _a.destroy(); // release resources
|
|
4610
4680
|
|
|
@@ -4757,6 +4827,8 @@ function (_super) {
|
|
|
4757
4827
|
__proto.beforeSync = function (diffInfo) {
|
|
4758
4828
|
var _this = this;
|
|
4759
4829
|
|
|
4830
|
+
var _a;
|
|
4831
|
+
|
|
4760
4832
|
var maintained = diffInfo.maintained,
|
|
4761
4833
|
added = diffInfo.added,
|
|
4762
4834
|
changed = diffInfo.changed,
|
|
@@ -4848,8 +4920,12 @@ function (_super) {
|
|
|
4848
4920
|
}
|
|
4849
4921
|
|
|
4850
4922
|
panelManager.replacePanels(newPanels, newClones);
|
|
4923
|
+
var currentPanelIndex = (_a = currentPanel === null || currentPanel === void 0 ? void 0 : currentPanel.getIndex()) !== null && _a !== void 0 ? _a : -1;
|
|
4924
|
+
var currentPanelIsRemoved = findIndex(removed, function (index) {
|
|
4925
|
+
return index === currentPanelIndex;
|
|
4926
|
+
}) >= 0;
|
|
4851
4927
|
|
|
4852
|
-
if (!currentPanel && newPanels.length > 0) {
|
|
4928
|
+
if ((!currentPanel || currentPanelIsRemoved) && newPanels.length > 0) {
|
|
4853
4929
|
viewport.setCurrentPanel(newPanels[0]);
|
|
4854
4930
|
} else if (newPanels.length <= 0) {
|
|
4855
4931
|
viewport.setCurrentPanel(undefined);
|
|
@@ -4970,7 +5046,7 @@ function (_super) {
|
|
|
4970
5046
|
var options = this.options;
|
|
4971
5047
|
|
|
4972
5048
|
if (options.autoResize) {
|
|
4973
|
-
|
|
5049
|
+
this.autoResizer.enable();
|
|
4974
5050
|
}
|
|
4975
5051
|
|
|
4976
5052
|
if (options.resizeOnContentsReady) {
|
|
@@ -5010,7 +5086,7 @@ function (_super) {
|
|
|
5010
5086
|
*/
|
|
5011
5087
|
|
|
5012
5088
|
|
|
5013
|
-
Flicking.VERSION = "3.
|
|
5089
|
+
Flicking.VERSION = "3.9.2-beta.0";
|
|
5014
5090
|
/**
|
|
5015
5091
|
* Direction constant - "PREV" or "NEXT"
|
|
5016
5092
|
* @ko 방향 상수 - "PREV" 또는 "NEXT"
|