Skip to content

Commit 916580e

Browse files
committed
Merge branch 'master' into page-indicators
# Conflicts: # nativescript-slides.ts
1 parent 8b2de04 commit 916580e

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
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: 25 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
}
@@ -172,6 +185,7 @@ export class SlideContainer extends AbsoluteLayout {
172185
}
173186
// Android Translucent bars API >= 19 only
174187
if (app.android && this.androidTranslucentStatusBar === true || this._androidTranslucentNavBar === true && Platform.device.sdkVersion >= '19') {
188+
175189
let window = app.android.startActivity.getWindow();
176190

177191
// check for status bar
@@ -205,7 +219,9 @@ export class SlideContainer extends AbsoluteLayout {
205219

206220
this.currentPanel = this.buildSlideMap(slides);
207221
this.currentPanel.panel.translateX = -this.pageWidth;
208-
this.applySwipe(this.pageWidth);
222+
if(this.disablePan === false) {
223+
this.applySwipe(this.pageWidth);
224+
}
209225

210226
//handles application orientation change
211227
app.on(app.orientationChangedEvent, (args: app.OrientationChangedEventData) => {
@@ -216,7 +232,9 @@ export class SlideContainer extends AbsoluteLayout {
216232
view.width = this.pageWidth;
217233
}
218234
});
219-
this.applySwipe(this.pageWidth);
235+
if(this.disablePan === false) {
236+
this.applySwipe(this.pageWidth);
237+
}
220238
let topOffset = Platform.screen.mainScreen.heightDIPs - 105;
221239
AbsoluteLayout.setTop(this._footer, topOffset);
222240
this.currentPanel.panel.translateX = -this.pageWidth;
@@ -291,8 +309,10 @@ export class SlideContainer extends AbsoluteLayout {
291309
this.transitioning = false;
292310
this.currentPanel.panel.off('pan');
293311
this.currentPanel = panel;
312+
if(this.disablePan == false) {
313+
this.applySwipe(this.pageWidth);
314+
}
294315
this.setActivePageIndicator(this.currentPanel.index);
295-
this.applySwipe(this.pageWidth);
296316
this.rebindSlideShow();
297317
}
298318

@@ -479,7 +499,7 @@ export class SlideContainer extends AbsoluteLayout {
479499
activeIndicator.className = 'slide-indicator-active';
480500
activeIndicator.opacity = 0.9;
481501

482-
footerInnerWrap.marginTop = <any>"88%";
502+
footerInnerWrap.marginTop = <any>'88%';
483503

484504
return footerInnerWrap;
485505
}
@@ -544,4 +564,4 @@ export class SlideContainer extends AbsoluteLayout {
544564
activeIndicator.opacity = 0.9;
545565

546566
}
547-
}
567+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-slides",
3-
"version": "1.4.5",
3+
"version": "1.5.0",
44
"description": "NativeScript Slides plugin.",
55
"main": "nativescript-slides.js",
66
"nativescript": {

0 commit comments

Comments
 (0)