@egjs/flicking 4.10.1 → 4.10.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.10.1",
3
+ "version": "4.10.3",
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",
@@ -141,7 +141,7 @@
141
141
  "dependencies": {
142
142
  "@egjs/axes": "^3.8.1",
143
143
  "@egjs/component": "^3.0.1",
144
- "@egjs/imready": "^1.1.3",
144
+ "@egjs/imready": "^1.3.1",
145
145
  "@egjs/list-differ": "^1.0.0"
146
146
  },
147
147
  "husky": {
package/src/Flicking.ts CHANGED
@@ -702,31 +702,132 @@ class Flicking extends Component<FlickingEvents> {
702
702
  this._align = val;
703
703
  this._renderer.align = val;
704
704
  this._camera.align = val;
705
+ void this.resize();
705
706
  }
706
707
 
707
708
  public set defaultIndex(val: FlickingOptions["defaultIndex"]) { this._defaultIndex = val; }
708
- public set horizontal(val: FlickingOptions["horizontal"]) { this._horizontal = val; }
709
- public set circular(val: FlickingOptions["circular"]) { this._circular = val; }
710
- public set bound(val: FlickingOptions["bound"]) { this._bound = val; }
711
- public set adaptive(val: FlickingOptions["adaptive"]) { this._adaptive = val; }
712
- public set panelsPerView(val: FlickingOptions["panelsPerView"]) { this._panelsPerView = val; }
713
- public set noPanelStyleOverride(val: FlickingOptions["noPanelStyleOverride"]) { this._noPanelStyleOverride = val; }
714
- public set resizeOnContentsReady(val: FlickingOptions["resizeOnContentsReady"]) { this._resizeOnContentsReady = val; }
715
- public set nested(val: FlickingOptions["nested"]) { this._nested = val; }
709
+ public set horizontal(val: FlickingOptions["horizontal"]) {
710
+ this._horizontal = val;
711
+ this._control.controller.updateDirection();
712
+ void this.resize();
713
+ }
714
+
715
+ public set circular(val: FlickingOptions["circular"]) {
716
+ this._circular = val;
717
+ void this.resize();
718
+ }
719
+
720
+ public set bound(val: FlickingOptions["bound"]) {
721
+ this._bound = val;
722
+ void this.resize();
723
+ }
724
+
725
+ public set adaptive(val: FlickingOptions["adaptive"]) {
726
+ this._adaptive = val;
727
+ void this.resize();
728
+ }
729
+
730
+ public set panelsPerView(val: FlickingOptions["panelsPerView"]) {
731
+ this._panelsPerView = val;
732
+ void this.resize();
733
+ }
734
+
735
+ public set noPanelStyleOverride(val: FlickingOptions["noPanelStyleOverride"]) {
736
+ this._noPanelStyleOverride = val;
737
+ void this.resize();
738
+ }
739
+
740
+ public set resizeOnContentsReady(val: FlickingOptions["resizeOnContentsReady"]) {
741
+ this._resizeOnContentsReady = val;
742
+ if (val) {
743
+ this._renderer.checkPanelContentsReady(this._renderer.panels);
744
+ }
745
+ }
746
+
747
+ public set nested(val: FlickingOptions["nested"]) {
748
+ this._nested = val;
749
+ const axes = this._control.controller.axes;
750
+
751
+ if (axes) {
752
+ axes.options.nested = val;
753
+ }
754
+ }
755
+
716
756
  // EVENTS
717
757
  public set needPanelThreshold(val: FlickingOptions["needPanelThreshold"]) { this._needPanelThreshold = val; }
718
758
  public set preventEventsBeforeInit(val: FlickingOptions["preventEventsBeforeInit"]) { this._preventEventsBeforeInit = val; }
719
759
  // ANIMATION
720
- public set deceleration(val: FlickingOptions["deceleration"]) { this._deceleration = val; }
721
- public set easing(val: FlickingOptions["easing"]) { this._easing = val; }
760
+ public set deceleration(val: FlickingOptions["deceleration"]) {
761
+ this._deceleration = val;
762
+ const axes = this._control.controller.axes;
763
+
764
+ if (axes) {
765
+ axes.options.deceleration = val;
766
+ }
767
+ }
768
+
769
+ public set easing(val: FlickingOptions["easing"]) {
770
+ this._easing = val;
771
+ const axes = this._control.controller.axes;
772
+
773
+ if (axes) {
774
+ axes.options.easing = val;
775
+ }
776
+ }
777
+
722
778
  public set duration(val: FlickingOptions["duration"]) { this._duration = val; }
723
779
  // INPUT
724
- public set inputType(val: FlickingOptions["inputType"]) { this._inputType = val; }
725
- public set moveType(val: FlickingOptions["moveType"]) { this._moveType = val; }
780
+ public set inputType(val: FlickingOptions["inputType"]) {
781
+ this._inputType = val;
782
+ const panInput = this._control.controller.panInput;
783
+
784
+ if (panInput) {
785
+ panInput.options.inputType = val;
786
+ }
787
+ }
788
+
789
+ public set moveType(val: FlickingOptions["moveType"]) {
790
+ this._moveType = val;
791
+
792
+ const prevControl = this._control;
793
+ const newControl = this._createControl();
794
+ const activePanel = prevControl.activePanel;
795
+ newControl.copy(prevControl);
796
+
797
+ const prevProgressInPanel = activePanel
798
+ ? this._camera.getProgressInPanel(activePanel)
799
+ : 0;
800
+
801
+ this._control = newControl;
802
+ this._control.updatePosition(prevProgressInPanel);
803
+ this._control.updateInput();
804
+ }
805
+
726
806
  public set threshold(val: FlickingOptions["threshold"]) { this._threshold = val; }
727
- public set interruptable(val: FlickingOptions["interruptable"]) { this._interruptable = val; }
728
- public set bounce(val: FlickingOptions["bounce"]) { this._bounce = val; }
729
- public set iOSEdgeSwipeThreshold(val: FlickingOptions["iOSEdgeSwipeThreshold"]) { this._iOSEdgeSwipeThreshold = val; }
807
+ public set interruptable(val: FlickingOptions["interruptable"]) {
808
+ this._interruptable = val;
809
+
810
+ const axes = this._control.controller.axes;
811
+
812
+ if (axes) {
813
+ axes.options.interruptable = val;
814
+ }
815
+ }
816
+
817
+ public set bounce(val: FlickingOptions["bounce"]) {
818
+ this._bounce = val;
819
+ this._control.updateInput();
820
+ }
821
+
822
+ public set iOSEdgeSwipeThreshold(val: FlickingOptions["iOSEdgeSwipeThreshold"]) {
823
+ this._iOSEdgeSwipeThreshold = val;
824
+ const panInput = this._control.controller.panInput;
825
+
826
+ if (panInput) {
827
+ panInput.options.iOSEdgeSwipeThreshold = val;
828
+ }
829
+ }
830
+
730
831
  public set preventClickOnDrag(val: FlickingOptions["preventClickOnDrag"]) {
731
832
  const prevVal = this._preventClickOnDrag;
732
833
 
@@ -746,7 +847,11 @@ class Flicking extends Component<FlickingEvents> {
746
847
  public set disableOnInit(val: FlickingOptions["disableOnInit"]) { this._disableOnInit = val; }
747
848
  public set changeOnHold(val: FlickingOptions["changeOnHold"]) { this._changeOnHold = val; }
748
849
  // PERFORMANCE
749
- public set renderOnlyVisible(val: FlickingOptions["renderOnlyVisible"]) { this._renderOnlyVisible = val; }
850
+ public set renderOnlyVisible(val: FlickingOptions["renderOnlyVisible"]) {
851
+ this._renderOnlyVisible = val;
852
+ void this._renderer.render();
853
+ }
854
+
750
855
  // OTHERS
751
856
  public set autoResize(val: FlickingOptions["autoResize"]) {
752
857
  this._autoResize = val;
@@ -450,9 +450,7 @@ class Camera {
450
450
  this._updateMode();
451
451
  this._range = this._mode.getRange();
452
452
 
453
- if (this._circularEnabled) {
454
- panels.forEach(panel => panel.updateCircularToggleDirection());
455
- }
453
+ panels.forEach(panel => panel.updateCircularToggleDirection());
456
454
 
457
455
  return this;
458
456
  }
@@ -705,6 +703,7 @@ class Camera {
705
703
  this._mode = flicking.bound
706
704
  ? new BoundCameraMode(flicking)
707
705
  : new LinearCameraMode(flicking);
706
+ this._circularEnabled = false;
708
707
  }
709
708
  }
710
709
 
@@ -28,13 +28,21 @@ class AxesController {
28
28
  private _dragged: boolean;
29
29
 
30
30
  /**
31
- * An {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
32
- * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes}의 인스턴스
33
- * @type {Axes}
34
- * @see https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html
31
+ * An {@link https://naver.github.io/egjs-axes/docs/api/Axes Axes} instance
32
+ * @ko {@link https://naver.github.io/egjs-axes/docs/api/Axes Axes}의 인스턴스
33
+ * @type {Axes | null}
34
+ * @see https://naver.github.io/egjs-axes/docs/api/Axes
35
35
  * @readonly
36
36
  */
37
37
  public get axes() { return this._axes; }
38
+ /**
39
+ * An {@link https://naver.github.io/egjs-axes/docs/api/PanInput PanInput} instance
40
+ * @ko {@link https://naver.github.io/egjs-axes/docs/api/PanInput PanInput}의 인스턴스
41
+ * @type {PanInput | null}
42
+ * @see https://naver.github.io/egjs-axes/docs/api/PanInput
43
+ * @readonly
44
+ */
45
+ public get panInput() { return this._panInput; }
38
46
  /**
39
47
  * @internal
40
48
  */
@@ -401,6 +409,17 @@ class AxesController {
401
409
  }
402
410
  }
403
411
 
412
+ public updateDirection() {
413
+ const flicking = getFlickingAttached(this._flicking);
414
+ const axes = this._axes!;
415
+ const panInput = this._panInput!;
416
+
417
+ axes.disconnect(panInput);
418
+ axes.connect(flicking.horizontal ? [AXES.POSITION_KEY, ""] : ["", AXES.POSITION_KEY], panInput);
419
+
420
+ panInput.options.scale = flicking.horizontal ? [-1, 0] : [0, -1];
421
+ }
422
+
404
423
  private _resetInternalValues() {
405
424
  this._flicking = null;
406
425
  this._axes = null;
@@ -336,6 +336,15 @@ abstract class Control {
336
336
  }
337
337
  }
338
338
 
339
+ /**
340
+ * @internal
341
+ */
342
+ public copy(control: Control) {
343
+ this._flicking = control._flicking;
344
+ this._activePanel = control._activePanel;
345
+ this._controller = control._controller;
346
+ }
347
+
339
348
  protected _triggerIndexChangeEvent(panel: Panel, position: number, axesEvent?: OnRelease) {
340
349
  const flicking = getFlickingAttached(this._flicking);
341
350
  const triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
@@ -254,7 +254,10 @@ class Panel {
254
254
  public get align() { return this._align; }
255
255
 
256
256
  // Options Setter
257
- public set align(val: PanelOptions["align"]) { this._align = val; }
257
+ public set align(val: PanelOptions["align"]) {
258
+ this._align = val;
259
+ this._updateAlignPos();
260
+ }
258
261
 
259
262
  /**
260
263
  * @param {object} options An options object<ko>옵션 오브젝트</ko>
@@ -569,6 +572,7 @@ class Panel {
569
572
 
570
573
  if (!flicking.circularEnabled) {
571
574
  this._toggleDirection = DIRECTION.NONE;
575
+ this._togglePosition = 0;
572
576
  this._toggled = false;
573
577
  return this;
574
578
  }