Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ the `SlideContainer` class also has public `nextSlide` and `previousSlide` funct

the `<Slides:SlideContainer>` element also has a property called `loop` which is a boolean value and if set to true will cause the slide to be an endless loop. The suggested use case would be for a Image Carousel or something of that nature.

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>`).

#### Android Optional Attribute
- `AndroidTransparentStatusBar`: boolean - If true, the Android status bar will be transparent on devices that support it. Typically this is API >=21 (Lollipop).

Expand Down Expand Up @@ -124,4 +126,4 @@ https://github.com/NathanWalker/nativescript-plugin-seed

[MIT](/LICENSE)

for {N} version 2.0.0+
for {N} version 2.0.0+
5 changes: 5 additions & 0 deletions nativescript-slides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ export declare class SlideContainer extends AbsoluteLayout {
private direction;
private _loop;
private _AndroidTransparentStatusBar;
private timer_reference;
private _interval;
interval: number;
loop: boolean;
AndroidTransparentStatusBar: boolean;
pageWidth: number;
android: any;
ios: any;
constructor();
constructView(): void;
stopSlideshow(): void;
nextSlide(): void;
previousSlide(): void;
private setupLeftPanel();
Expand All @@ -33,4 +37,5 @@ export declare class SlideContainer extends AbsoluteLayout {
private setwidthPercent(view, percentage);
private newFooterButton(name);
private buildSlideMap(views);
private carousel(isenabled, time);
}
26 changes: 26 additions & 0 deletions nativescript-slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@ export class SlideContainer extends AbsoluteLayout {
private _pageWidth: number;
private transitioning: boolean;
private direction: direction = direction.none;
private _loop: boolean;
private _interval: number;
private _AndroidTransparentStatusBar: boolean;
private _loop: boolean
private _AndroidTransparentStatusBar: boolean;

get interval() {
return this._interval;
}

set interval(value: boolean) {
this._interval = value;
}

get loop() {
return this._loop;
}
Expand Down Expand Up @@ -122,6 +133,18 @@ export class SlideContainer extends AbsoluteLayout {

}

private carousel(isenabled: boolean,time: number) {
if (isenabled) {
this.timer_reference = setInterval(() => {
this.nextSlide();
},time);
}else {
clearTimeout(this.timer_reference);
}
}
public stopSlideshow() {
this.carousel(false,0);
}
public nextSlide() {
this.transitioning = true;
this.showRightSlide(this.currentPanel).then(() => {
Expand Down Expand Up @@ -319,6 +342,9 @@ export class SlideContainer extends AbsoluteLayout {
slideMap[0].left = slideMap[slideMap.length - 1];
slideMap[slideMap.length - 1].right = slideMap[0];
}
if (this.interval !== 0) {
this.carousel(true,this.interval);
}
return slideMap[0];
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
"name": "Brad Martin",
"email": "bradwaynemartin@gmail.com",
"url": "https://github.com/bradmartin"
}
},
{
"name": "Obsessive Inc/Abhijith Reddy",
"email": "mabhijith95a10@gmail.com",
"url": "https://github.com/Obsessive"
}
],
"bugs": {
"url": "https://github.com/TheOriginalJosh/nativescript-slides/issues"
Expand All @@ -56,4 +61,4 @@
"devDependencies": {
"typescript": "^1.8.7"
}
}
}