@nativescript-community/ui-pager 13.0.44 → 14.0.1
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/README.md +2 -55
- package/angular/esm2020/index.mjs +4 -4
- package/angular/esm2020/nativescript-community-ui-pager-angular.mjs +4 -1
- package/angular/esm2020/pager-items-comp.mjs +11 -4
- package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs +17 -6
- package/angular/fesm2015/nativescript-community-ui-pager-angular.mjs.map +1 -1
- package/angular/fesm2020/nativescript-community-ui-pager-angular.mjs +17 -6
- package/angular/fesm2020/nativescript-community-ui-pager-angular.mjs.map +1 -1
- package/index.android.d.ts +4 -9
- package/index.android.js +164 -211
- package/index.android.js.map +1 -1
- package/index.common.d.ts +14 -17
- package/index.common.js +35 -32
- package/index.common.js.map +1 -1
- package/index.ios.d.ts +3 -9
- package/index.ios.js +107 -174
- package/index.ios.js.map +1 -1
- package/package.json +10 -10
- package/platforms/android/include.gradle +0 -13
- package/platforms/android/native-api-usage.json +1 -6
- package/platforms/ios/native-api-usage.json +0 -1
- package/react/index.d.ts +2 -0
- package/react/index.js +27 -3
- package/react/index.js.map +1 -1
- package/references.d.ts +1 -2
- package/svelte/index.js +11 -1
- package/svelte/index.js.map +1 -1
- package/typings/viewpager2.d.ts +1 -1
- package/vue/pager.js +8 -1
- package/vue/pager.js.map +1 -1
- package/.pnpm-debug.log +0 -1
- package/CHANGELOG.md +0 -358
- package/platforms/ios/Podfile +0 -1
- package/typings/objc!CHIPageControl.d.ts +0 -197
package/index.android.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { ChangeType, Color, Device, ObservableArray, Property, Screen, StackLayout, View, ViewBase, profile } from '@nativescript/core';
|
1
|
+
import { ChangeType, Color, Device, ObservableArray, Property, Screen, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
|
2
2
|
import { isString } from '@nativescript/core/utils/types';
|
3
|
-
import {
|
4
|
-
import { Indicator, PagerBase, Transformer, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, indicatorColorProperty, indicatorProperty, indicatorSelectedColorProperty, itemTemplatesProperty, itemsProperty, orientationProperty, peakingProperty, selectedIndexProperty, showIndicatorProperty, spacingProperty } from './index.common';
|
3
|
+
import { PagerBase, Transformer, autoPlayProperty, autoplayDelayProperty, disableSwipeProperty, itemTemplatesProperty, itemsProperty, orientationProperty, peakingProperty, selectedIndexProperty, spacingProperty } 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) {
|
@@ -18,9 +17,12 @@ function notifyForItemAtIndex(owner, nativeView, view, eventName, index) {
|
|
18
17
|
}
|
19
18
|
const PLACEHOLDER = 'PLACEHOLDER';
|
20
19
|
export class Pager extends PagerBase {
|
20
|
+
// private _pager: androidx.viewpager2.widget.ViewPager2;
|
21
21
|
constructor() {
|
22
22
|
super();
|
23
23
|
this._oldDisableAnimation = false;
|
24
|
+
// used to store viewHolder and thus their corresponding Views
|
25
|
+
// used to "destroy" cells when possible
|
24
26
|
this._viewHolders = new Set();
|
25
27
|
this._childrenViewsType = new Map();
|
26
28
|
this._realizedTemplates = new Map();
|
@@ -29,10 +31,6 @@ export class Pager extends PagerBase {
|
|
29
31
|
this._lastPeaking = 0;
|
30
32
|
this._selectedIndexBeforeLoad = 0;
|
31
33
|
this._observableArrayHandler = (args) => {
|
32
|
-
if (this.indicatorView && this.showIndicator) {
|
33
|
-
this.indicatorView.setCount(this._childrenCount);
|
34
|
-
this.indicatorView.setSelected(args.index);
|
35
|
-
}
|
36
34
|
if (this.pagerAdapter) {
|
37
35
|
switch (args.action) {
|
38
36
|
case ChangeType.Add:
|
@@ -69,69 +67,54 @@ export class Pager extends PagerBase {
|
|
69
67
|
set views(value) {
|
70
68
|
this._views = value;
|
71
69
|
}
|
72
|
-
get pager() {
|
73
|
-
return this._pager;
|
74
|
-
}
|
75
|
-
get indicatorView() {
|
76
|
-
return this._indicatorView;
|
77
|
-
}
|
78
70
|
createNativeView() {
|
79
|
-
const nativeView = new
|
80
|
-
this._pager = new androidx.viewpager2.widget.ViewPager2(this._context);
|
71
|
+
const nativeView = new androidx.viewpager2.widget.ViewPager2(this._context);
|
81
72
|
const sdkVersion = parseInt(Device.sdkVersion, 10);
|
82
73
|
if (sdkVersion >= 21) {
|
83
|
-
|
74
|
+
nativeView.setNestedScrollingEnabled(true);
|
84
75
|
}
|
85
76
|
if (this.orientation === 'vertical') {
|
86
|
-
|
77
|
+
nativeView.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_VERTICAL);
|
87
78
|
}
|
88
79
|
else {
|
89
|
-
|
80
|
+
nativeView.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL);
|
90
81
|
}
|
91
82
|
initPagerRecyclerAdapter();
|
92
83
|
this._pagerAdapter = new PagerRecyclerAdapter(new WeakRef(this));
|
93
84
|
this.compositeTransformer = new androidx.viewpager2.widget.CompositePageTransformer();
|
94
|
-
|
85
|
+
nativeView.setUserInputEnabled(!this.disableSwipe);
|
95
86
|
this.on(View.layoutChangedEvent, this.onLayoutChange, this);
|
96
|
-
const LayoutParams = android.widget.RelativeLayout.LayoutParams;
|
97
|
-
nativeView.addView(this.pager, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
98
|
-
this._indicatorView = new com.rd.PageIndicatorView2(this._context);
|
99
|
-
const params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
100
|
-
params.addRule(android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM);
|
101
|
-
params.addRule(android.widget.RelativeLayout.CENTER_HORIZONTAL);
|
102
|
-
params.setMargins(0, 0, 0, 10 * Screen.mainScreen.scale);
|
103
|
-
this._indicatorView.setLayoutParams(params);
|
104
|
-
this._indicatorView.setDynamicCount(true);
|
105
|
-
this._indicatorView.setInteractiveAnimation(true);
|
106
|
-
nativeView.addView(this._indicatorView);
|
107
87
|
return nativeView;
|
108
88
|
}
|
109
89
|
initNativeView() {
|
110
90
|
super.initNativeView();
|
91
|
+
// Store disable animation value
|
111
92
|
this._oldDisableAnimation = this.disableAnimation;
|
93
|
+
// Disable animation to set currentItem w/o animation
|
112
94
|
this.disableAnimation = true;
|
113
95
|
initPagerChangeCallback();
|
114
96
|
this._pageListener = new PageChangeCallback(new WeakRef(this));
|
115
|
-
this.
|
116
|
-
|
97
|
+
const nativeView = this.nativeViewProtected;
|
98
|
+
nativeView.registerOnPageChangeCallback(this._pageListener);
|
99
|
+
nativeView.setAdapter(this._pagerAdapter);
|
117
100
|
if (this._androidViewId < 0) {
|
118
101
|
this._androidViewId = android.view.View.generateViewId();
|
119
102
|
}
|
120
103
|
if (this.pagesCount > 0) {
|
121
|
-
|
104
|
+
nativeView.setOffscreenPageLimit(this.pagesCount);
|
122
105
|
}
|
123
106
|
else {
|
124
|
-
|
107
|
+
nativeView.setOffscreenPageLimit(3);
|
125
108
|
}
|
126
|
-
this._setIndicator(this.indicator);
|
127
109
|
this._setPeaking(this.peaking);
|
128
110
|
this._setSpacing(this.spacing);
|
129
111
|
this._setTransformers(this.transformers ? this.transformers : '');
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
this.
|
112
|
+
}
|
113
|
+
setIndicator(indicator) {
|
114
|
+
super.setIndicator(indicator);
|
115
|
+
if (indicator) {
|
116
|
+
this.indicator.setCount(this.items ? this.items.length : 0);
|
117
|
+
this.indicator.setSelection(this.selectedIndex, false);
|
135
118
|
}
|
136
119
|
}
|
137
120
|
enumerateViewHolders(cb) {
|
@@ -167,6 +150,7 @@ export class Pager extends PagerBase {
|
|
167
150
|
this._setPeaking(args.object.peaking);
|
168
151
|
this._setTransformers(this.transformers ? this.transformers : '');
|
169
152
|
this._updateScrollPosition();
|
153
|
+
// Set disableAnimation to original value
|
170
154
|
this.disableAnimation = this._oldDisableAnimation;
|
171
155
|
}
|
172
156
|
_setSpacing(value) {
|
@@ -185,11 +169,12 @@ export class Pager extends PagerBase {
|
|
185
169
|
const size = this.convertToSize(value);
|
186
170
|
const newPeaking = size !== this._lastPeaking;
|
187
171
|
if (newPeaking) {
|
188
|
-
this.
|
172
|
+
const nativeView = this.nativeViewProtected;
|
173
|
+
nativeView.setClipToPadding(false);
|
189
174
|
const left = this.orientation === 'horizontal' ? size : 0;
|
190
175
|
const top = this.orientation === 'horizontal' ? 0 : size;
|
191
|
-
|
192
|
-
|
176
|
+
nativeView.setPadding(left, top, left, top);
|
177
|
+
nativeView.setClipChildren(false);
|
193
178
|
this._lastPeaking = size;
|
194
179
|
}
|
195
180
|
}
|
@@ -199,31 +184,6 @@ export class Pager extends PagerBase {
|
|
199
184
|
[peakingProperty.setNative](value) {
|
200
185
|
this._setPeaking(value);
|
201
186
|
}
|
202
|
-
[indicatorProperty.setNative](value) {
|
203
|
-
this._setIndicator(value);
|
204
|
-
}
|
205
|
-
_setIndicator(value) {
|
206
|
-
const AnimationType = com.rd.animation.type.AnimationType;
|
207
|
-
switch (value) {
|
208
|
-
case Indicator.None:
|
209
|
-
this.indicatorView.setAnimationType(AnimationType.NONE);
|
210
|
-
break;
|
211
|
-
case Indicator.Worm:
|
212
|
-
this.indicatorView.setAnimationType(AnimationType.WORM);
|
213
|
-
break;
|
214
|
-
case Indicator.Fill:
|
215
|
-
this.indicatorView.setAnimationType(AnimationType.FILL);
|
216
|
-
break;
|
217
|
-
case Indicator.Swap:
|
218
|
-
this.indicatorView.setAnimationType(AnimationType.SWAP);
|
219
|
-
break;
|
220
|
-
case Indicator.THIN_WORM:
|
221
|
-
this.indicatorView.setAnimationType(AnimationType.THIN_WORM);
|
222
|
-
break;
|
223
|
-
default:
|
224
|
-
break;
|
225
|
-
}
|
226
|
-
}
|
227
187
|
_setTransformers(transformers) {
|
228
188
|
if (!isString(transformers)) {
|
229
189
|
return;
|
@@ -246,12 +206,19 @@ export class Pager extends PagerBase {
|
|
246
206
|
this.compositeTransformer.removeTransformer(transformer);
|
247
207
|
});
|
248
208
|
}
|
249
|
-
this.
|
209
|
+
this.nativeViewProtected.setPageTransformer(this.compositeTransformer);
|
250
210
|
}
|
251
211
|
disposeViewHolderViews() {
|
252
212
|
this.enumerateViewHolders((v) => {
|
253
213
|
const view = v.view;
|
214
|
+
// if (view && view.isLoaded) {
|
215
|
+
// view.callUnloaded();
|
216
|
+
// }
|
254
217
|
this._removeViewCore(view);
|
218
|
+
// view._isAddedToNativeVisualTree = false;
|
219
|
+
// //@ts-ignore
|
220
|
+
// view.parent = null;
|
221
|
+
// view._tearDownUI();
|
255
222
|
});
|
256
223
|
this._viewHolders = new Set();
|
257
224
|
}
|
@@ -261,13 +228,10 @@ export class Pager extends PagerBase {
|
|
261
228
|
this.disposeViewHolderViews();
|
262
229
|
this._realizedTemplates.clear();
|
263
230
|
this._pageListener = null;
|
264
|
-
|
231
|
+
// setAdapter(null) will destroy views
|
232
|
+
this.nativeViewProtected.setAdapter(null);
|
265
233
|
this._pagerAdapter = null;
|
266
234
|
this._transformers = [];
|
267
|
-
if (this._observableArrayInstance) {
|
268
|
-
this._observableArrayInstance.off(ObservableArray.changeEvent, this._observableArrayHandler);
|
269
|
-
this._observableArrayInstance = null;
|
270
|
-
}
|
271
235
|
super.disposeNativeView();
|
272
236
|
}
|
273
237
|
get disableAnimation() {
|
@@ -282,55 +246,30 @@ export class Pager extends PagerBase {
|
|
282
246
|
get _childrenCount() {
|
283
247
|
return (this.items && this.items.length) || (this._childrenViews && this._childrenViews.length) || 0;
|
284
248
|
}
|
285
|
-
[indicatorColorProperty.setNative](value) {
|
286
|
-
if (this.indicatorView) {
|
287
|
-
const color = !value || value instanceof Color ? value : new Color(value);
|
288
|
-
this.indicatorView.setUnselectedColor(color ? color.android : null);
|
289
|
-
}
|
290
|
-
}
|
291
|
-
[indicatorSelectedColorProperty.setNative](value) {
|
292
|
-
if (this.indicatorView) {
|
293
|
-
const color = !value || value instanceof Color ? value : new Color(value);
|
294
|
-
this.indicatorView.setSelectedColor(color ? color.android : null);
|
295
|
-
}
|
296
|
-
}
|
297
249
|
[disableSwipeProperty.setNative](value) {
|
298
|
-
|
299
|
-
this.pager.setUserInputEnabled(!value);
|
300
|
-
}
|
250
|
+
this.nativeViewProtected.setUserInputEnabled(!value);
|
301
251
|
}
|
302
252
|
[itemsProperty.getDefault]() {
|
303
253
|
return null;
|
304
254
|
}
|
305
255
|
[itemsProperty.setNative](value) {
|
306
|
-
|
307
|
-
this.indicatorView.setCount(this._childrenCount);
|
308
|
-
}
|
309
|
-
if (this._observableArrayInstance) {
|
310
|
-
this._observableArrayInstance.off(ObservableArray.changeEvent, this._observableArrayHandler);
|
311
|
-
this._observableArrayInstance = null;
|
312
|
-
}
|
313
|
-
if (value) {
|
314
|
-
if (value instanceof ObservableArray) {
|
315
|
-
const adapter = this.pagerAdapter;
|
316
|
-
if (!adapter)
|
317
|
-
return;
|
318
|
-
selectedIndexProperty.coerce(this);
|
319
|
-
this._observableArrayInstance = value;
|
320
|
-
this._observableArrayInstance.on(ObservableArray.changeEvent, this._observableArrayHandler);
|
321
|
-
}
|
322
|
-
else {
|
323
|
-
this.refresh();
|
324
|
-
selectedIndexProperty.coerce(this);
|
325
|
-
}
|
326
|
-
}
|
256
|
+
this.setObservableArrayInstance(value);
|
327
257
|
}
|
328
258
|
_updateScrollPosition() {
|
329
259
|
const index = this.circularMode ? this.selectedIndex + 1 : this.selectedIndex;
|
330
|
-
|
331
|
-
|
332
|
-
this.
|
333
|
-
|
260
|
+
const nativeView = this.nativeViewProtected;
|
261
|
+
if (nativeView.getCurrentItem() !== index) {
|
262
|
+
const indicator = this.indicator;
|
263
|
+
const toDo = () => {
|
264
|
+
nativeView.setCurrentItem(index, false);
|
265
|
+
indicator.setSelection(this.selectedIndex, false);
|
266
|
+
};
|
267
|
+
if (indicator) {
|
268
|
+
indicator.withoutAnimation(toDo);
|
269
|
+
}
|
270
|
+
else {
|
271
|
+
toDo();
|
272
|
+
}
|
334
273
|
}
|
335
274
|
setTimeout(() => {
|
336
275
|
this._initAutoPlay(this.autoPlay);
|
@@ -339,14 +278,15 @@ export class Pager extends PagerBase {
|
|
339
278
|
initStaticPagerAdapter() {
|
340
279
|
if (!this.items && this._childrenCount > 0) {
|
341
280
|
initStaticPagerStateAdapter();
|
342
|
-
|
281
|
+
const nativeView = this.nativeViewProtected;
|
282
|
+
if (nativeView && !(this._pagerAdapter instanceof StaticPagerStateAdapter)) {
|
343
283
|
this._pagerAdapter = new StaticPagerStateAdapter(new WeakRef(this));
|
344
|
-
|
284
|
+
nativeView.setAdapter(this._pagerAdapter);
|
345
285
|
selectedIndexProperty.coerce(this);
|
346
286
|
setTimeout(() => {
|
347
|
-
|
348
|
-
if (this.
|
349
|
-
this.
|
287
|
+
nativeView.setCurrentItem(this.selectedIndex, false);
|
288
|
+
if (this.indicator) {
|
289
|
+
this.indicator.setSelection(this.selectedIndex);
|
350
290
|
}
|
351
291
|
}, 0);
|
352
292
|
}
|
@@ -357,41 +297,44 @@ export class Pager extends PagerBase {
|
|
357
297
|
this.initStaticPagerAdapter();
|
358
298
|
}
|
359
299
|
[selectedIndexProperty.setNative](value) {
|
360
|
-
|
300
|
+
const nativeView = this.nativeViewProtected;
|
301
|
+
if (this.isLoaded && nativeView) {
|
361
302
|
const index = this.circularMode ? value + 1 : value;
|
362
|
-
|
363
|
-
this.pager.setCurrentItem(index, !this.disableAnimation);
|
364
|
-
if (this.indicatorView) {
|
365
|
-
}
|
366
|
-
}
|
303
|
+
nativeView.setCurrentItem(index, !this.disableAnimation);
|
367
304
|
}
|
368
305
|
}
|
369
306
|
scrollToIndexAnimated(index, animate) {
|
370
|
-
|
371
|
-
|
307
|
+
const nativeView = this.nativeViewProtected;
|
308
|
+
if (nativeView) {
|
309
|
+
nativeView.setCurrentItem(index, animate);
|
372
310
|
if (!animate) {
|
311
|
+
// without animate we wont go through the delegate
|
373
312
|
selectedIndexProperty.nativeValueChange(this, index);
|
374
313
|
}
|
375
314
|
}
|
376
315
|
}
|
377
316
|
_onItemsChanged(oldValue, newValue) { }
|
378
317
|
refresh() {
|
379
|
-
|
380
|
-
|
381
|
-
|
318
|
+
const nativeView = this.nativeViewProtected;
|
319
|
+
if (nativeView && this._pagerAdapter) {
|
320
|
+
nativeView.requestLayout();
|
321
|
+
nativeView.getAdapter().notifyDataSetChanged();
|
382
322
|
}
|
383
323
|
}
|
384
324
|
updatePagesCount(value) {
|
385
|
-
|
325
|
+
const nativeView = this.nativeViewProtected;
|
326
|
+
if (nativeView) {
|
386
327
|
this._pagerAdapter.notifyDataSetChanged();
|
387
|
-
|
328
|
+
nativeView.setOffscreenPageLimit(value);
|
388
329
|
}
|
389
330
|
}
|
390
331
|
onUnloaded() {
|
332
|
+
// this._android.setAdapter(null);
|
391
333
|
super.onUnloaded();
|
392
334
|
}
|
393
335
|
eachChild(callback) {
|
394
336
|
super.eachChild(callback);
|
337
|
+
// used for css updates (like theme change)
|
395
338
|
this.enumerateViewHolders((v) => {
|
396
339
|
const view = v.view;
|
397
340
|
if (view) {
|
@@ -399,6 +342,7 @@ export class Pager extends PagerBase {
|
|
399
342
|
callback(view);
|
400
343
|
}
|
401
344
|
else {
|
345
|
+
// in some cases (like item is unloaded from another place (like angular) view.parent becomes undefined)
|
402
346
|
if (view.parent) {
|
403
347
|
callback(view.parent);
|
404
348
|
}
|
@@ -419,77 +363,22 @@ export class Pager extends PagerBase {
|
|
419
363
|
this._itemTemplatesInternal = this._itemTemplatesInternal.concat(value);
|
420
364
|
}
|
421
365
|
this._pagerAdapter = new PagerRecyclerAdapter(new WeakRef(this));
|
422
|
-
this.
|
366
|
+
this.nativeViewProtected.setAdapter(this._pagerAdapter);
|
423
367
|
this.refresh();
|
424
368
|
}
|
425
|
-
[showIndicatorProperty.setNative](value) {
|
426
|
-
if (!this.indicatorView) {
|
427
|
-
return;
|
428
|
-
}
|
429
|
-
if (value) {
|
430
|
-
this.indicatorView.setCount(this.items ? this.items.length : 0);
|
431
|
-
this.indicatorView.setSelected(this.selectedIndex);
|
432
|
-
}
|
433
|
-
else {
|
434
|
-
this.indicatorView.setCount(0);
|
435
|
-
}
|
436
|
-
}
|
437
369
|
[orientationProperty.setNative](value) {
|
438
370
|
if (value === 'vertical') {
|
439
|
-
this.
|
371
|
+
this.nativeViewProtected.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_VERTICAL);
|
440
372
|
}
|
441
373
|
else {
|
442
|
-
this.
|
374
|
+
this.nativeViewProtected.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL);
|
443
375
|
}
|
444
376
|
}
|
445
377
|
get horizontalOffset() {
|
446
|
-
return this._horizontalOffset / layout.getDisplayDensity();
|
378
|
+
return this._horizontalOffset / Utils.layout.getDisplayDensity();
|
447
379
|
}
|
448
380
|
get verticalOffset() {
|
449
|
-
return this._verticalOffset / layout.getDisplayDensity();
|
450
|
-
}
|
451
|
-
static getProgress(indicator, position, positionOffset, isRtl) {
|
452
|
-
const count = indicator.getCount();
|
453
|
-
let selectedPosition = indicator.getSelection();
|
454
|
-
if (isRtl) {
|
455
|
-
position = count - 1 - position;
|
456
|
-
}
|
457
|
-
if (position < 0) {
|
458
|
-
position = 0;
|
459
|
-
}
|
460
|
-
else if (position > count - 1) {
|
461
|
-
position = count - 1;
|
462
|
-
}
|
463
|
-
const isRightOverScrolled = position > selectedPosition;
|
464
|
-
let isLeftOverScrolled;
|
465
|
-
if (isRtl) {
|
466
|
-
isLeftOverScrolled = position - 1 < selectedPosition;
|
467
|
-
}
|
468
|
-
else {
|
469
|
-
isLeftOverScrolled = position + 1 < selectedPosition;
|
470
|
-
}
|
471
|
-
if (isRightOverScrolled || isLeftOverScrolled) {
|
472
|
-
selectedPosition = position;
|
473
|
-
indicator.setSelection(selectedPosition);
|
474
|
-
}
|
475
|
-
const slideToRightSide = selectedPosition === position && positionOffset !== 0;
|
476
|
-
let selectingPosition;
|
477
|
-
let selectingProgress;
|
478
|
-
if (slideToRightSide) {
|
479
|
-
selectingPosition = isRtl ? position - 1 : position + 1;
|
480
|
-
selectingProgress = positionOffset;
|
481
|
-
}
|
482
|
-
else {
|
483
|
-
selectingPosition = position;
|
484
|
-
selectingProgress = 1 - positionOffset;
|
485
|
-
}
|
486
|
-
if (selectingProgress > 1) {
|
487
|
-
selectingProgress = 1;
|
488
|
-
}
|
489
|
-
else if (selectingProgress < 0) {
|
490
|
-
selectingProgress = 0;
|
491
|
-
}
|
492
|
-
return [selectingPosition, selectingProgress];
|
381
|
+
return this._verticalOffset / Utils.layout.getDisplayDensity();
|
493
382
|
}
|
494
383
|
[autoPlayProperty.setNative](value) {
|
495
384
|
this._initAutoPlay(value);
|
@@ -535,6 +424,49 @@ export class Pager extends PagerBase {
|
|
535
424
|
}
|
536
425
|
return this.circularMode ? this.itemCount - 3 : this.itemCount - 1;
|
537
426
|
}
|
427
|
+
static getProgress(indicator, position, positionOffset, isRtl) {
|
428
|
+
const count = indicator.getCount();
|
429
|
+
let selectedPosition = indicator.getSelection();
|
430
|
+
if (isRtl) {
|
431
|
+
position = count - 1 - position;
|
432
|
+
}
|
433
|
+
if (position < 0) {
|
434
|
+
position = 0;
|
435
|
+
}
|
436
|
+
else if (position > count - 1) {
|
437
|
+
position = count - 1;
|
438
|
+
}
|
439
|
+
const isRightOverScrolled = position > selectedPosition;
|
440
|
+
let isLeftOverScrolled;
|
441
|
+
if (isRtl) {
|
442
|
+
isLeftOverScrolled = position - 1 < selectedPosition;
|
443
|
+
}
|
444
|
+
else {
|
445
|
+
isLeftOverScrolled = position + 1 < selectedPosition;
|
446
|
+
}
|
447
|
+
if (isRightOverScrolled || isLeftOverScrolled) {
|
448
|
+
selectedPosition = position;
|
449
|
+
indicator.setSelection(selectedPosition);
|
450
|
+
}
|
451
|
+
const slideToRightSide = selectedPosition === position && positionOffset !== 0;
|
452
|
+
let selectingPosition;
|
453
|
+
let selectingProgress;
|
454
|
+
if (slideToRightSide) {
|
455
|
+
selectingPosition = isRtl ? position - 1 : position + 1;
|
456
|
+
selectingProgress = positionOffset;
|
457
|
+
}
|
458
|
+
else {
|
459
|
+
selectingPosition = position;
|
460
|
+
selectingProgress = 1 - positionOffset;
|
461
|
+
}
|
462
|
+
if (selectingProgress > 1) {
|
463
|
+
selectingProgress = 1;
|
464
|
+
}
|
465
|
+
else if (selectingProgress < 0) {
|
466
|
+
selectingProgress = 0;
|
467
|
+
}
|
468
|
+
return [selectingPosition, selectingProgress];
|
469
|
+
}
|
538
470
|
}
|
539
471
|
__decorate([
|
540
472
|
profile()
|
@@ -595,12 +527,13 @@ function initPagerChangeCallback() {
|
|
595
527
|
if (owner.items && position === owner.pagerAdapter.lastIndex() - owner.loadMoreCount) {
|
596
528
|
owner.notify({ eventName: Pager.loadMoreItemsEvent, object: owner });
|
597
529
|
}
|
598
|
-
|
599
|
-
|
530
|
+
var indicator = owner.indicator;
|
531
|
+
if (indicator) {
|
532
|
+
var progress = Pager.getProgress(indicator, position, positionOffset, false);
|
600
533
|
var selectingPosition = progress[0];
|
601
534
|
var selectingProgress = progress[1];
|
602
|
-
|
603
|
-
|
535
|
+
indicator.setInteractiveAnimation(true);
|
536
|
+
indicator.setProgress(selectingPosition, selectingProgress);
|
604
537
|
}
|
605
538
|
}
|
606
539
|
};
|
@@ -633,24 +566,40 @@ function initPagerChangeCallback() {
|
|
633
566
|
}
|
634
567
|
if (owner.isLayoutValid && state === androidx.viewpager2.widget.ViewPager2.SCROLL_STATE_IDLE) {
|
635
568
|
// ts-ignore
|
636
|
-
var
|
637
|
-
var index = owner.
|
569
|
+
var count_1 = owner.pagerAdapter.getItemCount();
|
570
|
+
var index = owner.nativeViewProtected.getCurrentItem();
|
571
|
+
var indicator_1 = owner.indicator;
|
638
572
|
if (owner.circularMode) {
|
639
573
|
if (index === 0) {
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
574
|
+
var toDo = function () {
|
575
|
+
owner.nativeViewProtected.setCurrentItem(count_1 - 2, false);
|
576
|
+
selectedIndexProperty.nativeValueChange(owner, count_1 - 3);
|
577
|
+
if (indicator_1) {
|
578
|
+
indicator_1.setSelection(count_1 - 3, false);
|
579
|
+
}
|
580
|
+
};
|
581
|
+
if (indicator_1) {
|
582
|
+
indicator_1.withoutAnimation(toDo);
|
583
|
+
}
|
584
|
+
else {
|
585
|
+
toDo();
|
586
|
+
}
|
646
587
|
}
|
647
|
-
else if (index ===
|
588
|
+
else if (index === count_1 - 1) {
|
648
589
|
// first item
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
590
|
+
var toDo = function () {
|
591
|
+
owner.nativeViewProtected.setCurrentItem(1, false);
|
592
|
+
selectedIndexProperty.nativeValueChange(owner, 0);
|
593
|
+
if (indicator_1) {
|
594
|
+
indicator_1.setSelection(0, false);
|
595
|
+
}
|
596
|
+
};
|
597
|
+
if (indicator_1) {
|
598
|
+
indicator_1.withoutAnimation(toDo);
|
599
|
+
}
|
600
|
+
else {
|
601
|
+
toDo();
|
602
|
+
}
|
654
603
|
}
|
655
604
|
else {
|
656
605
|
selectedIndexProperty.nativeValueChange(owner, index - 1);
|
@@ -658,7 +607,9 @@ function initPagerChangeCallback() {
|
|
658
607
|
}
|
659
608
|
else {
|
660
609
|
selectedIndexProperty.nativeValueChange(owner, index);
|
661
|
-
|
610
|
+
if (indicator_1) {
|
611
|
+
indicator_1.setSelection(index, false);
|
612
|
+
}
|
662
613
|
}
|
663
614
|
}
|
664
615
|
}
|
@@ -667,6 +618,7 @@ function initPagerChangeCallback() {
|
|
667
618
|
}(androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback));
|
668
619
|
PageChangeCallback = PageChangeCallbackImpl;
|
669
620
|
}
|
621
|
+
// eslint-disable-next-line no-redeclare
|
670
622
|
let PagerRecyclerAdapter;
|
671
623
|
function initPagerRecyclerAdapter() {
|
672
624
|
if (PagerRecyclerAdapter) {
|
@@ -908,6 +860,7 @@ function initStaticPagerStateAdapter() {
|
|
908
860
|
}(androidx.recyclerview.widget.RecyclerView.Adapter));
|
909
861
|
StaticPagerStateAdapter = StaticPagerStateAdapterImpl;
|
910
862
|
}
|
863
|
+
// eslint-disable-next-line no-redeclare
|
911
864
|
let PagerViewHolder;
|
912
865
|
function initPagerViewHolder() {
|
913
866
|
if (PagerViewHolder) {
|