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