Skip to content

Commit b7a7c29

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # yarn.lock
2 parents 68f4255 + b6a1d77 commit b7a7c29

File tree

9 files changed

+41
-16
lines changed

9 files changed

+41
-16
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [14.1.2](https://github.com/nativescript-community/ui-pager/compare/v14.1.1...v14.1.2) (2023-03-21)
7+
8+
9+
### Bug Fixes
10+
11+
* **ios:** potential crash while disposing ([cde7a15](https://github.com/nativescript-community/ui-pager/commit/cde7a15e31546a94768efe4790fce4ebef3c065b))
12+
13+
14+
15+
16+
617
## [14.1.1](https://github.com/nativescript-community/ui-pager/compare/v14.1.0...v14.1.1) (2023-01-28)
718

819
**Note:** Version bump only for package ui-pager

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "14.1.1",
2+
"version": "14.1.2",
33
"packages": [
44
"packages/*"
55
],

packages/ui-pager-indicator/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [14.1.2](https://github.com/nativescript-community/ui-pager/compare/v14.1.1...v14.1.2) (2023-03-21)
7+
8+
**Note:** Version bump only for package @nativescript-community/ui-pager-indicator
9+
10+
11+
12+
13+
614
## [14.1.1](https://github.com/nativescript-community/ui-pager/compare/v14.1.0...v14.1.1) (2023-01-28)
715

816
**Note:** Version bump only for package @nativescript-community/ui-pager-indicator

packages/ui-pager-indicator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript-community/ui-pager-indicator",
3-
"version": "14.1.1",
3+
"version": "14.1.2",
44
"description": "A NativeScript Indicator for Pager / Carousel /CollectionView",
55
"main": "index",
66
"typings": "index.d.ts",

packages/ui-pager/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [14.1.2](https://github.com/nativescript-community/ui-pager/compare/v14.1.1...v14.1.2) (2023-03-21)
7+
8+
**Note:** Version bump only for package @nativescript-community/ui-pager
9+
10+
11+
12+
13+
614
## [14.1.1](https://github.com/nativescript-community/ui-pager/compare/v14.1.0...v14.1.1) (2023-01-28)
715

816
**Note:** Version bump only for package @nativescript-community/ui-pager

packages/ui-pager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript-community/ui-pager",
3-
"version": "14.1.1",
3+
"version": "14.1.2",
44
"description": "A NativeScript Pager / Carousel component that allows the user to swipe left and right through pages of data. ",
55
"main": "index",
66
"typings": "index.d.ts",

src/ui-pager/index.android.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { ChangeType, Color, Device, ObservableArray, Property, Screen, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
1+
import { ChangeType, Device, Property, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
22
import { KeyedTemplate } from '@nativescript/core/ui/core/view';
33
import { isString } from '@nativescript/core/utils/types';
44
import {
55
ItemEventData,
66
Orientation,
77
PagerBase,
8-
Transformer,
98
autoPlayProperty,
109
autoplayDelayProperty,
1110
disableSwipeProperty,

src/ui-pager/index.common.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ import {
33
Builder,
44
CSSType,
55
CoercibleProperty,
6-
Color,
76
ContainerView,
87
CoreTypes,
98
GridLayout,
109
ItemsSource,
1110
KeyedTemplate,
1211
Label,
13-
Length,
1412
Observable,
1513
ObservableArray,
16-
PercentLength,
1714
Property,
1815
Template,
1916
Trace,
@@ -163,7 +160,7 @@ export abstract class PagerBase extends ContainerView implements AddChildFromBui
163160
const index = this._childrenViews.findIndex((s) => s.view === view);
164161
if (index !== -1) {
165162
// this._removeChildView(index);
166-
if (this.isLoaded) {
163+
if (this.isLoaded && this._isAddedToNativeVisualTree) {
167164
this.refresh();
168165
}
169166
}
@@ -302,7 +299,7 @@ export abstract class PagerBase extends ContainerView implements AddChildFromBui
302299
super.onLayout(left, top, right, bottom);
303300
this._effectiveItemWidth = this.getMeasuredWidth() - this.effectivePaddingLeft - this.effectivePaddingRight;
304301
this._effectiveItemHeight = this.getMeasuredHeight() - this.effectivePaddingTop - this.effectivePaddingBottom;
305-
if (global.isIOS && this.iosOverflowSafeAreaEnabled) {
302+
if (__IOS__ && this.iosOverflowSafeAreaEnabled) {
306303
const safeArea = this.getSafeAreaInsets();
307304
this._effectiveItemHeight += safeArea.top + safeArea.bottom;
308305
}
@@ -311,9 +308,9 @@ export abstract class PagerBase extends ContainerView implements AddChildFromBui
311308
public convertToSize(length): number {
312309
let size = 0;
313310
if (this.orientation === 'horizontal') {
314-
size = global.isIOS ? Utils.layout.getMeasureSpecSize((this as any)._currentWidthMeasureSpec) : this.getMeasuredWidth();
311+
size = __IOS__ ? Utils.layout.getMeasureSpecSize((this as any)._currentWidthMeasureSpec) : this.getMeasuredWidth();
315312
} else {
316-
size = global.isIOS ? Utils.layout.getMeasureSpecSize((this as any)._currentHeightMeasureSpec) : this.getMeasuredHeight();
313+
size = __IOS__ ? Utils.layout.getMeasureSpecSize((this as any)._currentHeightMeasureSpec) : this.getMeasuredHeight();
317314
}
318315

319316
let converted = 0;
@@ -378,7 +375,7 @@ circularModeProperty.register(PagerBase);
378375
export const selectedIndexProperty = new CoercibleProperty<PagerBase, number>({
379376
name: 'selectedIndex',
380377
defaultValue: -1,
381-
// affectsLayout: global.isIOS,
378+
// affectsLayout: __IOS__,
382379
coerceValue: (target, value) => {
383380
const items = target._childrenCount;
384381
if (items) {

src/ui-pager/index.ios.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeType, Color, EventData, KeyedTemplate, Observable, ObservableArray, Property, ProxyViewContainer, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
1+
import { ChangeType, EventData, KeyedTemplate, Observable, Property, ProxyViewContainer, StackLayout, Utils, View, ViewBase, profile } from '@nativescript/core';
22
import {
33
ItemEventData,
44
Orientation,
@@ -9,8 +9,7 @@ import {
99
itemTemplatesProperty,
1010
itemsProperty,
1111
orientationProperty,
12-
selectedIndexProperty,
13-
showIndicatorProperty
12+
selectedIndexProperty
1413
} from './index.common';
1514

1615
export * from './index.common';
@@ -381,6 +380,9 @@ export class Pager extends PagerBase {
381380
}
382381
// dispatch_async(main_queue, () => {
383382
if (this.mDataSource.collectionViewNumberOfItemsInSection(this.nativeViewProtected, 0) > maxMinIndex) {
383+
// when we have custom layouts (they don't occupy 100% of the parent) and we use custom transformers we need to call setContentOffsetAnimated to take size into account.
384+
// Reference: https://stackoverflow.com/a/53798708/6015400
385+
this.nativeViewProtected.setContentOffsetAnimated(CGPointMake(1, 0), !!animate);
384386
this.nativeViewProtected.scrollToItemAtIndexPathAtScrollPositionAnimated(
385387
NSIndexPath.indexPathForItemInSection(maxMinIndex, 0),
386388
this.orientation === 'vertical' ? UICollectionViewScrollPosition.CenteredVertically : UICollectionViewScrollPosition.CenteredHorizontally,

0 commit comments

Comments
 (0)