@nativescript-community/ui-pager 13.0.32 → 13.0.35
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 +24 -0
- package/angular/esm2020/index.mjs +55 -0
- package/angular/{esm2015/nativescript-community-ui-pager-angular.js → esm2020/nativescript-community-ui-pager-angular.mjs} +0 -0
- package/angular/esm2020/pager-items-comp.mjs +304 -0
- package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs +379 -0
- package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs.map +1 -0
- package/angular/{fesm2015/nativescript-community-ui-pager-angular.js → fesm2020/nativescript-community-ui-pager-angular.mjs} +15 -24
- package/angular/fesm2020/nativescript-community-ui-pager-angular.mjs.map +1 -0
- package/angular/package.json +20 -6
- package/index.android.js +21 -31
- package/index.android.js.map +1 -1
- package/index.common.d.ts +2 -1
- package/index.common.js +37 -42
- package/index.common.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.ios.d.ts +17 -15
- package/index.ios.js +174 -183
- package/index.ios.js.map +1 -1
- package/package.json +9 -4
- package/react/index.d.ts +5 -5
- package/react/index.js +4 -2
- package/react/index.js.map +1 -1
- package/references.d.ts +1 -0
- package/svelte/index.js +8 -7
- package/svelte/index.js.map +1 -1
- package/typings/objc!CHIPageControl.d.ts +197 -0
- package/vue/pager.js +15 -15
- package/vue/pager.js.map +1 -1
- package/.pnpm-debug.log +0 -1
- package/angular/bundles/nativescript-community-ui-pager-angular.umd.js +0 -759
- package/angular/bundles/nativescript-community-ui-pager-angular.umd.js.map +0 -1
- package/angular/esm2015/index.js +0 -55
- package/angular/esm2015/pager-items-comp.js +0 -312
- package/angular/fesm2015/nativescript-community-ui-pager-angular.js.map +0 -1
package/index.ios.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ChangeType, Color, Observable, ObservableArray, Property, ProxyViewContainer, StackLayout, Utils, View, profile } from '@nativescript/core';
|
1
|
+
import { ChangeType, Color, Observable, ObservableArray, Property, ProxyViewContainer, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
|
2
2
|
import { layout } from '@nativescript/core/utils/utils';
|
3
|
-
import { ITEMDISPOSING, ITEMLOADING, Indicator, LOADMOREITEMS, PagerBase, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, selectedIndexProperty, showIndicatorProperty } from './index.common';
|
3
|
+
import { ITEMDISPOSING, ITEMLOADING, Indicator, LOADMOREITEMS, PagerBase, PagerItem, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, selectedIndexProperty, showIndicatorProperty } from './index.common';
|
4
4
|
export * from './index.common';
|
5
5
|
export { Transformer } from './index.common';
|
6
6
|
function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
|
@@ -10,7 +10,7 @@ function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
|
|
10
10
|
index,
|
11
11
|
view,
|
12
12
|
ios: nativeView,
|
13
|
-
android: undefined
|
13
|
+
android: undefined
|
14
14
|
};
|
15
15
|
owner.notify(args);
|
16
16
|
return args;
|
@@ -67,37 +67,33 @@ export class Pager extends PagerBase {
|
|
67
67
|
constructor() {
|
68
68
|
super();
|
69
69
|
this.lastEvent = 0;
|
70
|
-
this.
|
71
|
-
this.
|
72
|
-
this.
|
73
|
-
this.
|
74
|
-
this.
|
75
|
-
this.
|
76
|
-
this.
|
70
|
+
this.mDisableSwipe = false;
|
71
|
+
this.mDisableAnimation = false;
|
72
|
+
this.mPreparingCell = false;
|
73
|
+
this.mIsRefreshing = false;
|
74
|
+
this.mIsInit = false;
|
75
|
+
this.mInnerWidth = 0;
|
76
|
+
this.mInnerHeight = 0;
|
77
77
|
this._observableArrayHandler = (args) => {
|
78
78
|
if (!this.pager) {
|
79
79
|
return;
|
80
80
|
}
|
81
|
-
if (this.indicatorView &&
|
82
|
-
this.
|
83
|
-
this._observableArrayInstance.length) {
|
84
|
-
this.indicatorView.numberOfPages = this._observableArrayInstance.length;
|
81
|
+
if (this.indicatorView && this.mObservableArrayInstance && this.mObservableArrayInstance.length) {
|
82
|
+
this.indicatorView.numberOfPages = this.mObservableArrayInstance.length;
|
85
83
|
}
|
86
84
|
const collectionView = this.pager;
|
87
85
|
if (collectionView) {
|
88
86
|
try {
|
89
87
|
let offset = 0;
|
90
88
|
collectionView.performBatchUpdatesCompletion(() => {
|
91
|
-
this.
|
89
|
+
this.mIsRefreshing = true;
|
92
90
|
const array = [];
|
93
91
|
switch (args.action) {
|
94
92
|
case ChangeType.Add:
|
95
93
|
for (let i = 0; i < args.addedCount; i++) {
|
96
94
|
array.push(NSIndexPath.indexPathForRowInSection(args.index + i, 0));
|
97
95
|
}
|
98
|
-
offset =
|
99
|
-
collectionView.contentSize.width -
|
100
|
-
collectionView.contentOffset.x;
|
96
|
+
offset = collectionView.contentSize.width - collectionView.contentOffset.x;
|
101
97
|
collectionView.insertItemsAtIndexPaths(array);
|
102
98
|
break;
|
103
99
|
case ChangeType.Delete:
|
@@ -122,16 +118,14 @@ export class Pager extends PagerBase {
|
|
122
118
|
}
|
123
119
|
break;
|
124
120
|
case ChangeType.Update:
|
125
|
-
collectionView.reloadItemsAtIndexPaths([
|
126
|
-
NSIndexPath.indexPathForRowInSection(args.index, 0),
|
127
|
-
]);
|
121
|
+
collectionView.reloadItemsAtIndexPaths([NSIndexPath.indexPathForRowInSection(args.index, 0)]);
|
128
122
|
break;
|
129
123
|
default:
|
130
124
|
break;
|
131
125
|
}
|
132
126
|
this._initAutoPlay(this.autoPlay);
|
133
127
|
if (this.itemCount === 0) {
|
134
|
-
this.
|
128
|
+
this.mIsInit = false;
|
135
129
|
}
|
136
130
|
}, null);
|
137
131
|
}
|
@@ -140,21 +134,20 @@ export class Pager extends PagerBase {
|
|
140
134
|
};
|
141
135
|
this._isDataDirty = false;
|
142
136
|
this.iosOverflowSafeAreaEnabledLayoutHackNeeded = true;
|
143
|
-
this.
|
137
|
+
this.mMap = new Map();
|
144
138
|
}
|
145
139
|
get pager() {
|
146
|
-
return this.
|
140
|
+
return this.mPager;
|
147
141
|
}
|
148
142
|
get indicatorView() {
|
149
|
-
return this.
|
143
|
+
return this.mIndicatorView;
|
150
144
|
}
|
151
145
|
createNativeView() {
|
152
146
|
const nativeView = UIView.new();
|
153
|
-
this.
|
154
|
-
this.
|
155
|
-
|
156
|
-
this.
|
157
|
-
const pager = this._pager = UICollectionView.alloc().initWithFrameCollectionViewLayout(CGRectZero, this._layout);
|
147
|
+
this.mLayout = UICollectionViewFlowLinearLayoutImpl.initWithOwner(new WeakRef(this));
|
148
|
+
this.mLayout.scrollDirection = 1;
|
149
|
+
this.mLayout.minimumInteritemSpacing = 0;
|
150
|
+
const pager = (this.mPager = UICollectionView.alloc().initWithFrameCollectionViewLayout(CGRectZero, this.mLayout));
|
158
151
|
pager.backgroundColor = UIColor.clearColor;
|
159
152
|
pager.autoresizesSubviews = false;
|
160
153
|
pager.autoresizingMask = 0;
|
@@ -168,38 +161,31 @@ export class Pager extends PagerBase {
|
|
168
161
|
super.initNativeView();
|
169
162
|
const nativeView = this.pager;
|
170
163
|
nativeView.registerClassForCellWithReuseIdentifier(PagerCell.class(), this._defaultTemplate.key);
|
171
|
-
nativeView.
|
164
|
+
nativeView.backgroundColor = UIColor.clearColor;
|
165
|
+
nativeView.autoresizesSubviews = false;
|
166
|
+
nativeView.autoresizingMask = 0;
|
167
|
+
nativeView.dataSource = this.mDataSource = UICollectionViewDataSourceImpl.initWithOwner(new WeakRef(this));
|
172
168
|
nativeView.scrollEnabled = !this.disableSwipe;
|
173
169
|
if (this.orientation === 'vertical') {
|
174
|
-
this.
|
175
|
-
0;
|
170
|
+
this.mLayout.scrollDirection = 0;
|
176
171
|
nativeView.alwaysBounceVertical = true;
|
177
172
|
nativeView.alwaysBounceHorizontal = false;
|
178
173
|
}
|
179
174
|
else {
|
180
|
-
this.
|
181
|
-
1;
|
175
|
+
this.mLayout.scrollDirection = 1;
|
182
176
|
nativeView.alwaysBounceHorizontal = true;
|
183
177
|
nativeView.alwaysBounceVertical = false;
|
184
178
|
}
|
185
179
|
this._setIndicator(this.indicator);
|
186
|
-
this.
|
180
|
+
this.mDelegate = UICollectionDelegateImpl.initWithOwner(new WeakRef(this));
|
187
181
|
this._setNativeClipToBounds();
|
188
182
|
this._initAutoPlay(this.autoPlay);
|
189
183
|
}
|
190
184
|
_getRealWidthHeight() {
|
191
185
|
let height = 0;
|
192
186
|
let width = 0;
|
193
|
-
width =
|
194
|
-
|
195
|
-
(this.perPage * 2 * this._getSpacing() +
|
196
|
-
this._getPeaking() * 2)) /
|
197
|
-
this.perPage;
|
198
|
-
height =
|
199
|
-
(layout.toDeviceIndependentPixels(this._effectiveItemHeight) -
|
200
|
-
(this.perPage * 2 * this._getSpacing() +
|
201
|
-
this._getPeaking() * 2)) /
|
202
|
-
this.perPage;
|
187
|
+
width = (layout.toDeviceIndependentPixels(this._effectiveItemWidth) - (this.perPage * 2 * this._getSpacing() + this._getPeaking() * 2)) / this.perPage;
|
188
|
+
height = (layout.toDeviceIndependentPixels(this._effectiveItemHeight) - (this.perPage * 2 * this._getSpacing() + this._getPeaking() * 2)) / this.perPage;
|
203
189
|
return { height, width };
|
204
190
|
}
|
205
191
|
_nextIndex() {
|
@@ -248,9 +234,7 @@ export class Pager extends PagerBase {
|
|
248
234
|
return position;
|
249
235
|
}
|
250
236
|
get itemCount() {
|
251
|
-
return this._childrenCount
|
252
|
-
? this._childrenCount + (this.circularMode ? 2 : 0)
|
253
|
-
: 0;
|
237
|
+
return this._childrenCount ? this._childrenCount + (this.circularMode ? 2 : 0) : 0;
|
254
238
|
}
|
255
239
|
get lastIndex() {
|
256
240
|
if (this.items && this.items.length === 0) {
|
@@ -269,33 +253,47 @@ export class Pager extends PagerBase {
|
|
269
253
|
return this.lastIndex;
|
270
254
|
}
|
271
255
|
_setIndicator(value) {
|
272
|
-
if (this.
|
273
|
-
this.
|
256
|
+
if (this.mIndicatorView) {
|
257
|
+
this.mIndicatorView.removeFromSuperview();
|
274
258
|
}
|
275
259
|
switch (value) {
|
276
260
|
case Indicator.None:
|
277
|
-
this.
|
261
|
+
this.mIndicatorView = CHIPageControlAji.new();
|
278
262
|
break;
|
279
263
|
case Indicator.Worm:
|
280
|
-
this.
|
264
|
+
this.mIndicatorView = CHIPageControlAleppo.new();
|
281
265
|
break;
|
282
266
|
case Indicator.Fill:
|
283
|
-
this.
|
267
|
+
this.mIndicatorView = CHIPageControlChimayo.new();
|
284
268
|
break;
|
285
269
|
case Indicator.Swap:
|
286
|
-
this.
|
270
|
+
this.mIndicatorView = CHIPageControlPuya.new();
|
287
271
|
break;
|
288
272
|
case Indicator.THIN_WORM:
|
289
|
-
this.
|
273
|
+
this.mIndicatorView = CHIPageControlJalapeno.new();
|
290
274
|
break;
|
291
275
|
case Indicator.Flat:
|
292
|
-
this.
|
276
|
+
this.mIndicatorView = CHIPageControlJaloro.new();
|
293
277
|
break;
|
294
278
|
default:
|
295
279
|
break;
|
296
280
|
}
|
297
|
-
this.
|
298
|
-
this.
|
281
|
+
this.mIndicatorView.tintColor = UIColor.whiteColor;
|
282
|
+
this.mIndicatorView.currentPageTintColor = UIColor.whiteColor;
|
283
|
+
switch (value) {
|
284
|
+
case Indicator.None:
|
285
|
+
case Indicator.Worm:
|
286
|
+
case Indicator.Fill:
|
287
|
+
case Indicator.Swap:
|
288
|
+
case Indicator.THIN_WORM:
|
289
|
+
case Indicator.Disabled:
|
290
|
+
this.mIndicatorView.radius = 4;
|
291
|
+
break;
|
292
|
+
case Indicator.Flat:
|
293
|
+
this.mIndicatorView.radius = 2;
|
294
|
+
this.mIndicatorView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.7, 0.5);
|
295
|
+
break;
|
296
|
+
}
|
299
297
|
}
|
300
298
|
get _childrenCount() {
|
301
299
|
var _a, _b;
|
@@ -307,25 +305,21 @@ export class Pager extends PagerBase {
|
|
307
305
|
}
|
308
306
|
[orientationProperty.setNative](value) {
|
309
307
|
if (value === 'horizontal') {
|
310
|
-
this.
|
311
|
-
1;
|
308
|
+
this.mLayout.scrollDirection = 1;
|
312
309
|
}
|
313
310
|
else {
|
314
|
-
this.
|
315
|
-
0;
|
311
|
+
this.mLayout.scrollDirection = 0;
|
316
312
|
}
|
317
313
|
}
|
318
314
|
eachChildView(callback) {
|
319
|
-
this.
|
315
|
+
this.mMap.forEach((view, key) => callback(view));
|
320
316
|
}
|
321
317
|
eachChild(callback) {
|
322
|
-
this.
|
318
|
+
this.mMap.forEach((view, key) => callback(view));
|
323
319
|
}
|
324
320
|
_updateScrollPosition() {
|
325
321
|
const view = this.pager;
|
326
|
-
const size = this.orientation === 'vertical'
|
327
|
-
? view.contentSize.height
|
328
|
-
: view.contentSize.width;
|
322
|
+
const size = this.orientation === 'vertical' ? view.contentSize.height : view.contentSize.width;
|
329
323
|
if (!view || size === 0) {
|
330
324
|
return;
|
331
325
|
}
|
@@ -352,19 +346,19 @@ export class Pager extends PagerBase {
|
|
352
346
|
if (this.indicatorView && value && value.length) {
|
353
347
|
this.indicatorView.numberOfPages = value.length;
|
354
348
|
}
|
355
|
-
if (this.
|
356
|
-
this.
|
357
|
-
this.
|
349
|
+
if (this.mObservableArrayInstance) {
|
350
|
+
this.mObservableArrayInstance.off(ObservableArray.changeEvent, this._observableArrayHandler);
|
351
|
+
this.mObservableArrayInstance = null;
|
358
352
|
}
|
359
353
|
if (value instanceof ObservableArray) {
|
360
|
-
this.
|
361
|
-
this.
|
354
|
+
this.mObservableArrayInstance = value;
|
355
|
+
this.mObservableArrayInstance.on(ObservableArray.changeEvent, this._observableArrayHandler);
|
362
356
|
}
|
363
357
|
else {
|
364
358
|
this.refresh();
|
365
359
|
}
|
366
360
|
if (!value) {
|
367
|
-
this.
|
361
|
+
this.mIsInit = false;
|
368
362
|
}
|
369
363
|
selectedIndexProperty.coerce(this);
|
370
364
|
}
|
@@ -385,8 +379,7 @@ export class Pager extends PagerBase {
|
|
385
379
|
if (!this.nativeView) {
|
386
380
|
return;
|
387
381
|
}
|
388
|
-
this.indicatorView.center = CGPointMake(this.nativeView.center.x, this.nativeView.bounds.size.height -
|
389
|
-
this.indicatorView.intrinsicContentSize.height);
|
382
|
+
this.indicatorView.center = CGPointMake(this.nativeView.center.x, this.nativeView.bounds.size.height - this.indicatorView.intrinsicContentSize.height);
|
390
383
|
const hasParent = this.indicatorView.superview;
|
391
384
|
if (value) {
|
392
385
|
if (!hasParent) {
|
@@ -404,9 +397,7 @@ export class Pager extends PagerBase {
|
|
404
397
|
if (!this.pager)
|
405
398
|
return;
|
406
399
|
const contentSize = this.pager.contentSize;
|
407
|
-
const size = this.orientation === 'vertical'
|
408
|
-
? contentSize.height
|
409
|
-
: contentSize.width;
|
400
|
+
const size = this.orientation === 'vertical' ? contentSize.height : contentSize.width;
|
410
401
|
if (size === 0) {
|
411
402
|
return;
|
412
403
|
}
|
@@ -429,10 +420,8 @@ export class Pager extends PagerBase {
|
|
429
420
|
}
|
430
421
|
}
|
431
422
|
dispatch_async(main_queue, () => {
|
432
|
-
if (this.
|
433
|
-
this.pager.scrollToItemAtIndexPathAtScrollPositionAnimated(NSIndexPath.indexPathForItemInSection(maxMinIndex, 0), this.orientation === 'vertical'
|
434
|
-
? 2
|
435
|
-
: 16, !!animate);
|
423
|
+
if (this.mDataSource.collectionViewNumberOfItemsInSection(this.pager, 0) > maxMinIndex) {
|
424
|
+
this.pager.scrollToItemAtIndexPathAtScrollPositionAnimated(NSIndexPath.indexPathForItemInSection(maxMinIndex, 0), this.orientation === 'vertical' ? 2 : 16, !!animate);
|
436
425
|
}
|
437
426
|
selectedIndexProperty.nativeValueChange(this, maxMinIndex);
|
438
427
|
});
|
@@ -446,8 +435,8 @@ export class Pager extends PagerBase {
|
|
446
435
|
return;
|
447
436
|
}
|
448
437
|
this._isDataDirty = false;
|
449
|
-
this.
|
450
|
-
this.
|
438
|
+
this.mLastLayoutKey = this.mInnerWidth + '_' + this.mInnerHeight;
|
439
|
+
this.mMap.forEach((view, nativeView, map) => {
|
451
440
|
if (!(view.bindingContext instanceof Observable)) {
|
452
441
|
view.bindingContext = null;
|
453
442
|
}
|
@@ -462,10 +451,10 @@ export class Pager extends PagerBase {
|
|
462
451
|
if (this.showIndicator && this.indicatorView) {
|
463
452
|
this.nativeView.addSubview(this.indicatorView);
|
464
453
|
}
|
465
|
-
if (this._isDataDirty && this.
|
454
|
+
if (this._isDataDirty && this.mInnerWidth !== undefined && this.mInnerHeight !== undefined) {
|
466
455
|
this.refresh();
|
467
456
|
}
|
468
|
-
this.pager.delegate = this.
|
457
|
+
this.pager.delegate = this.mDelegate;
|
469
458
|
if (!this.items && this._childrenCount > 0) {
|
470
459
|
selectedIndexProperty.coerce(this);
|
471
460
|
this._updateScrollPosition();
|
@@ -478,42 +467,78 @@ export class Pager extends PagerBase {
|
|
478
467
|
super.onUnloaded();
|
479
468
|
}
|
480
469
|
disposeNativeView() {
|
481
|
-
this.
|
482
|
-
this.
|
483
|
-
this.
|
484
|
-
|
485
|
-
this.
|
486
|
-
|
487
|
-
|
470
|
+
this.mDelegate = null;
|
471
|
+
this.mDataSource = null;
|
472
|
+
if (this.mPager) {
|
473
|
+
this.mPager.delegate = null;
|
474
|
+
this.mPager = null;
|
475
|
+
}
|
476
|
+
this.mIndicatorView = null;
|
477
|
+
this.mLayout = null;
|
478
|
+
if (this.mObservableArrayInstance) {
|
479
|
+
this.mObservableArrayInstance.off(ObservableArray.changeEvent, this._observableArrayHandler);
|
480
|
+
this.mObservableArrayInstance = null;
|
481
|
+
}
|
482
|
+
this.clearRealizedCells();
|
488
483
|
super.disposeNativeView();
|
489
484
|
}
|
485
|
+
clearRealizedCells() {
|
486
|
+
const that = new WeakRef(this);
|
487
|
+
this.mMap.forEach(function (value, key) {
|
488
|
+
that.get()._removeContainer(key);
|
489
|
+
that.get()._clearCellViews(key);
|
490
|
+
}, that);
|
491
|
+
this.mMap.clear();
|
492
|
+
}
|
493
|
+
_clearCellViews(cell) {
|
494
|
+
const view = cell.view;
|
495
|
+
if (!view) {
|
496
|
+
return;
|
497
|
+
}
|
498
|
+
if (view.parent && !(view.parent instanceof Pager)) {
|
499
|
+
this._removeView(view.parent);
|
500
|
+
}
|
501
|
+
cell.owner = undefined;
|
502
|
+
const preparing = this.mPreparingCell;
|
503
|
+
this.mPreparingCell = true;
|
504
|
+
if (view.parent && !(view.parent instanceof Pager)) {
|
505
|
+
if (!(view.parent instanceof Pager)) {
|
506
|
+
this._removeView(view.parent);
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
view.parent._removeView(view);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
this.mPreparingCell = preparing;
|
513
|
+
this.mMap.delete(cell);
|
514
|
+
}
|
490
515
|
[indicatorProperty.setNative](value) {
|
491
516
|
this._setIndicator(value);
|
492
517
|
}
|
493
518
|
[indicatorColorProperty.setNative](value) {
|
494
519
|
if (this.indicatorView) {
|
495
|
-
const color =
|
520
|
+
const color = !value || value instanceof Color ? value : new Color(value);
|
496
521
|
this.indicatorView.tintColor = color ? color.ios : null;
|
497
522
|
}
|
498
523
|
}
|
499
524
|
[indicatorSelectedColorProperty.setNative](value) {
|
500
525
|
if (this.indicatorView) {
|
501
|
-
const color =
|
526
|
+
const color = !value || value instanceof Color ? value : new Color(value);
|
502
527
|
this.indicatorView.currentPageTintColor = color ? color.ios : null;
|
503
528
|
}
|
504
529
|
}
|
505
530
|
[disableSwipeProperty.setNative](value) {
|
506
|
-
this.
|
507
|
-
this.
|
531
|
+
this.mPager.scrollEnabled = !value;
|
532
|
+
this.mDisableSwipe = value;
|
508
533
|
}
|
509
534
|
[contentInsetAdjustmentBehaviorProperty.setNative](value) {
|
510
|
-
this.
|
535
|
+
this.mPager.contentInsetAdjustmentBehavior = value;
|
511
536
|
}
|
512
537
|
get disableAnimation() {
|
513
|
-
return this.
|
538
|
+
return this.mDisableAnimation;
|
514
539
|
}
|
515
540
|
set disableAnimation(value) {
|
516
|
-
this.
|
541
|
+
this.mDisableAnimation = value;
|
517
542
|
}
|
518
543
|
_removeContainer(cell, index) {
|
519
544
|
let view = cell.view;
|
@@ -523,7 +548,7 @@ export class Pager extends PagerBase {
|
|
523
548
|
index,
|
524
549
|
android: undefined,
|
525
550
|
ios: cell,
|
526
|
-
view
|
551
|
+
view
|
527
552
|
};
|
528
553
|
this.notify(args);
|
529
554
|
view = args.view;
|
@@ -533,19 +558,19 @@ export class Pager extends PagerBase {
|
|
533
558
|
}
|
534
559
|
view.parent._removeView(view);
|
535
560
|
}
|
536
|
-
this.
|
561
|
+
this.mMap.delete(cell);
|
537
562
|
}
|
538
563
|
onMeasure(widthMeasureSpec, heightMeasureSpec) {
|
539
564
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
540
|
-
this.
|
565
|
+
this.mMap.forEach((childView, pagerCell) => {
|
541
566
|
View.measureChild(this, childView, childView._currentWidthMeasureSpec, childView._currentHeightMeasureSpec);
|
542
567
|
});
|
543
568
|
}
|
544
569
|
updateInnerSize() {
|
545
570
|
const width = this.getMeasuredWidth();
|
546
571
|
const height = this.getMeasuredHeight();
|
547
|
-
this.
|
548
|
-
this.
|
572
|
+
this.mInnerWidth = width - this.effectivePaddingLeft - this.effectivePaddingRight;
|
573
|
+
this.mInnerHeight = height - this.effectivePaddingTop - this.effectivePaddingBottom;
|
549
574
|
}
|
550
575
|
onLayout(left, top, right, bottom) {
|
551
576
|
super.onLayout(left, top, right, bottom);
|
@@ -555,8 +580,7 @@ export class Pager extends PagerBase {
|
|
555
580
|
}
|
556
581
|
this.pager.frame = this.nativeView.bounds;
|
557
582
|
if (this.indicatorView && this.indicatorView.intrinsicContentSize) {
|
558
|
-
this.indicatorView.center = CGPointMake(this.nativeView.center.x, this.nativeView.bounds.size.height -
|
559
|
-
this.indicatorView.intrinsicContentSize.height);
|
583
|
+
this.indicatorView.center = CGPointMake(this.nativeView.center.x, this.nativeView.bounds.size.height - this.indicatorView.intrinsicContentSize.height);
|
560
584
|
}
|
561
585
|
const layoutView = this.pager.collectionViewLayout;
|
562
586
|
if (!layoutView) {
|
@@ -564,24 +588,24 @@ export class Pager extends PagerBase {
|
|
564
588
|
}
|
565
589
|
layoutView.invalidateLayout();
|
566
590
|
const size = this._getSize();
|
567
|
-
this.
|
591
|
+
this.mMap.forEach((childView, pagerCell) => {
|
568
592
|
const width = layout.toDevicePixels(size.width);
|
569
593
|
const height = layout.toDevicePixels(size.height);
|
570
594
|
View.layoutChild(this, childView, 0, 0, width, height);
|
571
595
|
});
|
572
|
-
const layoutKey = this.
|
573
|
-
if (this.
|
596
|
+
const layoutKey = this.mInnerWidth + '_' + this.mInnerHeight;
|
597
|
+
if (this.mLastLayoutKey !== layoutKey) {
|
574
598
|
this.refresh();
|
575
599
|
}
|
576
600
|
}
|
577
601
|
requestLayout() {
|
578
|
-
if (!this.
|
602
|
+
if (!this.mPreparingCell) {
|
579
603
|
super.requestLayout();
|
580
604
|
}
|
581
605
|
}
|
582
606
|
_prepareCell(cell, indexPath) {
|
583
607
|
try {
|
584
|
-
this.
|
608
|
+
this.mPreparingCell = true;
|
585
609
|
const index = indexPath.row;
|
586
610
|
let view = cell.view;
|
587
611
|
const template = this._getItemTemplate(indexPath.row);
|
@@ -599,7 +623,7 @@ export class Pager extends PagerBase {
|
|
599
623
|
android: undefined,
|
600
624
|
ios: cell,
|
601
625
|
view,
|
602
|
-
bindingContext
|
626
|
+
bindingContext
|
603
627
|
};
|
604
628
|
this.notify(args);
|
605
629
|
view = args.view || this._getDefaultItemContent(indexPath.row);
|
@@ -612,7 +636,7 @@ export class Pager extends PagerBase {
|
|
612
636
|
cell.owner = new WeakRef(view);
|
613
637
|
}
|
614
638
|
else if (cell.view !== view) {
|
615
|
-
this.
|
639
|
+
this.mMap.delete(cell);
|
616
640
|
this._removeContainer(cell, index);
|
617
641
|
cell.view.nativeViewProtected.removeFromSuperview();
|
618
642
|
cell.owner = new WeakRef(view);
|
@@ -620,7 +644,7 @@ export class Pager extends PagerBase {
|
|
620
644
|
if (view) {
|
621
645
|
view.bindingContext = bindingContext;
|
622
646
|
}
|
623
|
-
this.
|
647
|
+
this.mMap.set(cell, view);
|
624
648
|
if (view && !view.parent) {
|
625
649
|
this._addView(view);
|
626
650
|
if (this.iosOverflowSafeArea) {
|
@@ -636,7 +660,7 @@ export class Pager extends PagerBase {
|
|
636
660
|
this._layoutCell(view, indexPath);
|
637
661
|
}
|
638
662
|
finally {
|
639
|
-
this.
|
663
|
+
this.mPreparingCell = false;
|
640
664
|
}
|
641
665
|
}
|
642
666
|
_layoutCell(cellView, index) {
|
@@ -665,14 +689,10 @@ export class Pager extends PagerBase {
|
|
665
689
|
let width = layout.toDeviceIndependentPixels(this._effectiveItemWidth);
|
666
690
|
let height = layout.toDeviceIndependentPixels(this._effectiveItemHeight);
|
667
691
|
if (this.orientation === 'vertical') {
|
668
|
-
height =
|
669
|
-
(height - (this._getSpacing() * 2 + this._getPeaking() * 2)) /
|
670
|
-
this.perPage;
|
692
|
+
height = (height - (this._getSpacing() * 2 + this._getPeaking() * 2)) / this.perPage;
|
671
693
|
}
|
672
694
|
else {
|
673
|
-
width =
|
674
|
-
(width - (this._getSpacing() * 2 + this._getPeaking() * 2)) /
|
675
|
-
this.perPage;
|
695
|
+
width = (width - (this._getSpacing() * 2 + this._getPeaking() * 2)) / this.perPage;
|
676
696
|
}
|
677
697
|
if (Number.isNaN(width)) {
|
678
698
|
width = 0;
|
@@ -734,14 +754,14 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
734
754
|
bottom: inset,
|
735
755
|
left: 0,
|
736
756
|
right: 0,
|
737
|
-
top: inset
|
757
|
+
top: inset
|
738
758
|
});
|
739
759
|
}
|
740
760
|
return new UIEdgeInsets({
|
741
761
|
bottom: 0,
|
742
762
|
left: inset,
|
743
763
|
right: inset,
|
744
|
-
top: 0
|
764
|
+
top: 0
|
745
765
|
});
|
746
766
|
}
|
747
767
|
return new UIEdgeInsets({ bottom: 0, left: 0, right: 0, top: 0 });
|
@@ -756,15 +776,14 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
756
776
|
UICollectionDelegateImpl.prototype.collectionViewWillDisplayCellForItemAtIndexPath = function (collectionView, cell, indexPath) {
|
757
777
|
var owner = this._owner && this._owner.get();
|
758
778
|
if (owner) {
|
759
|
-
if (!owner.
|
779
|
+
if (!owner.mIsInit) {
|
760
780
|
owner._updateScrollPosition();
|
761
|
-
owner.
|
781
|
+
owner.mIsInit = true;
|
762
782
|
}
|
763
|
-
if (owner.items &&
|
764
|
-
indexPath.row === owner.lastIndex - owner.loadMoreCount) {
|
783
|
+
if (owner.items && indexPath.row === owner.lastIndex - owner.loadMoreCount) {
|
765
784
|
owner.notify({
|
766
785
|
eventName: LOADMOREITEMS,
|
767
|
-
object: owner
|
786
|
+
object: owner
|
768
787
|
});
|
769
788
|
}
|
770
789
|
}
|
@@ -788,7 +807,7 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
788
807
|
if (owner.lastEvent === 0) {
|
789
808
|
owner.notify({
|
790
809
|
eventName: Pager.swipeStartEvent,
|
791
|
-
object: owner
|
810
|
+
object: owner
|
792
811
|
});
|
793
812
|
owner.lastEvent = 1;
|
794
813
|
}
|
@@ -799,7 +818,7 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
799
818
|
if (owner) {
|
800
819
|
owner.notify({
|
801
820
|
eventName: Pager.swipeEvent,
|
802
|
-
object: owner
|
821
|
+
object: owner
|
803
822
|
});
|
804
823
|
}
|
805
824
|
};
|
@@ -813,21 +832,16 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
813
832
|
if (owner.orientation === 'vertical') {
|
814
833
|
width = size.height;
|
815
834
|
offset = scrollView.contentOffset.y;
|
816
|
-
total =
|
817
|
-
scrollView.contentSize.height -
|
818
|
-
scrollView.bounds.size.height;
|
835
|
+
total = scrollView.contentSize.height - scrollView.bounds.size.height;
|
819
836
|
}
|
820
837
|
else {
|
821
838
|
width = size.width;
|
822
839
|
offset = scrollView.contentOffset.x;
|
823
|
-
total =
|
824
|
-
scrollView.contentSize.width - scrollView.bounds.size.width;
|
840
|
+
total = scrollView.contentSize.width - scrollView.bounds.size.width;
|
825
841
|
}
|
826
842
|
var percent = offset / total;
|
827
843
|
var progress = percent * (owner.itemCount - 1);
|
828
|
-
if (owner.indicatorView &&
|
829
|
-
owner.indicatorView.setWithProgressAnimated &&
|
830
|
-
!Number.isNaN(progress)) {
|
844
|
+
if (owner.indicatorView && owner.indicatorView.setWithProgressAnimated && !Number.isNaN(progress)) {
|
831
845
|
owner.indicatorView.progress = progress;
|
832
846
|
}
|
833
847
|
var index = parseInt(progress.toFixed(0), 10);
|
@@ -840,12 +854,12 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
840
854
|
selectedIndex: Math.floor(progress),
|
841
855
|
currentPosition: progress,
|
842
856
|
scrollX: owner.horizontalOffset,
|
843
|
-
scrollY: owner.verticalOffset
|
857
|
+
scrollY: owner.verticalOffset
|
844
858
|
});
|
845
859
|
if (owner.lastEvent === 1) {
|
846
860
|
owner.notify({
|
847
861
|
eventName: Pager.swipeOverEvent,
|
848
|
-
object: owner
|
862
|
+
object: owner
|
849
863
|
});
|
850
864
|
owner.lastEvent = 1;
|
851
865
|
}
|
@@ -923,8 +937,7 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
923
937
|
// (owner.nativeView as UICollectionView).setContentOffsetAnimated(CGPointMake((w * width) + 1, 0),false);
|
924
938
|
}
|
925
939
|
};
|
926
|
-
UICollectionDelegateImpl.prototype.scrollViewDidEndDraggingWillDecelerate = function (scrollView, decelerate) {
|
927
|
-
};
|
940
|
+
UICollectionDelegateImpl.prototype.scrollViewDidEndDraggingWillDecelerate = function (scrollView, decelerate) { };
|
928
941
|
UICollectionDelegateImpl.prototype.scrollViewWillEndDraggingWithVelocityTargetContentOffset = function (scrollView, velocity, targetContentOffset) {
|
929
942
|
var owner = this._owner ? this._owner.get() : null;
|
930
943
|
if (!owner)
|
@@ -932,7 +945,7 @@ var UICollectionDelegateImpl = /** @class */ (function (_super) {
|
|
932
945
|
if (owner.lastEvent === 1) {
|
933
946
|
owner.notify({
|
934
947
|
eventName: Pager.swipeEndEvent,
|
935
|
-
object: owner
|
948
|
+
object: owner
|
936
949
|
});
|
937
950
|
owner.lastEvent = 0;
|
938
951
|
}
|
@@ -979,10 +992,9 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
979
992
|
var index = indexPath.row;
|
980
993
|
var data = owner._childrenViews[index];
|
981
994
|
var viewType = data.type;
|
982
|
-
owner.
|
983
|
-
collectionView.registerClassForCellWithReuseIdentifier(PagerCell.class(), "static-"
|
984
|
-
cell =
|
985
|
-
collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath("static-" + viewType, indexPath) || PagerCell.initWithEmptyBackground();
|
995
|
+
owner.mPreparingCell = true;
|
996
|
+
collectionView.registerClassForCellWithReuseIdentifier(PagerCell.class(), "static-".concat(viewType));
|
997
|
+
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath("static-".concat(viewType), indexPath) || PagerCell.initWithEmptyBackground();
|
986
998
|
cell.index = index;
|
987
999
|
var view = data.view;
|
988
1000
|
// if (view instanceof ProxyViewContainer) {
|
@@ -996,7 +1008,7 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
996
1008
|
}
|
997
1009
|
else if (cell.view !== view) {
|
998
1010
|
owner._removeView(view);
|
999
|
-
cell.view.nativeViewProtected.removeFromSuperview();
|
1011
|
+
// (cell.view.nativeViewProtected as UIView).removeFromSuperview();
|
1000
1012
|
cell.owner = new WeakRef(view);
|
1001
1013
|
}
|
1002
1014
|
if (view && !view.parent) {
|
@@ -1017,7 +1029,7 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
1017
1029
|
innerView.view = new WeakRef(view);
|
1018
1030
|
innerView.addSubview(view.nativeViewProtected);
|
1019
1031
|
cell.contentView.addSubview(innerView);
|
1020
|
-
owner.
|
1032
|
+
owner.mMap.set(cell, view);
|
1021
1033
|
// } else {
|
1022
1034
|
// cell.contentView.addSubview(view.nativeViewProtected);
|
1023
1035
|
// }
|
@@ -1031,12 +1043,11 @@ var UICollectionViewDataSourceImpl = /** @class */ (function (_super) {
|
|
1031
1043
|
if (view && view.isLayoutRequired) {
|
1032
1044
|
View.layoutChild(owner, view, 0, 0, width, height);
|
1033
1045
|
}
|
1034
|
-
owner.
|
1046
|
+
owner.mPreparingCell = false;
|
1035
1047
|
return cell;
|
1036
1048
|
}
|
1037
1049
|
var template = owner && owner._getItemTemplate(indexPath.row);
|
1038
|
-
cell =
|
1039
|
-
collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(template.key, indexPath) || PagerCell.initWithEmptyBackground();
|
1050
|
+
cell = collectionView.dequeueReusableCellWithReuseIdentifierForIndexPath(template.key, indexPath) || PagerCell.initWithEmptyBackground();
|
1040
1051
|
cell.index = indexPath;
|
1041
1052
|
if (owner) {
|
1042
1053
|
var size = owner._getSize();
|
@@ -1083,8 +1094,7 @@ var UICollectionViewFlowLinearLayoutImpl = /** @class */ (function (_super) {
|
|
1083
1094
|
var originalLayoutAttribute = _super.prototype.layoutAttributesForElementsInRect.call(this, rect);
|
1084
1095
|
var visibleLayoutAttributes = [];
|
1085
1096
|
if (owner) {
|
1086
|
-
if (owner.transformers &&
|
1087
|
-
owner.transformers.indexOf('scale') > -1) {
|
1097
|
+
if (owner.transformers && owner.transformers.indexOf('scale') > -1) {
|
1088
1098
|
var count = originalLayoutAttribute.count;
|
1089
1099
|
for (var i = 0; i < count; i++) {
|
1090
1100
|
var attributes = originalLayoutAttribute.objectAtIndex(i);
|
@@ -1095,13 +1105,8 @@ var UICollectionViewFlowLinearLayoutImpl = /** @class */ (function (_super) {
|
|
1095
1105
|
attributes.frame.size.width = width;
|
1096
1106
|
attributes.frame.size.height = height;
|
1097
1107
|
var spacing = owner.convertToSize(owner.spacing);
|
1098
|
-
var distance = Math.abs(this.collectionView.contentOffset.x +
|
1099
|
-
|
1100
|
-
spacing -
|
1101
|
-
frame.origin.x);
|
1102
|
-
var scale = Math.min(Math.max(1 -
|
1103
|
-
distance /
|
1104
|
-
this.collectionView.bounds.size.width, 0.75), 1);
|
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);
|
1105
1110
|
attributes.transform = CGAffineTransformScale(attributes.transform, 1, scale);
|
1106
1111
|
}
|
1107
1112
|
}
|
@@ -1136,22 +1141,15 @@ var UICollectionViewFlowLinearLayoutImpl = /** @class */ (function (_super) {
|
|
1136
1141
|
// Make an estimation of the current page position.
|
1137
1142
|
var approximatePage = this.collectionView.contentOffset.x / pageWidth;
|
1138
1143
|
// Determine the current page based on velocity.
|
1139
|
-
var currentPage = velocity.x === 0
|
1140
|
-
? Math.round(approximatePage)
|
1141
|
-
: velocity.x < 0.0
|
1142
|
-
? Math.floor(approximatePage)
|
1143
|
-
: Math.ceil(approximatePage);
|
1144
|
+
var currentPage = velocity.x === 0 ? Math.round(approximatePage) : velocity.x < 0.0 ? Math.floor(approximatePage) : Math.ceil(approximatePage);
|
1144
1145
|
// Create custom flickVelocity.
|
1145
1146
|
var flickVelocity = velocity.x * 0.3;
|
1146
1147
|
// Check how many pages the user flicked, if <= 1 then flickedPages should return 0.
|
1147
|
-
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1
|
1148
|
-
? 0
|
1149
|
-
: Math.round(flickVelocity);
|
1148
|
+
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1150
1149
|
var newPageIndex = currentPage + flickedPages;
|
1151
1150
|
selectedIndexProperty.nativeValueChange(owner, Math.min(Math.max(newPageIndex, 0), owner._childrenCount - 1));
|
1152
1151
|
// Calculate newHorizontalOffset.
|
1153
|
-
var newHorizontalOffset = newPageIndex * pageWidth -
|
1154
|
-
this.collectionView.contentInset.left;
|
1152
|
+
var newHorizontalOffset = newPageIndex * pageWidth - this.collectionView.contentInset.left;
|
1155
1153
|
return CGPointMake(newHorizontalOffset, proposedContentOffset.y);
|
1156
1154
|
}
|
1157
1155
|
else {
|
@@ -1161,21 +1159,14 @@ var UICollectionViewFlowLinearLayoutImpl = /** @class */ (function (_super) {
|
|
1161
1159
|
// Make an estimation of the current page position.
|
1162
1160
|
var approximatePage = Math.max(0, this.collectionView.contentOffset.y / pageHeight);
|
1163
1161
|
// Determine the current page based on velocity.
|
1164
|
-
var currentPage = velocity.y === 0
|
1165
|
-
? Math.round(approximatePage)
|
1166
|
-
: velocity.y < 0.0
|
1167
|
-
? Math.floor(approximatePage)
|
1168
|
-
: Math.ceil(approximatePage);
|
1162
|
+
var currentPage = velocity.y === 0 ? Math.round(approximatePage) : velocity.y < 0.0 ? Math.floor(approximatePage) : Math.ceil(approximatePage);
|
1169
1163
|
// Create custom flickVelocity.
|
1170
1164
|
var flickVelocity = velocity.y * 0.3;
|
1171
1165
|
// Check how many pages the user flicked, if <= 1 then flickedPages should return 0.
|
1172
|
-
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1
|
1173
|
-
? 0
|
1174
|
-
: Math.round(flickVelocity);
|
1166
|
+
var flickedPages = Math.abs(Math.round(flickVelocity)) <= 1 ? 0 : Math.round(flickVelocity);
|
1175
1167
|
var newPageIndex = currentPage + flickedPages;
|
1176
1168
|
selectedIndexProperty.nativeValueChange(owner, Math.min(Math.max(newPageIndex, 0), owner._childrenCount - 1));
|
1177
|
-
var newVerticalOffset = newPageIndex * pageHeight -
|
1178
|
-
this.collectionView.contentInset.top;
|
1169
|
+
var newVerticalOffset = newPageIndex * pageHeight - this.collectionView.contentInset.top;
|
1179
1170
|
return CGPointMake(proposedContentOffset.x, newVerticalOffset);
|
1180
1171
|
}
|
1181
1172
|
};
|