Skip to content

Commit

Permalink
Allow toggling of page navigation #50
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Mar 14, 2018
1 parent a53722a commit b0a2101
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ _Angular v4+_
## Config

```xml
<Pager disableSwipe="true" selectedIndex="5">
<Pager disableSwipe="true" disableAnimation="true" selectedIndex="5">
```

| IOS | Android |
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-pager",
"version": "7.1.3",
"version": "7.2.0",
"description": "A Carousel/Pager plugin for NativeScript",
"main": "pager",
"typings": "index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion src/pager.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ declare namespace com.eftimoff {
export class Pager extends PagerBase {
_androidViewId: number;
disableSwipe: boolean;
private _disableAnimation: boolean;
public pagesCount: number;
public itemTemplateUpdated(oldData: any, newData: any): void {}
private _android: android.support.v4.view.ViewPager;
Expand Down Expand Up @@ -118,6 +119,13 @@ export class Pager extends PagerBase {
this.nativeView.setId(this._androidViewId);
}

get disableAnimation(): boolean {
return this._disableAnimation;
}
set disableAnimation(value: boolean) {
this._disableAnimation = value;
}

get pagerAdapter() {
return this._pagerAdapter;
}
Expand All @@ -139,7 +147,7 @@ export class Pager extends PagerBase {

[selectedIndexProperty.setNative](value: number) {
if (this._android) {
this._android.setCurrentItem(value, true);
this._android.setCurrentItem(value, this.disableAnimation);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/pager.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export abstract class PagerBase extends View {

abstract get disableSwipe(): boolean;
abstract set disableSwipe(value: boolean);

abstract get disableAnimation(): boolean;
abstract set disableAnimation(value: boolean);
get pageSpacing() {
return this._pageSpacing;
}
Expand Down
17 changes: 12 additions & 5 deletions src/pager.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ declare const ADTransitioningDelegate,
ADTransitioningViewController;

export class Pager extends PagerBase {
private _disableSwipe: any;
private _disableSwipe: boolean;
private _disableAnimation: boolean;
public itemTemplateUpdated(oldData: any, newData: any): void {}
private _orientation: UIPageViewControllerNavigationOrientation;
private _options: NSDictionary<any, any>;
Expand Down Expand Up @@ -238,6 +239,14 @@ export class Pager extends PagerBase {
this._ios.dataSource = this.dataSource;
}
}

get disableAnimation(): boolean {
return this._disableAnimation;
}
set disableAnimation(value: boolean) {
this._disableAnimation = value;
}

public onUnloaded() {
this._ios.delegate = null;
super.onUnloaded();
Expand All @@ -260,7 +269,6 @@ export class Pager extends PagerBase {
this.heightMeasureSpec
);

// View.layoutChild(this, view, 0, 0, this.layoutWidth, this.layoutHeight);
View.layoutChild(
this,
view,
Expand All @@ -273,7 +281,7 @@ export class Pager extends PagerBase {
}

public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
// console.log(`Pager.onMeasure: ${widthMeasureSpec}x${heightMeasureSpec}`)

this.widthMeasureSpec = widthMeasureSpec;
this.heightMeasureSpec = heightMeasureSpec;

Expand All @@ -289,7 +297,6 @@ export class Pager extends PagerBase {
widthMeasureSpec,
heightMeasureSpec
);
// console.log(`Pager.onMeasure - measureChild = (${measuredWidth}x${measuredHeight})`);

// Check against our minimum sizes
measuredWidth = Math.max(measuredWidth, this.effectiveMinWidth);
Expand Down Expand Up @@ -382,7 +389,7 @@ export class Pager extends PagerBase {
owner._ios.setViewControllersDirectionAnimatedCompletion(
NSArray.arrayWithObject(vc),
direction,
false,
this.disableAnimation,
null
);
});
Expand Down

0 comments on commit b0a2101

Please sign in to comment.