Skip to content

Commit 0259648

Browse files
Merge pull request #24 from Obsessive/master
disablepan done
2 parents 7704453 + d122883 commit 0259648

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ the `<Slides:SlideContainer>` element also has a property called `pageIndicators
7777

7878
the `<Slides:SlideContainer>` element also has a property called `interval` which is a integer value and the value is in milliseconds. The suggested use case would be for a Image Carousel or something of that nature which can change the image for every fixed intervals. In unloaded function call `page.getViewById("your_id").stopSlideshow()` to unregister it (your_id is the id given to `<Slides:SlideContainer>`), it can be restarted with `startSlidShow`.
7979

80+
the `<Slides:SlideContainer>` element also has a property called `disablePan` which is used to disable panning when set to true. So that you can call nextSlide() function to change the slide. If slides is used to get details about users like email, phone number ,username etc in this case you don't want users to move from one slide to another slide without filling details. So, you can disablePan option.
81+
8082
#### Angular 2 compatibility
8183
To use the slides with Angular2 and the `registerElement` from `nativescript-angular` you will want to set the `SlideContainer`'s property of `angular` to `true`. Then in your angular component in the `ngAfterViewInit`. you will want to have an instance of your slide container to call the function `constructView()`.
8284

nativescript-slides.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ export declare class SlideContainer extends AbsoluteLayout {
2222
private _androidTranslucentNavBar;
2323
private timer_reference;
2424
private _angular;
25+
private _disablePan;
2526
private _footer;
2627
private _pageIndicators;
2728
pageIndicators: boolean;
2829
hasNext: boolean;
2930
hasPrevious: boolean;
3031
interval: number;
3132
loop: boolean;
33+
disablePan: boolean;
3234
androidTranslucentStatusBar: boolean;
3335
androidTranslucentNavBar: boolean;
3436
velocityScrolling: boolean;

nativescript-slides.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class SlideContainer extends AbsoluteLayout {
4747
private _androidTranslucentNavBar: boolean;
4848
private timer_reference: number;
4949
private _angular: boolean;
50+
private _disablePan: boolean;
5051
private _footer: StackLayout;
5152
private _pageIndicators: boolean;
5253

@@ -81,6 +82,14 @@ export class SlideContainer extends AbsoluteLayout {
8182
this._loop = value;
8283
}
8384

85+
get disablePan() {
86+
return this._disablePan;
87+
}
88+
89+
set disablePan(value: boolean) {
90+
this._disablePan = value;
91+
}
92+
8493
get androidTranslucentStatusBar() {
8594
return this._androidTranslucentStatusBar;
8695
}
@@ -149,6 +158,10 @@ export class SlideContainer extends AbsoluteLayout {
149158
this.interval = 0;
150159
}
151160

161+
if (this._disablePan == null) {
162+
this.disablePan = false;
163+
}
164+
152165
if (this._velocityScrolling == null) {
153166
this._velocityScrolling = false;
154167
}
@@ -171,7 +184,7 @@ export class SlideContainer extends AbsoluteLayout {
171184
return;
172185
}
173186
// Android Translucent bars API >= 19 only
174-
if (this.androidTranslucentStatusBar === true || this._androidTranslucentNavBar === true && app.android && Platform.device.sdkVersion >= '19') {
187+
if ((this.androidTranslucentStatusBar === true || this._androidTranslucentNavBar === true) && app.android && Platform.device.sdkVersion >= '19') {
175188
let window = app.android.startActivity.getWindow();
176189

177190
// check for status bar
@@ -205,7 +218,9 @@ export class SlideContainer extends AbsoluteLayout {
205218

206219
this.currentPanel = this.buildSlideMap(slides);
207220
this.currentPanel.panel.translateX = -this.pageWidth;
208-
this.applySwipe(this.pageWidth);
221+
if(disablePan == false) {
222+
this.applySwipe(this.pageWidth);
223+
}
209224

210225
//handles application orientation change
211226
app.on(app.orientationChangedEvent, (args: app.OrientationChangedEventData) => {
@@ -216,7 +231,9 @@ export class SlideContainer extends AbsoluteLayout {
216231
view.width = this.pageWidth;
217232
}
218233
});
219-
this.applySwipe(this.pageWidth);
234+
if(disablePan == false) {
235+
this.applySwipe(this.pageWidth);
236+
}
220237
let topOffset = Platform.screen.mainScreen.heightDIPs - 105;
221238
AbsoluteLayout.setTop(this._footer, topOffset);
222239
this.currentPanel.panel.translateX = -this.pageWidth;
@@ -291,8 +308,10 @@ export class SlideContainer extends AbsoluteLayout {
291308
this.transitioning = false;
292309
this.currentPanel.panel.off('pan');
293310
this.currentPanel = panel;
311+
if(disablePan == false) {
312+
this.applySwipe(this.pageWidth);
313+
}
294314
this.setActivePageIndicator(this.currentPanel.index);
295-
this.applySwipe(this.pageWidth);
296315
this.rebindSlideShow();
297316
}
298317

@@ -541,4 +560,4 @@ export class SlideContainer extends AbsoluteLayout {
541560
activeIndicator.opacity = 0.9;
542561

543562
}
544-
}
563+
}

0 commit comments

Comments
 (0)