@nativescript-community/ui-pager 13.0.43 → 14.0.0
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/angular/package.json +2 -2
- package/index.android.d.ts +4 -9
- package/index.android.js +165 -213
- 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 +109 -177
- 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 +47 -40
- package/react/index.js +33 -6
- 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 -350
- package/angular/nativescript-community-ui-pager-angular.d.ts +0 -2
- 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() {
|
@@ -280,58 +244,32 @@ export class Pager extends PagerBase {
|
|
280
244
|
return this._pagerAdapter;
|
281
245
|
}
|
282
246
|
get _childrenCount() {
|
283
|
-
|
284
|
-
return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = this._childrenViews) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
285
|
-
}
|
286
|
-
[indicatorColorProperty.setNative](value) {
|
287
|
-
if (this.indicatorView) {
|
288
|
-
const color = !value || value instanceof Color ? value : new Color(value);
|
289
|
-
this.indicatorView.setUnselectedColor(color ? color.android : null);
|
290
|
-
}
|
291
|
-
}
|
292
|
-
[indicatorSelectedColorProperty.setNative](value) {
|
293
|
-
if (this.indicatorView) {
|
294
|
-
const color = !value || value instanceof Color ? value : new Color(value);
|
295
|
-
this.indicatorView.setSelectedColor(color ? color.android : null);
|
296
|
-
}
|
247
|
+
return (this.items && this.items.length) || (this._childrenViews && this._childrenViews.length) || 0;
|
297
248
|
}
|
298
249
|
[disableSwipeProperty.setNative](value) {
|
299
|
-
|
300
|
-
this.pager.setUserInputEnabled(!value);
|
301
|
-
}
|
250
|
+
this.nativeViewProtected.setUserInputEnabled(!value);
|
302
251
|
}
|
303
252
|
[itemsProperty.getDefault]() {
|
304
253
|
return null;
|
305
254
|
}
|
306
255
|
[itemsProperty.setNative](value) {
|
307
|
-
|
308
|
-
this.indicatorView.setCount(this._childrenCount);
|
309
|
-
}
|
310
|
-
if (this._observableArrayInstance) {
|
311
|
-
this._observableArrayInstance.off(ObservableArray.changeEvent, this._observableArrayHandler);
|
312
|
-
this._observableArrayInstance = null;
|
313
|
-
}
|
314
|
-
if (value) {
|
315
|
-
if (value instanceof ObservableArray) {
|
316
|
-
const adapter = this.pagerAdapter;
|
317
|
-
if (!adapter)
|
318
|
-
return;
|
319
|
-
selectedIndexProperty.coerce(this);
|
320
|
-
this._observableArrayInstance = value;
|
321
|
-
this._observableArrayInstance.on(ObservableArray.changeEvent, this._observableArrayHandler);
|
322
|
-
}
|
323
|
-
else {
|
324
|
-
this.refresh();
|
325
|
-
selectedIndexProperty.coerce(this);
|
326
|
-
}
|
327
|
-
}
|
256
|
+
this.setObservableArrayInstance(value);
|
328
257
|
}
|
329
258
|
_updateScrollPosition() {
|
330
259
|
const index = this.circularMode ? this.selectedIndex + 1 : this.selectedIndex;
|
331
|
-
|
332
|
-
|
333
|
-
this.
|
334
|
-
|
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
|
+
}
|
335
273
|
}
|
336
274
|
setTimeout(() => {
|
337
275
|
this._initAutoPlay(this.autoPlay);
|
@@ -340,14 +278,15 @@ export class Pager extends PagerBase {
|
|
340
278
|
initStaticPagerAdapter() {
|
341
279
|
if (!this.items && this._childrenCount > 0) {
|
342
280
|
initStaticPagerStateAdapter();
|
343
|
-
|
281
|
+
const nativeView = this.nativeViewProtected;
|
282
|
+
if (nativeView && !(this._pagerAdapter instanceof StaticPagerStateAdapter)) {
|
344
283
|
this._pagerAdapter = new StaticPagerStateAdapter(new WeakRef(this));
|
345
|
-
|
284
|
+
nativeView.setAdapter(this._pagerAdapter);
|
346
285
|
selectedIndexProperty.coerce(this);
|
347
286
|
setTimeout(() => {
|
348
|
-
|
349
|
-
if (this.
|
350
|
-
this.
|
287
|
+
nativeView.setCurrentItem(this.selectedIndex, false);
|
288
|
+
if (this.indicator) {
|
289
|
+
this.indicator.setSelection(this.selectedIndex);
|
351
290
|
}
|
352
291
|
}, 0);
|
353
292
|
}
|
@@ -358,41 +297,44 @@ export class Pager extends PagerBase {
|
|
358
297
|
this.initStaticPagerAdapter();
|
359
298
|
}
|
360
299
|
[selectedIndexProperty.setNative](value) {
|
361
|
-
|
300
|
+
const nativeView = this.nativeViewProtected;
|
301
|
+
if (this.isLoaded && nativeView) {
|
362
302
|
const index = this.circularMode ? value + 1 : value;
|
363
|
-
|
364
|
-
this.pager.setCurrentItem(index, !this.disableAnimation);
|
365
|
-
if (this.indicatorView) {
|
366
|
-
}
|
367
|
-
}
|
303
|
+
nativeView.setCurrentItem(index, !this.disableAnimation);
|
368
304
|
}
|
369
305
|
}
|
370
306
|
scrollToIndexAnimated(index, animate) {
|
371
|
-
|
372
|
-
|
307
|
+
const nativeView = this.nativeViewProtected;
|
308
|
+
if (nativeView) {
|
309
|
+
nativeView.setCurrentItem(index, animate);
|
373
310
|
if (!animate) {
|
311
|
+
// without animate we wont go through the delegate
|
374
312
|
selectedIndexProperty.nativeValueChange(this, index);
|
375
313
|
}
|
376
314
|
}
|
377
315
|
}
|
378
316
|
_onItemsChanged(oldValue, newValue) { }
|
379
317
|
refresh() {
|
380
|
-
|
381
|
-
|
382
|
-
|
318
|
+
const nativeView = this.nativeViewProtected;
|
319
|
+
if (nativeView && this._pagerAdapter) {
|
320
|
+
nativeView.requestLayout();
|
321
|
+
nativeView.getAdapter().notifyDataSetChanged();
|
383
322
|
}
|
384
323
|
}
|
385
324
|
updatePagesCount(value) {
|
386
|
-
|
325
|
+
const nativeView = this.nativeViewProtected;
|
326
|
+
if (nativeView) {
|
387
327
|
this._pagerAdapter.notifyDataSetChanged();
|
388
|
-
|
328
|
+
nativeView.setOffscreenPageLimit(value);
|
389
329
|
}
|
390
330
|
}
|
391
331
|
onUnloaded() {
|
332
|
+
// this._android.setAdapter(null);
|
392
333
|
super.onUnloaded();
|
393
334
|
}
|
394
335
|
eachChild(callback) {
|
395
336
|
super.eachChild(callback);
|
337
|
+
// used for css updates (like theme change)
|
396
338
|
this.enumerateViewHolders((v) => {
|
397
339
|
const view = v.view;
|
398
340
|
if (view) {
|
@@ -400,6 +342,7 @@ export class Pager extends PagerBase {
|
|
400
342
|
callback(view);
|
401
343
|
}
|
402
344
|
else {
|
345
|
+
// in some cases (like item is unloaded from another place (like angular) view.parent becomes undefined)
|
403
346
|
if (view.parent) {
|
404
347
|
callback(view.parent);
|
405
348
|
}
|
@@ -420,77 +363,22 @@ export class Pager extends PagerBase {
|
|
420
363
|
this._itemTemplatesInternal = this._itemTemplatesInternal.concat(value);
|
421
364
|
}
|
422
365
|
this._pagerAdapter = new PagerRecyclerAdapter(new WeakRef(this));
|
423
|
-
this.
|
366
|
+
this.nativeViewProtected.setAdapter(this._pagerAdapter);
|
424
367
|
this.refresh();
|
425
368
|
}
|
426
|
-
[showIndicatorProperty.setNative](value) {
|
427
|
-
if (!this.indicatorView) {
|
428
|
-
return;
|
429
|
-
}
|
430
|
-
if (value) {
|
431
|
-
this.indicatorView.setCount(this.items ? this.items.length : 0);
|
432
|
-
this.indicatorView.setSelected(this.selectedIndex);
|
433
|
-
}
|
434
|
-
else {
|
435
|
-
this.indicatorView.setCount(0);
|
436
|
-
}
|
437
|
-
}
|
438
369
|
[orientationProperty.setNative](value) {
|
439
370
|
if (value === 'vertical') {
|
440
|
-
this.
|
371
|
+
this.nativeViewProtected.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_VERTICAL);
|
441
372
|
}
|
442
373
|
else {
|
443
|
-
this.
|
374
|
+
this.nativeViewProtected.setOrientation(androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL);
|
444
375
|
}
|
445
376
|
}
|
446
377
|
get horizontalOffset() {
|
447
|
-
return this._horizontalOffset / layout.getDisplayDensity();
|
378
|
+
return this._horizontalOffset / Utils.layout.getDisplayDensity();
|
448
379
|
}
|
449
380
|
get verticalOffset() {
|
450
|
-
return this._verticalOffset / layout.getDisplayDensity();
|
451
|
-
}
|
452
|
-
static getProgress(indicator, position, positionOffset, isRtl) {
|
453
|
-
const count = indicator.getCount();
|
454
|
-
let selectedPosition = indicator.getSelection();
|
455
|
-
if (isRtl) {
|
456
|
-
position = count - 1 - position;
|
457
|
-
}
|
458
|
-
if (position < 0) {
|
459
|
-
position = 0;
|
460
|
-
}
|
461
|
-
else if (position > count - 1) {
|
462
|
-
position = count - 1;
|
463
|
-
}
|
464
|
-
const isRightOverScrolled = position > selectedPosition;
|
465
|
-
let isLeftOverScrolled;
|
466
|
-
if (isRtl) {
|
467
|
-
isLeftOverScrolled = position - 1 < selectedPosition;
|
468
|
-
}
|
469
|
-
else {
|
470
|
-
isLeftOverScrolled = position + 1 < selectedPosition;
|
471
|
-
}
|
472
|
-
if (isRightOverScrolled || isLeftOverScrolled) {
|
473
|
-
selectedPosition = position;
|
474
|
-
indicator.setSelection(selectedPosition);
|
475
|
-
}
|
476
|
-
const slideToRightSide = selectedPosition === position && positionOffset !== 0;
|
477
|
-
let selectingPosition;
|
478
|
-
let selectingProgress;
|
479
|
-
if (slideToRightSide) {
|
480
|
-
selectingPosition = isRtl ? position - 1 : position + 1;
|
481
|
-
selectingProgress = positionOffset;
|
482
|
-
}
|
483
|
-
else {
|
484
|
-
selectingPosition = position;
|
485
|
-
selectingProgress = 1 - positionOffset;
|
486
|
-
}
|
487
|
-
if (selectingProgress > 1) {
|
488
|
-
selectingProgress = 1;
|
489
|
-
}
|
490
|
-
else if (selectingProgress < 0) {
|
491
|
-
selectingProgress = 0;
|
492
|
-
}
|
493
|
-
return [selectingPosition, selectingProgress];
|
381
|
+
return this._verticalOffset / Utils.layout.getDisplayDensity();
|
494
382
|
}
|
495
383
|
[autoPlayProperty.setNative](value) {
|
496
384
|
this._initAutoPlay(value);
|
@@ -536,6 +424,49 @@ export class Pager extends PagerBase {
|
|
536
424
|
}
|
537
425
|
return this.circularMode ? this.itemCount - 3 : this.itemCount - 1;
|
538
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
|
+
}
|
539
470
|
}
|
540
471
|
__decorate([
|
541
472
|
profile()
|
@@ -596,12 +527,13 @@ function initPagerChangeCallback() {
|
|
596
527
|
if (owner.items && position === owner.pagerAdapter.lastIndex() - owner.loadMoreCount) {
|
597
528
|
owner.notify({ eventName: Pager.loadMoreItemsEvent, object: owner });
|
598
529
|
}
|
599
|
-
|
600
|
-
|
530
|
+
var indicator = owner.indicator;
|
531
|
+
if (indicator) {
|
532
|
+
var progress = Pager.getProgress(indicator, position, positionOffset, false);
|
601
533
|
var selectingPosition = progress[0];
|
602
534
|
var selectingProgress = progress[1];
|
603
|
-
|
604
|
-
|
535
|
+
indicator.setInteractiveAnimation(true);
|
536
|
+
indicator.setProgress(selectingPosition, selectingProgress);
|
605
537
|
}
|
606
538
|
}
|
607
539
|
};
|
@@ -634,24 +566,40 @@ function initPagerChangeCallback() {
|
|
634
566
|
}
|
635
567
|
if (owner.isLayoutValid && state === androidx.viewpager2.widget.ViewPager2.SCROLL_STATE_IDLE) {
|
636
568
|
// ts-ignore
|
637
|
-
var
|
638
|
-
var index = owner.
|
569
|
+
var count_1 = owner.pagerAdapter.getItemCount();
|
570
|
+
var index = owner.nativeViewProtected.getCurrentItem();
|
571
|
+
var indicator_1 = owner.indicator;
|
639
572
|
if (owner.circularMode) {
|
640
573
|
if (index === 0) {
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
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
|
+
}
|
647
587
|
}
|
648
|
-
else if (index ===
|
588
|
+
else if (index === count_1 - 1) {
|
649
589
|
// first item
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
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
|
+
}
|
655
603
|
}
|
656
604
|
else {
|
657
605
|
selectedIndexProperty.nativeValueChange(owner, index - 1);
|
@@ -659,7 +607,9 @@ function initPagerChangeCallback() {
|
|
659
607
|
}
|
660
608
|
else {
|
661
609
|
selectedIndexProperty.nativeValueChange(owner, index);
|
662
|
-
|
610
|
+
if (indicator_1) {
|
611
|
+
indicator_1.setSelection(index, false);
|
612
|
+
}
|
663
613
|
}
|
664
614
|
}
|
665
615
|
}
|
@@ -668,6 +618,7 @@ function initPagerChangeCallback() {
|
|
668
618
|
}(androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback));
|
669
619
|
PageChangeCallback = PageChangeCallbackImpl;
|
670
620
|
}
|
621
|
+
// eslint-disable-next-line no-redeclare
|
671
622
|
let PagerRecyclerAdapter;
|
672
623
|
function initPagerRecyclerAdapter() {
|
673
624
|
if (PagerRecyclerAdapter) {
|
@@ -909,6 +860,7 @@ function initStaticPagerStateAdapter() {
|
|
909
860
|
}(androidx.recyclerview.widget.RecyclerView.Adapter));
|
910
861
|
StaticPagerStateAdapter = StaticPagerStateAdapterImpl;
|
911
862
|
}
|
863
|
+
// eslint-disable-next-line no-redeclare
|
912
864
|
let PagerViewHolder;
|
913
865
|
function initPagerViewHolder() {
|
914
866
|
if (PagerViewHolder) {
|