Skip to content

Commit 5b8d3b8

Browse files
Merge pull request #71 from vahidvdn/master
swipeSpeed property is added. Docs is updated.
2 parents 3abee47 + a346cec commit 5b8d3b8

File tree

6 files changed

+59
-38
lines changed

6 files changed

+59
-38
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ This very much a work in progress. Please feel free to contribute.
101101

102102
- **pageIndicators : boolean** - If true adds indicator dots to the bottom of your slides.
103103

104+
- **swipeSpeed : number** - Determines the speed of swipe. The bigger `swipeSpeed` property is, the faster you swipe the slides. Default value is 3. Try changing it to 15 to see the result.
105+
104106
#### Indicators
105107

106108
If the property `pageIndicators` is `true` you won't see the page indicators anymore as of 2.0.0 right away. there are two css classes exposed that you can setup however you like for active and inactive indicators. below is an example for semi translucent dots.

app/App_Resources/Android/app.gradle

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// Add your native dependencies here:
2-
3-
// Uncomment to add recyclerview-v7 dependency
4-
//dependencies {
5-
// compile 'com.android.support:recyclerview-v7:+'
6-
//}
7-
8-
android {
9-
defaultConfig {
10-
generatedDensities = []
11-
applicationId = "__PACKAGE__"
12-
}
13-
aaptOptions {
14-
additionalParameters "--no-version-vectors"
15-
}
16-
}
1+
// Add your native dependencies here:
2+
3+
// Uncomment to add recyclerview-v7 dependency
4+
//dependencies {
5+
// compile 'com.android.support:recyclerview-v7:+'
6+
//}
7+
8+
android {
9+
defaultConfig {
10+
generatedDensities = []
11+
applicationId = "org.nativescript.nativescriptpackagr"
12+
}
13+
aaptOptions {
14+
additionalParameters "--no-version-vectors"
15+
}
16+
}

app/home/home.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<StackLayout>
2-
<slides loop="true" [pageIndicators]="true">
2+
<slides loop="true" [pageIndicators]="true" [swipeSpeed]="20">
33
<slide class="slide-1">
44
<Label text="Slide 1" textWrap="true"></Label>
55
</slide>
@@ -10,4 +10,4 @@
1010
<Label text="Slide 3" textWrap="true"></Label>
1111
</slide>
1212
</slides>
13-
</StackLayout>
13+
</StackLayout>

lib/src/slides/slides.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class SlidesComponent implements OnInit, AfterViewInit, OnDestroy {
6262
@Input("footerMarginTop") footerMarginTop: number;
6363
@Input("loop") loop: boolean;
6464
@Input("pageIndicators") pageIndicators: boolean;
65+
@Input("swipeSpeed") swipeSpeed: number;
6566
@Input("class") cssClass: string = "";
6667
@Input() zoomEnabled = false;
6768
@Input("autoInit") autoInit: boolean = true;
@@ -100,6 +101,7 @@ export class SlidesComponent implements OnInit, AfterViewInit, OnDestroy {
100101
ngOnInit() {
101102
this.loop = this.loop ? this.loop : false;
102103
this.pageIndicators = this.pageIndicators ? this.pageIndicators : false;
104+
this.swipeSpeed = this.swipeSpeed ? this.swipeSpeed : 3;
103105
this.pageWidth = this.pageWidth
104106
? this.pageWidth
105107
: platform.screen.mainScreen.widthDIPs;
@@ -390,7 +392,7 @@ export class SlidesComponent implements OnInit, AfterViewInit, OnDestroy {
390392
// if velocityScrolling is enabled then calculate the velocitty
391393

392394
// swiping left to right.
393-
if (args.deltaX > this.pageWidth / 3) {
395+
if (args.deltaX > this.pageWidth / this.swipeSpeed) {
394396
if (this.hasPrevious) {
395397
this.transitioning = true;
396398
this.showLeftSlide(
@@ -410,7 +412,7 @@ export class SlidesComponent implements OnInit, AfterViewInit, OnDestroy {
410412
return;
411413
}
412414
// swiping right to left
413-
else if (args.deltaX < -this.pageWidth / 3) {
415+
else if (args.deltaX < -this.pageWidth / this.swipeSpeed) {
414416
if (this.hasNext) {
415417
this.transitioning = true;
416418
this.showRightSlide(

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"id": "org.nativescript.nativescriptpackagr",
88
"tns-ios": {
99
"version": "4.2.0"
10+
},
11+
"tns-android": {
12+
"version": "4.2.0"
1013
}
1114
},
1215
"scripts": {
@@ -38,4 +41,4 @@
3841
"ng-packagr": "^3.0.1",
3942
"typescript": "~2.7.2"
4043
}
41-
}
44+
}

tsconfig.json

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
{
2-
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "es5",
5-
"experimentalDecorators": true,
6-
"emitDecoratorMetadata": true,
7-
"noEmitHelpers": true,
8-
"noEmitOnError": true,
9-
"lib": ["es6", "dom", "es2015.iterable"],
10-
"baseUrl": ".",
11-
"paths": {
12-
"~/*": ["app/*"],
13-
"nativescript-ngx-slides": ["./lib/index.ts"],
14-
"*": ["./node_modules/tns-core-modules/*", "./node_modules/*"]
15-
}
16-
},
17-
"exclude": ["node_modules", "platforms"]
18-
}
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es5",
5+
"experimentalDecorators": true,
6+
"emitDecoratorMetadata": true,
7+
"noEmitHelpers": true,
8+
"noEmitOnError": true,
9+
"lib": [
10+
"es6",
11+
"dom",
12+
"es2015.iterable"
13+
],
14+
"baseUrl": ".",
15+
"paths": {
16+
"~/*": [
17+
"app/*"
18+
],
19+
"nativescript-ngx-slides": [
20+
"./lib/index.ts"
21+
],
22+
"*": [
23+
"./node_modules/tns-core-modules/*",
24+
"./node_modules/*"
25+
]
26+
}
27+
},
28+
"exclude": [
29+
"node_modules",
30+
"platforms"
31+
]
32+
}

0 commit comments

Comments
 (0)