@nativescript-community/ui-pager 13.0.35 → 13.0.36
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/CHANGELOG.md +8 -0
- package/index.android.js +326 -330
- package/index.android.js.map +1 -1
- package/index.common.d.ts +1 -4
- package/index.common.js +3 -6
- package/index.common.js.map +1 -1
- package/index.ios.js +155 -288
- package/index.ios.js.map +1 -1
- package/package.json +2 -2
package/index.ios.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
var PagerCell_1, UICollectionDelegateImpl_1, UICollectionViewDataSourceImpl_1, UICollectionViewFlowLinearLayoutImpl_1;
|
1
2
|
import { ChangeType, Color, Observable, ObservableArray, Property, ProxyViewContainer, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
|
2
3
|
import { layout } from '@nativescript/core/utils/utils';
|
3
|
-
import {
|
4
|
+
import { Indicator, PagerBase, PagerItem, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, selectedIndexProperty, showIndicatorProperty } from './index.common';
|
4
5
|
export * from './index.common';
|
5
6
|
export { Transformer } from './index.common';
|
6
7
|
function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
|
@@ -46,22 +47,20 @@ export const contentInsetAdjustmentBehaviorProperty = new Property({
|
|
46
47
|
valueConverter: parseContentInsetAdjustmentBehavior,
|
47
48
|
defaultValue: ContentInsetAdjustmentBehavior.Automatic
|
48
49
|
});
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
53
|
-
}
|
54
|
-
UICellView.prototype.layoutSubviews = function () {
|
55
|
-
var view = this.view && this.view.get();
|
50
|
+
let UICellView = class UICellView extends UIView {
|
51
|
+
layoutSubviews() {
|
52
|
+
const view = this.view && this.view.get();
|
56
53
|
if (!view) {
|
57
54
|
return;
|
58
55
|
}
|
59
56
|
this.frame = this.superview.bounds;
|
60
|
-
|
57
|
+
const size = this.bounds.size;
|
61
58
|
View.layoutChild(null, view, 0, 0, Utils.layout.toDevicePixels(size.width), Utils.layout.toDevicePixels(size.height));
|
62
|
-
}
|
63
|
-
|
64
|
-
|
59
|
+
}
|
60
|
+
};
|
61
|
+
UICellView = __decorate([
|
62
|
+
NativeClass
|
63
|
+
], UICellView);
|
65
64
|
const PFLAG_FORCE_LAYOUT = 1;
|
66
65
|
export class Pager extends PagerBase {
|
67
66
|
constructor() {
|
@@ -543,7 +542,7 @@ export class Pager extends PagerBase {
|
|
543
542
|
_removeContainer(cell, index) {
|
544
543
|
let view = cell.view;
|
545
544
|
const args = {
|
546
|
-
eventName:
|
545
|
+
eventName: Pager.itemDisposingEvent,
|
547
546
|
object: this,
|
548
547
|
index,
|
549
548
|
android: undefined,
|
@@ -617,7 +616,7 @@ export class Pager extends PagerBase {
|
|
617
616
|
}
|
618
617
|
const bindingContext = this._getDataItem(indexPath.row);
|
619
618
|
const args = {
|
620
|
-
eventName:
|
619
|
+
eventName: Pager.itemLoadingEvent,
|
621
620
|
object: this,
|
622
621
|
index,
|
623
622
|
android: undefined,
|
@@ -706,49 +705,35 @@ export class Pager extends PagerBase {
|
|
706
705
|
__decorate([
|
707
706
|
profile
|
708
707
|
], Pager.prototype, "refresh", null);
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
get: function () {
|
716
|
-
return this.owner ? this.owner.get() : null;
|
717
|
-
},
|
718
|
-
enumerable: true,
|
719
|
-
configurable: true
|
720
|
-
});
|
721
|
-
PagerCell.initWithEmptyBackground = function () {
|
722
|
-
var cell = PagerCell.new();
|
723
|
-
// Clear background by default - this will make cells transparent
|
708
|
+
let PagerCell = PagerCell_1 = class PagerCell extends UICollectionViewCell {
|
709
|
+
get view() {
|
710
|
+
return this.owner ? this.owner.get() : null;
|
711
|
+
}
|
712
|
+
static initWithEmptyBackground() {
|
713
|
+
const cell = PagerCell_1.new();
|
724
714
|
cell.backgroundColor = null;
|
725
715
|
return cell;
|
726
|
-
}
|
727
|
-
|
728
|
-
|
729
|
-
// When inside Pager and there is no newSuperview this cell is
|
730
|
-
// removed from native visual tree so we remove it from our tree too.
|
716
|
+
}
|
717
|
+
willMoveToSuperview(newSuperview) {
|
718
|
+
const parent = (this.view ? this.view.parent : null);
|
731
719
|
if (parent && !newSuperview) {
|
732
720
|
parent._removeContainer(this, this.index);
|
733
721
|
}
|
734
|
-
}
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
UICollectionDelegateImpl_1 = UICollectionDelegateImpl;
|
743
|
-
UICollectionDelegateImpl.initWithOwner = function (owner) {
|
744
|
-
var delegate = UICollectionDelegateImpl_1.alloc().init();
|
722
|
+
}
|
723
|
+
};
|
724
|
+
PagerCell = PagerCell_1 = __decorate([
|
725
|
+
NativeClass
|
726
|
+
], PagerCell);
|
727
|
+
let UICollectionDelegateImpl = UICollectionDelegateImpl_1 = class UICollectionDelegateImpl extends NSObject {
|
728
|
+
static initWithOwner(owner) {
|
729
|
+
const delegate = UICollectionDelegateImpl_1.alloc().init();
|
745
730
|
delegate._owner = owner;
|
746
731
|
return delegate;
|
747
|
-
}
|
748
|
-
|
749
|
-
|
732
|
+
}
|
733
|
+
collectionViewLayoutInsetForSectionAtIndex(collectionView, collectionViewLayout, section) {
|
734
|
+
const owner = this._owner ? this._owner.get() : null;
|
750
735
|
if (owner) {
|
751
|
-
|
736
|
+
const inset = owner._getSpacing() + owner._getPeaking();
|
752
737
|
if (owner.orientation === 'vertical') {
|
753
738
|
return new UIEdgeInsets({
|
754
739
|
bottom: inset,
|
@@ -765,16 +750,16 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
765
750
|
});
|
766
751
|
}
|
767
752
|
return new UIEdgeInsets({ bottom: 0, left: 0, right: 0, top: 0 });
|
768
|
-
}
|
769
|
-
|
770
|
-
|
753
|
+
}
|
754
|
+
collectionViewLayoutSizeForItemAtIndexPath(collectionView, collectionViewLayout, indexPath) {
|
755
|
+
const owner = this._owner && this._owner.get();
|
771
756
|
if (!owner)
|
772
757
|
return CGSizeZero;
|
773
|
-
|
758
|
+
const size = owner._getSize();
|
774
759
|
return CGSizeMake(size.width, size.height);
|
775
|
-
}
|
776
|
-
|
777
|
-
|
760
|
+
}
|
761
|
+
collectionViewWillDisplayCellForItemAtIndexPath(collectionView, cell, indexPath) {
|
762
|
+
const owner = this._owner && this._owner.get();
|
778
763
|
if (owner) {
|
779
764
|
if (!owner.mIsInit) {
|
780
765
|
owner._updateScrollPosition();
|
@@ -782,7 +767,7 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
782
767
|
}
|
783
768
|
if (owner.items && indexPath.row === owner.lastIndex - owner.loadMoreCount) {
|
784
769
|
owner.notify({
|
785
|
-
eventName:
|
770
|
+
eventName: Pager.loadMoreItemsEvent,
|
786
771
|
object: owner
|
787
772
|
});
|
788
773
|
}
|
@@ -793,16 +778,16 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
793
778
|
if (cell.layoutMargins) {
|
794
779
|
cell.layoutMargins = UIEdgeInsetsZero;
|
795
780
|
}
|
796
|
-
}
|
797
|
-
|
798
|
-
|
781
|
+
}
|
782
|
+
collectionViewLayoutMinimumLineSpacingForSectionAtIndex(collectionView, collectionViewLayout, section) {
|
783
|
+
const owner = this._owner ? this._owner.get() : null;
|
799
784
|
if (!owner)
|
800
785
|
return 0;
|
801
|
-
|
786
|
+
const result = owner._getSpacing();
|
802
787
|
return result;
|
803
|
-
}
|
804
|
-
|
805
|
-
|
788
|
+
}
|
789
|
+
scrollViewWillBeginDragging(scrollView) {
|
790
|
+
const owner = this._owner && this._owner.get();
|
806
791
|
if (owner) {
|
807
792
|
if (owner.lastEvent === 0) {
|
808
793
|
owner.notify({
|
@@ -812,23 +797,23 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
812
797
|
owner.lastEvent = 1;
|
813
798
|
}
|
814
799
|
}
|
815
|
-
}
|
816
|
-
|
817
|
-
|
800
|
+
}
|
801
|
+
scrollViewDidEndScrollingAnimation(scrollView) {
|
802
|
+
const owner = this._owner ? this._owner.get() : null;
|
818
803
|
if (owner) {
|
819
804
|
owner.notify({
|
820
805
|
eventName: Pager.swipeEvent,
|
821
806
|
object: owner
|
822
807
|
});
|
823
808
|
}
|
824
|
-
}
|
825
|
-
|
826
|
-
|
809
|
+
}
|
810
|
+
scrollViewDidScroll(scrollView) {
|
811
|
+
const owner = this._owner.get();
|
827
812
|
if (owner) {
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
813
|
+
let width;
|
814
|
+
let offset;
|
815
|
+
const size = owner._getRealWidthHeight();
|
816
|
+
let total;
|
832
817
|
if (owner.orientation === 'vertical') {
|
833
818
|
width = size.height;
|
834
819
|
offset = scrollView.contentOffset.y;
|
@@ -839,14 +824,13 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
839
824
|
offset = scrollView.contentOffset.x;
|
840
825
|
total = scrollView.contentSize.width - scrollView.bounds.size.width;
|
841
826
|
}
|
842
|
-
|
843
|
-
|
827
|
+
const percent = offset / total;
|
828
|
+
const progress = percent * (owner.itemCount - 1);
|
844
829
|
if (owner.indicatorView && owner.indicatorView.setWithProgressAnimated && !Number.isNaN(progress)) {
|
845
830
|
owner.indicatorView.progress = progress;
|
846
831
|
}
|
847
|
-
|
832
|
+
const index = parseInt(progress.toFixed(0), 10);
|
848
833
|
if (owner.selectedIndex !== index && !Number.isNaN(index)) {
|
849
|
-
// selectedIndexProperty.nativeValueChange(owner, index);
|
850
834
|
}
|
851
835
|
owner.notify({
|
852
836
|
object: owner,
|
@@ -863,83 +847,11 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
863
847
|
});
|
864
848
|
owner.lastEvent = 1;
|
865
849
|
}
|
866
|
-
// (scrollView as any).scrollToItemAtIndexPathAtScrollPositionAnimated(
|
867
|
-
// NSIndexPath.indexPathForRowInSection(Math.round(width),0), UICollectionViewScrollPosition.CenteredHorizontally, true
|
868
|
-
// );
|
869
|
-
// if(owner.circularMode){
|
870
|
-
// if(nextIndex === 0){
|
871
|
-
// selectedIndexProperty.nativeValueChange(owner, owner._childrenCount - 3);
|
872
|
-
// }else if(nextIndex === owner._childrenCount -1){
|
873
|
-
// selectedIndexProperty.nativeValueChange(owner, 0);
|
874
|
-
// }else {
|
875
|
-
// selectedIndexProperty.nativeValueChange(owner, nextIndex - 1);
|
876
|
-
// }
|
877
|
-
// }else {
|
878
|
-
// selectedIndexProperty.nativeValueChange(owner, nextIndex);
|
879
|
-
// }
|
880
|
-
/* if (!Number.isNaN(width)) {
|
881
|
-
let page = Math.ceil(width);
|
882
|
-
const doScroll = () => {
|
883
|
-
if (!Number.isNaN(width)) {
|
884
|
-
// scrollView.setContentOffsetAnimated(point, false);
|
885
|
-
scrollView.contentOffset = CGPointMake(Math.ceil(w) * page, scrollView.contentOffset.y);
|
886
|
-
}
|
887
|
-
};
|
888
|
-
console.log('page', page, owner.itemCount, page === owner.itemCount);
|
889
|
-
if (page === 0) {
|
890
|
-
page = owner.itemCount - 2;
|
891
|
-
doScroll();
|
892
|
-
// selectedIndexProperty.nativeValueChange(owner, owner.itemCount - 3);
|
893
|
-
} else if (page === owner.itemCount) {
|
894
|
-
page = 1;
|
895
|
-
doScroll();
|
896
|
-
// selectedIndexProperty.nativeValueChange(owner, 0);
|
897
|
-
} else {
|
898
|
-
if (page === owner._childrenCount + 1) {
|
899
|
-
// selectedIndexProperty.nativeValueChange(owner, 0);
|
900
|
-
} else {
|
901
|
-
// selectedIndexProperty.nativeValueChange(owner, page - 1);
|
902
|
-
}
|
903
|
-
|
904
|
-
}
|
905
|
-
} */
|
906
|
-
/* if(owner){
|
907
|
-
let width = 0;
|
908
|
-
let w = (layout.toDeviceIndependentPixels(owner._effectiveItemWidth) - (((owner.perPage * 2) * owner._getSpacing()) + (owner._getPeaking() * 2))) / owner.perPage;
|
909
|
-
let h = (layout.toDeviceIndependentPixels(owner._effectiveItemHeight) - (((owner.perPage * 2) * owner._getSpacing()) + (owner._getPeaking() * 2))) / owner.perPage;
|
910
|
-
width = scrollView.contentOffset.x / w;
|
911
|
-
if (!Number.isNaN(width)) {
|
912
|
-
let page = Math.ceil(width);
|
913
|
-
const doScroll = () => {
|
914
|
-
if (!Number.isNaN(width)) {
|
915
|
-
const point = CGPointMake(Math.ceil(w) * page, scrollView.contentOffset.y);
|
916
|
-
scrollView.setContentOffsetAnimated(point, false);
|
917
|
-
}
|
918
|
-
};
|
919
|
-
if (page === 0) {
|
920
|
-
page = owner.itemCount - 2;
|
921
|
-
doScroll();
|
922
|
-
selectedIndexProperty.nativeValueChange(owner, owner.itemCount - 3);
|
923
|
-
} else if (page === owner.itemCount -1) {
|
924
|
-
page = 1;
|
925
|
-
doScroll();
|
926
|
-
selectedIndexProperty.nativeValueChange(owner, 0);
|
927
|
-
} else {
|
928
|
-
if(page === owner.itemCount + 1){
|
929
|
-
selectedIndexProperty.nativeValueChange(owner, 0);
|
930
|
-
}else {
|
931
|
-
selectedIndexProperty.nativeValueChange(owner, page - 1);
|
932
|
-
}
|
933
|
-
}
|
934
|
-
}
|
935
|
-
} */
|
936
|
-
// scrollView.setContentOffsetAnimated(CGPointMake((w * width) + 1, 0),false);
|
937
|
-
// (owner.nativeView as UICollectionView).setContentOffsetAnimated(CGPointMake((w * width) + 1, 0),false);
|
938
850
|
}
|
939
|
-
}
|
940
|
-
|
941
|
-
|
942
|
-
|
851
|
+
}
|
852
|
+
scrollViewDidEndDraggingWillDecelerate(scrollView, decelerate) { }
|
853
|
+
scrollViewWillEndDraggingWithVelocityTargetContentOffset(scrollView, velocity, targetContentOffset) {
|
854
|
+
const owner = this._owner ? this._owner.get() : null;
|
943
855
|
if (!owner)
|
944
856
|
return;
|
945
857
|
if (owner.lastEvent === 1) {
|
@@ -949,28 +861,22 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
949
861
|
});
|
950
862
|
owner.lastEvent = 0;
|
951
863
|
}
|
952
|
-
}
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
function UICollectionViewDataSourceImpl() {
|
962
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
963
|
-
}
|
964
|
-
UICollectionViewDataSourceImpl_1 = UICollectionViewDataSourceImpl;
|
965
|
-
UICollectionViewDataSourceImpl.initWithOwner = function (owner) {
|
966
|
-
var delegate = UICollectionViewDataSourceImpl_1.alloc().init();
|
864
|
+
}
|
865
|
+
};
|
866
|
+
UICollectionDelegateImpl = UICollectionDelegateImpl_1 = __decorate([
|
867
|
+
NativeClass,
|
868
|
+
ObjCClass(UICollectionViewDelegate, UICollectionViewDelegateFlowLayout)
|
869
|
+
], UICollectionDelegateImpl);
|
870
|
+
let UICollectionViewDataSourceImpl = UICollectionViewDataSourceImpl_1 = class UICollectionViewDataSourceImpl extends NSObject {
|
871
|
+
static initWithOwner(owner) {
|
872
|
+
const delegate = UICollectionViewDataSourceImpl_1.alloc().init();
|
967
873
|
delegate._owner = owner;
|
968
874
|
return delegate;
|
969
|
-
}
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
875
|
+
}
|
876
|
+
collectionViewCellForItemAtIndexPath(collectionView, indexPath) {
|
877
|
+
const owner = this._owner ? this._owner.get() : null;
|
878
|
+
let cell;
|
879
|
+
let count = 0;
|
974
880
|
if (owner) {
|
975
881
|
count = owner._childrenCount;
|
976
882
|
if (owner.circularMode) {
|
@@ -989,70 +895,48 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
989
895
|
}
|
990
896
|
}
|
991
897
|
if (owner && !owner.items && count > 0) {
|
992
|
-
|
993
|
-
|
994
|
-
|
898
|
+
const index = indexPath.row;
|
899
|
+
const data = owner._childrenViews[index];
|
900
|
+
const viewType = data.type;
|
995
901
|
owner.mPreparingCell = true;
|
996
|
-
collectionView.registerClassForCellWithReuseIdentifier(PagerCell.class(),
|
997
|
-
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(
|
902
|
+
collectionView.registerClassForCellWithReuseIdentifier(PagerCell.class(), `static-${viewType}`);
|
903
|
+
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(`static-${viewType}`, indexPath) || PagerCell.initWithEmptyBackground();
|
998
904
|
cell.index = index;
|
999
|
-
|
1000
|
-
// if (view instanceof ProxyViewContainer) {
|
1001
|
-
// let sp = new StackLayout();
|
1002
|
-
// sp.addChild(view);
|
1003
|
-
// view = sp;
|
1004
|
-
// }
|
1005
|
-
// If cell is reused it has old content - remove it first.
|
905
|
+
const view = data.view;
|
1006
906
|
if (!cell.view) {
|
1007
907
|
cell.owner = new WeakRef(view);
|
1008
908
|
}
|
1009
909
|
else if (cell.view !== view) {
|
1010
910
|
owner._removeView(view);
|
1011
|
-
// (cell.view.nativeViewProtected as UIView).removeFromSuperview();
|
1012
911
|
cell.owner = new WeakRef(view);
|
1013
912
|
}
|
1014
913
|
if (view && !view.parent) {
|
1015
|
-
// view['performLayout'] = () => {
|
1016
|
-
// View.measureChild(
|
1017
|
-
// owner,
|
1018
|
-
// view,
|
1019
|
-
// view._currentWidthMeasureSpec,
|
1020
|
-
// view._currentHeightMeasureSpec
|
1021
|
-
// );
|
1022
|
-
// if (view && view.isLayoutRequired) {
|
1023
|
-
// View.layoutChild(owner, view, 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
1024
|
-
// }
|
1025
|
-
// };
|
1026
914
|
owner._addView(view);
|
1027
|
-
|
1028
|
-
var innerView = UICellView.new();
|
915
|
+
const innerView = UICellView.new();
|
1029
916
|
innerView.view = new WeakRef(view);
|
1030
917
|
innerView.addSubview(view.nativeViewProtected);
|
1031
918
|
cell.contentView.addSubview(innerView);
|
1032
919
|
owner.mMap.set(cell, view);
|
1033
|
-
// } else {
|
1034
|
-
// cell.contentView.addSubview(view.nativeViewProtected);
|
1035
|
-
// }
|
1036
920
|
}
|
1037
921
|
view.iosOverflowSafeArea = owner.iosOverflowSafeArea;
|
1038
922
|
view['iosIgnoreSafeArea'] = owner['iosIgnoreSafeArea'];
|
1039
923
|
owner._layoutCell(view, indexPath);
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
924
|
+
const size = owner._getSize();
|
925
|
+
const width = layout.toDevicePixels(size.width);
|
926
|
+
const height = layout.toDevicePixels(size.height);
|
1043
927
|
if (view && view.isLayoutRequired) {
|
1044
928
|
View.layoutChild(owner, view, 0, 0, width, height);
|
1045
929
|
}
|
1046
930
|
owner.mPreparingCell = false;
|
1047
931
|
return cell;
|
1048
932
|
}
|
1049
|
-
|
933
|
+
const template = owner && owner._getItemTemplate(indexPath.row);
|
1050
934
|
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(template.key, indexPath) || PagerCell.initWithEmptyBackground();
|
1051
935
|
cell.index = indexPath;
|
1052
936
|
if (owner) {
|
1053
|
-
|
937
|
+
const size = owner._getSize();
|
1054
938
|
owner._prepareCell(cell, indexPath);
|
1055
|
-
|
939
|
+
const cellView = cell.view;
|
1056
940
|
cellView.iosOverflowSafeArea = owner.iosOverflowSafeArea;
|
1057
941
|
cellView['iosIgnoreSafeArea'] = owner['iosIgnoreSafeArea'];
|
1058
942
|
if (!owner.iosOverflowSafeAreaEnabled && cellView && cellView.isLayoutRequired) {
|
@@ -1060,53 +944,46 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
1060
944
|
}
|
1061
945
|
}
|
1062
946
|
return cell;
|
1063
|
-
}
|
1064
|
-
|
1065
|
-
|
1066
|
-
// make sure we dont start to load static view if the pager is not loaded.
|
1067
|
-
// otherwise static items wont "load"
|
947
|
+
}
|
948
|
+
collectionViewNumberOfItemsInSection(collectionView, section) {
|
949
|
+
const owner = this._owner ? this._owner.get() : null;
|
1068
950
|
if (!owner || !owner.isLoaded)
|
1069
951
|
return 0;
|
1070
952
|
return owner.circularMode ? owner.itemCount : owner._childrenCount;
|
1071
|
-
}
|
1072
|
-
|
953
|
+
}
|
954
|
+
numberOfSectionsInCollectionView(collectionView) {
|
1073
955
|
return 1;
|
1074
|
-
}
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
function UICollectionViewFlowLinearLayoutImpl() {
|
1084
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
1085
|
-
}
|
1086
|
-
UICollectionViewFlowLinearLayoutImpl.initWithOwner = function (owner) {
|
1087
|
-
var layout = UICollectionViewFlowLinearLayoutImpl.new();
|
956
|
+
}
|
957
|
+
};
|
958
|
+
UICollectionViewDataSourceImpl = UICollectionViewDataSourceImpl_1 = __decorate([
|
959
|
+
NativeClass,
|
960
|
+
ObjCClass(UICollectionViewDataSource)
|
961
|
+
], UICollectionViewDataSourceImpl);
|
962
|
+
let UICollectionViewFlowLinearLayoutImpl = UICollectionViewFlowLinearLayoutImpl_1 = class UICollectionViewFlowLinearLayoutImpl extends UICollectionViewFlowLayout {
|
963
|
+
static initWithOwner(owner) {
|
964
|
+
const layout = UICollectionViewFlowLinearLayoutImpl_1.new();
|
1088
965
|
layout._owner = owner;
|
1089
966
|
layout._curl = CATransition.animation();
|
1090
967
|
return layout;
|
1091
|
-
}
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
968
|
+
}
|
969
|
+
layoutAttributesForElementsInRect(rect) {
|
970
|
+
const owner = this._owner ? this._owner.get() : null;
|
971
|
+
const originalLayoutAttribute = super.layoutAttributesForElementsInRect(rect);
|
972
|
+
const visibleLayoutAttributes = [];
|
1096
973
|
if (owner) {
|
1097
974
|
if (owner.transformers && owner.transformers.indexOf('scale') > -1) {
|
1098
|
-
|
1099
|
-
for (
|
1100
|
-
|
975
|
+
const count = originalLayoutAttribute.count;
|
976
|
+
for (let i = 0; i < count; i++) {
|
977
|
+
const attributes = originalLayoutAttribute.objectAtIndex(i);
|
1101
978
|
visibleLayoutAttributes[i] = attributes;
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
979
|
+
const frame = attributes.frame;
|
980
|
+
const width = attributes.frame.size.width * 0.75;
|
981
|
+
const height = attributes.frame.size.height * 0.75;
|
1105
982
|
attributes.frame.size.width = width;
|
1106
983
|
attributes.frame.size.height = height;
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
984
|
+
const spacing = owner.convertToSize(owner.spacing);
|
985
|
+
const distance = Math.abs(this.collectionView.contentOffset.x + this.collectionView.contentInset.left + spacing - frame.origin.x);
|
986
|
+
const scale = Math.min(Math.max(1 - distance / this.collectionView.bounds.size.width, 0.75), 1);
|
1110
987
|
attributes.transform = CGAffineTransformScale(attributes.transform, 1, scale);
|
1111
988
|
}
|
1112
989
|
}
|
@@ -1115,61 +992,51 @@ var UICollectionViewFlowLinearLayoutImpl = /** @class */ (function (_super) {
|
|
1115
992
|
}
|
1116
993
|
}
|
1117
994
|
return visibleLayoutAttributes;
|
1118
|
-
}
|
1119
|
-
|
995
|
+
}
|
996
|
+
shouldInvalidateLayoutForBoundsChange(newBounds) {
|
1120
997
|
return true;
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
|
998
|
+
}
|
999
|
+
initialLayoutAttributesForAppearingItemAtIndexPath(itemIndexPath) {
|
1000
|
+
const attrs = super.initialLayoutAttributesForAppearingItemAtIndexPath(itemIndexPath);
|
1124
1001
|
attrs.alpha = 1;
|
1125
1002
|
return attrs;
|
1126
|
-
}
|
1127
|
-
|
1128
|
-
|
1003
|
+
}
|
1004
|
+
finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath) {
|
1005
|
+
const attrs = super.finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath);
|
1129
1006
|
attrs.alpha = 1;
|
1130
1007
|
return attrs;
|
1131
|
-
}
|
1132
|
-
|
1133
|
-
|
1008
|
+
}
|
1009
|
+
targetContentOffsetForProposedContentOffsetWithScrollingVelocity(proposedContentOffset, velocity) {
|
1010
|
+
const owner = this._owner ? this._owner.get() : null;
|
1134
1011
|
if (!this.collectionView || !owner) {
|
1135
|
-
return
|
1136
|
-
}
|
1137
|
-
|
1138
|
-
if (this.scrollDirection ===
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
// Create custom flickVelocity.
|
1146
|
-
var flickVelocity = velocity.x * 0.3;
|
1147
|
-
// Check how many pages the user flicked, if <= 1 then flickedPages should return 0.
|
1148
|
-
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1149
|
-
var newPageIndex = currentPage + flickedPages;
|
1012
|
+
return super.targetContentOffsetForProposedContentOffsetWithScrollingVelocity(proposedContentOffset, velocity);
|
1013
|
+
}
|
1014
|
+
const size = owner._getRealWidthHeight();
|
1015
|
+
if (this.scrollDirection === 1) {
|
1016
|
+
const pageWidth = size.width + this.minimumInteritemSpacing;
|
1017
|
+
const approximatePage = this.collectionView.contentOffset.x / pageWidth;
|
1018
|
+
const currentPage = velocity.x === 0 ? Math.round(approximatePage) : velocity.x < 0.0 ? Math.floor(approximatePage) : Math.ceil(approximatePage);
|
1019
|
+
const flickVelocity = velocity.x * 0.3;
|
1020
|
+
const flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1021
|
+
const newPageIndex = currentPage + flickedPages;
|
1150
1022
|
selectedIndexProperty.nativeValueChange(owner, Math.min(Math.max(newPageIndex, 0), owner._childrenCount - 1));
|
1151
|
-
|
1152
|
-
var newHorizontalOffset = newPageIndex * pageWidth - this.collectionView.contentInset.left;
|
1023
|
+
const newHorizontalOffset = newPageIndex * pageWidth - this.collectionView.contentInset.left;
|
1153
1024
|
return CGPointMake(newHorizontalOffset, proposedContentOffset.y);
|
1154
1025
|
}
|
1155
1026
|
else {
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
var currentPage = velocity.y === 0 ? Math.round(approximatePage) : velocity.y < 0.0 ? Math.floor(approximatePage) : Math.ceil(approximatePage);
|
1163
|
-
// Create custom flickVelocity.
|
1164
|
-
var flickVelocity = velocity.y * 0.3;
|
1165
|
-
// Check how many pages the user flicked, if <= 1 then flickedPages should return 0.
|
1166
|
-
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1167
|
-
var newPageIndex = currentPage + flickedPages;
|
1027
|
+
const pageHeight = size.height;
|
1028
|
+
const approximatePage = Math.max(0, this.collectionView.contentOffset.y / pageHeight);
|
1029
|
+
const currentPage = velocity.y === 0 ? Math.round(approximatePage) : velocity.y < 0.0 ? Math.floor(approximatePage) : Math.ceil(approximatePage);
|
1030
|
+
const flickVelocity = velocity.y * 0.3;
|
1031
|
+
const flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1032
|
+
const newPageIndex = currentPage + flickedPages;
|
1168
1033
|
selectedIndexProperty.nativeValueChange(owner, Math.min(Math.max(newPageIndex, 0), owner._childrenCount - 1));
|
1169
|
-
|
1034
|
+
const newVerticalOffset = newPageIndex * pageHeight - this.collectionView.contentInset.top;
|
1170
1035
|
return CGPointMake(proposedContentOffset.x, newVerticalOffset);
|
1171
1036
|
}
|
1172
|
-
}
|
1173
|
-
|
1174
|
-
|
1037
|
+
}
|
1038
|
+
};
|
1039
|
+
UICollectionViewFlowLinearLayoutImpl = UICollectionViewFlowLinearLayoutImpl_1 = __decorate([
|
1040
|
+
NativeClass
|
1041
|
+
], UICollectionViewFlowLinearLayoutImpl);
|
1175
1042
|
//# sourceMappingURL=index.ios.js.map
|