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