@egjs/flicking-plugins 4.1.0 → 4.2.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/declaration/Sync.d.ts +37 -0
- package/declaration/const.d.ts +6 -0
- package/declaration/index.d.ts +3 -1
- package/dist/plugins.esm.js +276 -9
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +276 -7
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +2 -2
- package/dist/plugins.min.js.map +1 -1
- package/package.json +4 -3
- package/src/Sync.ts +236 -0
- package/src/const.ts +7 -0
- package/src/index.ts +8 -1
- package/src/pagination/renderer/ScrollBulletRenderer.ts +17 -6
package/dist/plugins.js
CHANGED
|
@@ -4,7 +4,7 @@ name: @egjs/flicking-plugins
|
|
|
4
4
|
license: MIT
|
|
5
5
|
author: NAVER Corp.
|
|
6
6
|
repository: https://github.com/naver/egjs-flicking-plugins
|
|
7
|
-
version: 4.
|
|
7
|
+
version: 4.2.3
|
|
8
8
|
*/
|
|
9
9
|
(function (global, factory) {
|
|
10
10
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@egjs/flicking')) :
|
|
@@ -402,6 +402,12 @@ version: 4.1.0
|
|
|
402
402
|
SCROLL: "scroll"
|
|
403
403
|
}
|
|
404
404
|
};
|
|
405
|
+
var SYNC = {
|
|
406
|
+
TYPE: {
|
|
407
|
+
CAMERA: "camera",
|
|
408
|
+
INDEX: "index"
|
|
409
|
+
}
|
|
410
|
+
};
|
|
405
411
|
|
|
406
412
|
var addClass = function (el, className) {
|
|
407
413
|
if (el.classList) {
|
|
@@ -694,6 +700,255 @@ version: 4.1.0
|
|
|
694
700
|
return Arrow;
|
|
695
701
|
}();
|
|
696
702
|
|
|
703
|
+
/**
|
|
704
|
+
* Plugin for synchronizing multiple flickings
|
|
705
|
+
* @ko 다양한 형태로 Flicking들이 같이 움직이게 할 수 있습니다.
|
|
706
|
+
* @memberof Flicking.Plugins
|
|
707
|
+
*/
|
|
708
|
+
|
|
709
|
+
var Sync =
|
|
710
|
+
/*#__PURE__*/
|
|
711
|
+
function () {
|
|
712
|
+
/** */
|
|
713
|
+
function Sync(_a) {
|
|
714
|
+
var _this = this;
|
|
715
|
+
|
|
716
|
+
var _b = _a === void 0 ? {} : _a,
|
|
717
|
+
_c = _b.type,
|
|
718
|
+
type = _c === void 0 ? SYNC.TYPE.CAMERA : _c,
|
|
719
|
+
_d = _b.synchronizedFlickingOptions,
|
|
720
|
+
synchronizedFlickingOptions = _d === void 0 ? [] : _d;
|
|
721
|
+
/* Internal Values */
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
this._flicking = null;
|
|
725
|
+
|
|
726
|
+
this._addEvents = function () {
|
|
727
|
+
var type = _this._type;
|
|
728
|
+
var synced = _this._synchronizedFlickingOptions;
|
|
729
|
+
synced.forEach(function (_a) {
|
|
730
|
+
var flicking$1 = _a.flicking,
|
|
731
|
+
isSlidable = _a.isSlidable,
|
|
732
|
+
isClickable = _a.isClickable;
|
|
733
|
+
|
|
734
|
+
if (type === SYNC.TYPE.CAMERA) {
|
|
735
|
+
flicking$1.on(flicking.EVENTS.MOVE, _this._onMove);
|
|
736
|
+
flicking$1.on(flicking.EVENTS.MOVE_START, _this._onMoveStart);
|
|
737
|
+
flicking$1.on(flicking.EVENTS.MOVE_END, _this._onMoveEnd);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (type === SYNC.TYPE.INDEX && isSlidable) {
|
|
741
|
+
flicking$1.on(flicking.EVENTS.WILL_CHANGE, _this._onIndexChange);
|
|
742
|
+
flicking$1.on(flicking.EVENTS.WILL_RESTORE, _this._onIndexChange);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (isClickable) {
|
|
746
|
+
flicking$1.on(flicking.EVENTS.SELECT, _this._onSelect);
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
this._removeEvents = function () {
|
|
752
|
+
var type = _this._type;
|
|
753
|
+
var synced = _this._synchronizedFlickingOptions;
|
|
754
|
+
synced.forEach(function (_a) {
|
|
755
|
+
var flicking$1 = _a.flicking,
|
|
756
|
+
isSlidable = _a.isSlidable,
|
|
757
|
+
isClickable = _a.isClickable;
|
|
758
|
+
|
|
759
|
+
if (type === SYNC.TYPE.CAMERA) {
|
|
760
|
+
flicking$1.off(flicking.EVENTS.MOVE, _this._onMove);
|
|
761
|
+
flicking$1.off(flicking.EVENTS.MOVE_START, _this._onMoveStart);
|
|
762
|
+
flicking$1.off(flicking.EVENTS.MOVE_END, _this._onMoveEnd);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (type === SYNC.TYPE.INDEX && isSlidable) {
|
|
766
|
+
flicking$1.off(flicking.EVENTS.WILL_CHANGE, _this._onIndexChange);
|
|
767
|
+
flicking$1.off(flicking.EVENTS.WILL_RESTORE, _this._onIndexChange);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (isClickable) {
|
|
771
|
+
flicking$1.off(flicking.EVENTS.SELECT, _this._onSelect);
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
this._onIndexChange = function (e) {
|
|
777
|
+
var flicking = e.currentTarget;
|
|
778
|
+
|
|
779
|
+
if (!flicking.initialized) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
_this._synchronizeByIndex(flicking, e.index);
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
this._onMove = function (e) {
|
|
787
|
+
var camera = e.currentTarget.camera;
|
|
788
|
+
var progress = (camera.position - camera.range.min) / camera.rangeDiff;
|
|
789
|
+
|
|
790
|
+
_this._synchronizedFlickingOptions.forEach(function (_a) {
|
|
791
|
+
var flicking = _a.flicking;
|
|
792
|
+
if (flicking === e.currentTarget) return;
|
|
793
|
+
var targetPosition = 0;
|
|
794
|
+
|
|
795
|
+
if (camera.position < camera.range.min) {
|
|
796
|
+
targetPosition = camera.position;
|
|
797
|
+
} else if (camera.position > camera.range.max) {
|
|
798
|
+
targetPosition = flicking.camera.range.max + camera.position - camera.range.max;
|
|
799
|
+
} else {
|
|
800
|
+
targetPosition = flicking.camera.range.min + flicking.camera.rangeDiff * progress;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
void flicking.camera.lookAt(targetPosition);
|
|
804
|
+
});
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
this._onMoveStart = function (e) {
|
|
808
|
+
_this._synchronizedFlickingOptions.forEach(function (_a) {
|
|
809
|
+
var flicking = _a.flicking;
|
|
810
|
+
|
|
811
|
+
if (flicking !== e.currentTarget) {
|
|
812
|
+
flicking.disableInput();
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
this._onMoveEnd = function (e) {
|
|
818
|
+
_this._synchronizedFlickingOptions.forEach(function (_a) {
|
|
819
|
+
var flicking = _a.flicking;
|
|
820
|
+
|
|
821
|
+
if (flicking !== e.currentTarget) {
|
|
822
|
+
flicking.enableInput();
|
|
823
|
+
flicking.control.updateInput();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
this._onSelect = function (e) {
|
|
829
|
+
void e.currentTarget.moveTo(e.index).catch(function () {
|
|
830
|
+
return void 0;
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
_this._synchronizeByIndex(e.currentTarget, e.index);
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
this._synchronizeByIndex = function (activeFlicking, index) {
|
|
837
|
+
var synchronizedFlickingOptions = _this._synchronizedFlickingOptions;
|
|
838
|
+
|
|
839
|
+
_this._preventEvent(function () {
|
|
840
|
+
synchronizedFlickingOptions.forEach(function (options) {
|
|
841
|
+
// Active class should be applied same to the Flicking which triggered event
|
|
842
|
+
_this._updateClass(options, index);
|
|
843
|
+
|
|
844
|
+
var flicking$1 = options.flicking;
|
|
845
|
+
if (flicking$1 === activeFlicking) return;
|
|
846
|
+
var targetIndex = flicking.clamp(index, 0, flicking$1.panels.length);
|
|
847
|
+
|
|
848
|
+
if (flicking$1.animating) {
|
|
849
|
+
// Reserve moveTo once previous animation is finished
|
|
850
|
+
flicking$1.once(flicking.EVENTS.MOVE_END, function () {
|
|
851
|
+
void flicking$1.moveTo(targetIndex).catch(function () {
|
|
852
|
+
return void 0;
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
} else {
|
|
856
|
+
void flicking$1.moveTo(targetIndex);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
this._updateClass = function (_a, index) {
|
|
863
|
+
var flicking = _a.flicking,
|
|
864
|
+
activeClass = _a.activeClass;
|
|
865
|
+
if (!activeClass) return;
|
|
866
|
+
flicking.panels.forEach(function (panel) {
|
|
867
|
+
if (panel.index === index) {
|
|
868
|
+
addClass(panel.element, activeClass);
|
|
869
|
+
} else {
|
|
870
|
+
removeClass(panel.element, activeClass);
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
this._type = type;
|
|
876
|
+
this._synchronizedFlickingOptions = synchronizedFlickingOptions;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
var __proto = Sync.prototype;
|
|
880
|
+
Object.defineProperty(__proto, "type", {
|
|
881
|
+
get: function () {
|
|
882
|
+
return this._type;
|
|
883
|
+
},
|
|
884
|
+
set: function (val) {
|
|
885
|
+
this._type = val;
|
|
886
|
+
},
|
|
887
|
+
enumerable: false,
|
|
888
|
+
configurable: true
|
|
889
|
+
});
|
|
890
|
+
Object.defineProperty(__proto, "synchronizedFlickingOptions", {
|
|
891
|
+
get: function () {
|
|
892
|
+
return this._synchronizedFlickingOptions;
|
|
893
|
+
},
|
|
894
|
+
set: function (val) {
|
|
895
|
+
this._synchronizedFlickingOptions = val;
|
|
896
|
+
},
|
|
897
|
+
enumerable: false,
|
|
898
|
+
configurable: true
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
__proto.init = function (flicking) {
|
|
902
|
+
var _this = this;
|
|
903
|
+
|
|
904
|
+
var synced = this._synchronizedFlickingOptions;
|
|
905
|
+
|
|
906
|
+
if (this._flicking) {
|
|
907
|
+
this.destroy();
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
this._flicking = flicking;
|
|
911
|
+
|
|
912
|
+
this._addEvents();
|
|
913
|
+
|
|
914
|
+
synced.forEach(function (options) {
|
|
915
|
+
var syncedFlicking = options.flicking;
|
|
916
|
+
|
|
917
|
+
_this._updateClass(options, syncedFlicking.defaultIndex);
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
__proto.destroy = function () {
|
|
922
|
+
var flicking = this._flicking;
|
|
923
|
+
|
|
924
|
+
if (!flicking) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
this._removeEvents();
|
|
929
|
+
|
|
930
|
+
this._flicking = null;
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
__proto.update = function () {
|
|
934
|
+
var _this = this;
|
|
935
|
+
|
|
936
|
+
this._synchronizedFlickingOptions.forEach(function (options) {
|
|
937
|
+
_this._updateClass(options, options.flicking.index);
|
|
938
|
+
});
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
__proto._preventEvent = function (fn) {
|
|
942
|
+
this._removeEvents();
|
|
943
|
+
|
|
944
|
+
fn();
|
|
945
|
+
|
|
946
|
+
this._addEvents();
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
return Sync;
|
|
950
|
+
}();
|
|
951
|
+
|
|
697
952
|
/*! *****************************************************************************
|
|
698
953
|
Copyright (c) Microsoft Corporation.
|
|
699
954
|
|
|
@@ -948,26 +1203,38 @@ version: 4.1.0
|
|
|
948
1203
|
var anchorOffset = anchorPoints[0].panel.index;
|
|
949
1204
|
var activeIndex = index - anchorOffset;
|
|
950
1205
|
if (anchorPoints.length <= 0) return;
|
|
951
|
-
var bulletClass = pagination.classPrefix + "-" + PAGINATION.BULLET_SUFFIX;
|
|
952
1206
|
var bulletActiveClass = pagination.classPrefix + "-" + PAGINATION.BULLET_ACTIVE_SUFFIX;
|
|
1207
|
+
var prevClassPrefix = pagination.classPrefix + "-" + PAGINATION.SCROLL_PREV_SUFFIX;
|
|
1208
|
+
var nextClassPrefix = pagination.classPrefix + "-" + PAGINATION.SCROLL_NEXT_SUFFIX;
|
|
953
1209
|
|
|
954
1210
|
var bulletPrevClass = function (offset) {
|
|
955
|
-
return
|
|
1211
|
+
return "" + prevClassPrefix + (offset > 1 ? offset : "");
|
|
956
1212
|
};
|
|
957
1213
|
|
|
958
1214
|
var bulletNextClass = function (offset) {
|
|
959
|
-
return
|
|
1215
|
+
return "" + nextClassPrefix + (offset > 1 ? offset : "");
|
|
960
1216
|
};
|
|
961
1217
|
|
|
1218
|
+
var prevClassRegex = new RegExp("^" + prevClassPrefix);
|
|
1219
|
+
var nextClassRegex = new RegExp("^" + nextClassPrefix);
|
|
962
1220
|
bullets.forEach(function (bullet, idx) {
|
|
963
1221
|
var indexOffset = idx - activeIndex;
|
|
1222
|
+
var classList = bullet.className.split(" ");
|
|
1223
|
+
|
|
1224
|
+
for (var _i = 0, classList_1 = classList; _i < classList_1.length; _i++) {
|
|
1225
|
+
var className = classList_1[_i];
|
|
1226
|
+
|
|
1227
|
+
if (className === bulletActiveClass || prevClassRegex.test(className) || nextClassRegex.test(className)) {
|
|
1228
|
+
removeClass(bullet, className);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
964
1231
|
|
|
965
1232
|
if (indexOffset === 0) {
|
|
966
|
-
bullet
|
|
1233
|
+
addClass(bullet, bulletActiveClass);
|
|
967
1234
|
} else if (indexOffset > 0) {
|
|
968
|
-
bullet
|
|
1235
|
+
addClass(bullet, bulletNextClass(Math.abs(indexOffset)));
|
|
969
1236
|
} else {
|
|
970
|
-
bullet
|
|
1237
|
+
addClass(bullet, bulletPrevClass(Math.abs(indexOffset)));
|
|
971
1238
|
}
|
|
972
1239
|
});
|
|
973
1240
|
pagination.scrollOnChange(activeIndex, {
|
|
@@ -1241,6 +1508,8 @@ version: 4.1.0
|
|
|
1241
1508
|
exports.PAGINATION = PAGINATION;
|
|
1242
1509
|
exports.Pagination = Pagination;
|
|
1243
1510
|
exports.Parallax = Parallax;
|
|
1511
|
+
exports.SYNC = SYNC;
|
|
1512
|
+
exports.Sync = Sync;
|
|
1244
1513
|
|
|
1245
1514
|
}));
|
|
1246
1515
|
//# sourceMappingURL=plugins.js.map
|