diff --git a/README.md b/README.md index 1b43a93..7c712ed 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ the `SlideContainer` class also has public `nextSlide` and `previousSlide` funct the `` 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 `` 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 ``). + #### 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). @@ -124,4 +126,4 @@ https://github.com/NathanWalker/nativescript-plugin-seed [MIT](/LICENSE) -for {N} version 2.0.0+ \ No newline at end of file +for {N} version 2.0.0+ diff --git a/nativescript-slides.d.ts b/nativescript-slides.d.ts index 4c2408b..aace63e 100644 --- a/nativescript-slides.d.ts +++ b/nativescript-slides.d.ts @@ -15,6 +15,9 @@ 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; @@ -22,6 +25,7 @@ export declare class SlideContainer extends AbsoluteLayout { ios: any; constructor(); constructView(): void; + stopSlideshow(): void; nextSlide(): void; previousSlide(): void; private setupLeftPanel(); @@ -33,4 +37,5 @@ export declare class SlideContainer extends AbsoluteLayout { private setwidthPercent(view, percentage); private newFooterButton(name); private buildSlideMap(views); + private carousel(isenabled, time); } diff --git a/nativescript-slides.ts b/nativescript-slides.ts index 7d4ef81..edd2176 100755 --- a/nativescript-slides.ts +++ b/nativescript-slides.ts @@ -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; } @@ -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(() => { @@ -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]; } } diff --git a/package.json b/package.json index 094f404..8e445ce 100755 --- a/package.json +++ b/package.json @@ -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" @@ -56,4 +61,4 @@ "devDependencies": { "typescript": "^1.8.7" } -} \ No newline at end of file +}