nativescript-slides
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -28,3 +28,5 @@ import { AbsoluteLayout } from 'ui/layouts/absolute-layout'; | ||
private _pageIndicators; | ||
private _indicatorsColor; | ||
pageIndicators: boolean; | ||
indicatorsColor: string; | ||
hasNext: boolean; | ||
@@ -57,8 +59,8 @@ hasPrevious: boolean; | ||
private showLeftSlide(panelMap, offset?, endingVelocity?); | ||
private buildFooter(pageCount?, activeIndex?); | ||
private buildFooter(pageCount, activeIndex, iColor); | ||
private setwidthPercent(view, percentage); | ||
private newFooterButton(name); | ||
private buildSlideMap(views); | ||
createIndicator(): Label; | ||
createIndicator(indicatorColor: string): Label; | ||
setActivePageIndicator(index: number): void; | ||
} |
@@ -56,2 +56,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(SlideContainer.prototype, "indicatorsColor", { | ||
get: function () { | ||
return this._indicatorsColor; | ||
}, | ||
set: function (value) { | ||
this._indicatorsColor = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SlideContainer.prototype, "hasNext", { | ||
@@ -191,2 +201,5 @@ get: function () { | ||
} | ||
if (this.indicatorsColor == null) { | ||
this.indicatorsColor = "#fff"; | ||
} | ||
}; | ||
@@ -220,4 +233,10 @@ SlideContainer.prototype.constructView = function (constructor) { | ||
}); | ||
_this._footer = _this.buildFooter(slides_1.length, 0); | ||
_this.insertChild(_this._footer, _this.getChildrenCount()); | ||
if (_this.pageIndicators) { | ||
var iColor = _this.indicatorsColor; | ||
if (!color_1.Color.isValid(iColor)) { | ||
iColor = '#fff'; | ||
} | ||
_this._footer = _this.buildFooter(slides_1.length, 0, iColor); | ||
_this.insertChild(_this._footer, _this.getChildrenCount()); | ||
} | ||
_this.currentPanel = _this.buildSlideMap(slides_1); | ||
@@ -461,3 +480,3 @@ _this.currentPanel.panel.translateX = -_this.pageWidth; | ||
}; | ||
SlideContainer.prototype.buildFooter = function (pageCount, activeIndex) { | ||
SlideContainer.prototype.buildFooter = function (pageCount, activeIndex, iColor) { | ||
if (pageCount === void 0) { pageCount = 5; } | ||
@@ -475,3 +494,3 @@ if (activeIndex === void 0) { activeIndex = 0; } | ||
while (i < pageCount) { | ||
footerInnerWrap.addChild(this.createIndicator()); | ||
footerInnerWrap.addChild(this.createIndicator(iColor)); | ||
i++; | ||
@@ -515,5 +534,5 @@ } | ||
}; | ||
SlideContainer.prototype.createIndicator = function () { | ||
SlideContainer.prototype.createIndicator = function (indicatorColor) { | ||
var indicator = new label_1.Label(); | ||
indicator.backgroundColor = new color_1.Color('#fff'); | ||
indicator.backgroundColor = new color_1.Color(indicatorColor); | ||
indicator.opacity = 0.4; | ||
@@ -520,0 +539,0 @@ indicator.width = 10; |
@@ -53,2 +53,3 @@ import * as app from 'application'; | ||
private _pageIndicators: boolean; | ||
private _indicatorsColor: string; | ||
@@ -63,2 +64,9 @@ /* page indicator stuff*/ | ||
get indicatorsColor(): string { | ||
return this._indicatorsColor; | ||
} | ||
set indicatorsColor(value: string) { | ||
this._indicatorsColor = value; | ||
} | ||
get hasNext(): boolean { | ||
@@ -177,2 +185,5 @@ return !!this.currentPanel.right; | ||
} | ||
if (this.indicatorsColor == null) { | ||
this.indicatorsColor = "#fff"; //defaults to white. | ||
} | ||
} | ||
@@ -217,3 +228,10 @@ | ||
if (this.pageIndicators) { | ||
this._footer = this.buildFooter(slides.length, 0); | ||
let iColor = this.indicatorsColor; | ||
//check if invalid and set to white (#fff) | ||
if (!Color.isValid(iColor)) { | ||
iColor = '#fff'; | ||
} | ||
this._footer = this.buildFooter(slides.length, 0, iColor); | ||
this.insertChild(this._footer, this.getChildrenCount()); | ||
@@ -486,3 +504,3 @@ // this.setActivePageIndicator(0); | ||
* */ | ||
private buildFooter(pageCount: number = 5, activeIndex: number = 0): StackLayout { | ||
private buildFooter(pageCount: number = 5, activeIndex: number = 0, iColor: string): StackLayout { | ||
let footerInnerWrap = new StackLayout(); | ||
@@ -502,3 +520,3 @@ | ||
while (i < pageCount) { | ||
footerInnerWrap.addChild(this.createIndicator()); | ||
footerInnerWrap.addChild(this.createIndicator(iColor)); | ||
i++; | ||
@@ -550,5 +568,5 @@ } | ||
createIndicator(): Label { | ||
createIndicator(indicatorColor: string): Label { | ||
let indicator = new Label(); | ||
indicator.backgroundColor = new Color('#fff'); | ||
indicator.backgroundColor = new Color(indicatorColor); | ||
indicator.opacity = 0.4; | ||
@@ -555,0 +573,0 @@ indicator.width = 10; |
{ | ||
"name": "nativescript-slides", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "NativeScript Slides plugin.", | ||
@@ -5,0 +5,0 @@ "main": "nativescript-slides.js", |
# NativeScript Slides for iOS and Android | ||
###_The plugin formally known as nativescript-intro-slides_ | ||
### _The plugin formally known as nativescript-intro-slides_ | ||
###Intro slides example: | ||
### Intro slides example: | ||
[![Nativescript Slides. Click to Play](https://img.youtube.com/vi/kGby8qtSDjM/0.jpg)](https://www.youtube.com/embed/kGby8qtSDjM) | ||
###Image carousel example: | ||
### Image carousel example: | ||
[![Nativescript Slides. Click to Play](https://img.youtube.com/vi/RsEqGAKm62k/0.jpg)](https://www.youtube.com/embed/RsEqGAKm62k) | ||
@@ -12,26 +12,26 @@ | ||
##Example Usage: | ||
###XML | ||
## Example Usage: | ||
### XML | ||
```xml | ||
<Slides:SlideContainer> | ||
<Slides:Slide class="slide-1"> | ||
<Label text="This is Panel 1" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-2"> | ||
<Label text="This is Panel 2" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-3"> | ||
<Label text="This is Panel 3" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-4"> | ||
<Label text="This is Panel 4" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-5"> | ||
<Label text="This is Panel 5" /> | ||
</Slides:Slide> | ||
<Slides:SlideContainer id="slides" pageIndicators="true" indicatorsColor="#fff"> | ||
<Slides:Slide class="slide-1"> | ||
<Label text="This is Panel 1" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-2"> | ||
<Label text="This is Panel 2" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-3"> | ||
<Label text="This is Panel 3" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-4"> | ||
<Label text="This is Panel 4" /> | ||
</Slides:Slide> | ||
<Slides:Slide class="slide-5"> | ||
<Label text="This is Panel 5" /> | ||
</Slides:Slide> | ||
</Slides:SlideContainer> | ||
``` | ||
###CSS | ||
### CSS | ||
```css | ||
@@ -71,14 +71,21 @@ .slide-1{ | ||
the `SlideContainer` class also has public `nextSlide` and `previousSlide` functions so you can add your own previous and next buttons as needed. | ||
### Methods for SlideContainer | ||
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. | ||
- **nextSlide()** - navigate to the next slide (right direction) | ||
- **previousSlide()** - navigate to the previous slide (left direction) | ||
the `<Slides:SlideContainer>` element also has a property called `velocityScrolling` which is a boolean value and if set to true will calculate transitions speeds based on the finger movement speed. | ||
### Attributes for SlideContainer | ||
the `<Slides:SlideContainer>` element also has a property called `pageIndicators` which will add indicator dots to the bottom of your slides. | ||
- **loop : boolean** - If 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>`), it can be restarted with `startSlidShow`. | ||
- **velocityScrolling : boolean** - If true will calculate transitions speeds based on the finger movement speed. | ||
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. | ||
- **pageIndicators : boolean** - If true adds indicator dots to the bottom of your slides. | ||
- **indicatorsColor : string** - color of the indicator dots. | ||
- **interval : integer** - 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`. | ||
- **disablePan : boolean** - If true panning is disabled. So that you can call nextSlide()/previousSlide() functions 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. | ||
#### Angular 2 compatibility | ||
@@ -88,4 +95,4 @@ 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()`. | ||
#### Android Optional Attributes | ||
- `androidTranslucentStatusBar`: boolean - If true, the Android status bar will be translucent on devices that support it. (Android sdk >= 19). | ||
- `androidTranslucentNavBar`: boolean - If true, the Android navigation bar will be translucent on devices that support it. (Android sdk >= 19). | ||
- **androidTranslucentStatusBar : boolean** - If true the Android status bar will be translucent on devices that support it. (Android sdk >= 19). | ||
- **androidTranslucentNavBar : boolean** - If true the Android navigation bar will be translucent on devices that support it. (Android sdk >= 19). | ||
@@ -144,3 +151,3 @@ #### Plugin Development Work Flow: | ||
###Thanks to these awesome contributors! | ||
### Thanks to these awesome contributors! | ||
@@ -156,6 +163,6 @@ [Brad Martin](https://github.com/bradmartin) | ||
##Contributing guidelines | ||
## Contributing guidelines | ||
[Contributing guidelines](https://github.com/TheOriginalJosh/nativescript-swiss-army-knife/blob/master/CONTRIBUTING.md) | ||
##License | ||
## License | ||
@@ -162,0 +169,0 @@ [MIT](/LICENSE) |
Sorry, the diff of this file is not supported yet
68265
1264
167