Skip to content

Commit

Permalink
fix(slides): fix rtl support.
Browse files Browse the repository at this point in the history
- fix rtl functionalities in slides when attribute (dir=“rtl”) added to
ion-slides.
- e2e test added: ‘slides/test/rtl’
  • Loading branch information
AhmadAmri authored and manucorporat committed Mar 8, 2017
1 parent bee75f7 commit e90d692
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/slides/slides.ts
Expand Up @@ -139,7 +139,7 @@ import { ViewController } from '../../navigation/view-controller';
@Component({
selector: 'ion-slides',
template:
'<div class="swiper-container">' +
'<div class="swiper-container" [attr.dir]="_rtl? \'rtl\' : null">' +
'<div class="swiper-wrapper">' +
'<ng-content></ng-content>' +
'</div>' +
Expand Down Expand Up @@ -249,6 +249,14 @@ export class Slides extends Ion {
}
private _pager = false;

/**
* @input {string} If dir attribute is equal to rtl, set interal _rtl to true;
*/
@Input()
set dir(val: string) {
this._rtl = (val.toLowerCase() === 'rtl');
}

/**
* @input {string} Type of pagination. Possible values are:
* `bullets`, `fraction`, `progress`. Default: `bullets`.
Expand Down
46 changes: 46 additions & 0 deletions src/components/slides/test/rtl/app.module.ts
@@ -0,0 +1,46 @@
import { Component, ViewChild, NgModule } from '@angular/core';
import { IonicApp, IonicModule, Slides } from '../../../../../ionic-angular';


@Component({
templateUrl: 'main.html'
})
export class E2EPage {
@ViewChild(Slides) slider: Slides;

onSlideWillChange(s: Slides) {
console.log(`onSlideWillChange: ${s}`);
}

onSlideDidChange(s: Slides) {
console.log(`onSlideDidChange: ${s}`);
}

onSlideDrag(s: Slides) {
console.log(`onSlideDrag: ${s}`);
}

}

@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class E2EApp {
root = E2EPage;
}

@NgModule({
declarations: [
E2EApp,
E2EPage
],
imports: [
IonicModule.forRoot(E2EApp)
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
E2EPage
]
})
export class AppModule {}
21 changes: 21 additions & 0 deletions src/components/slides/test/rtl/main.html
@@ -0,0 +1,21 @@
<ion-slides style="background: black"
(ionSlideWillChange)="onSlideWillChange($event)"
(ionSlideDidChange)="onSlideDidChange($event)"
(ionSlideDrag)="onSlideDrag($event)"
pager="true"
dir="rtl"
effect="slide">

<ion-slide style="background: red; color: white;">
<h1>شريحة ١</h1>

This comment has been minimized.

Copy link
@trakhimenok

trakhimenok Mar 9, 2017

@AhmadAmri, it would be good to add English translations to the texts so it's easier to understand for the rest of us.

This comment has been minimized.

Copy link
@AhmadAmri

AhmadAmri Mar 11, 2017

Author Contributor

@astec, I just used Arabic since it's RTL; the word is 'slide' in Arabic. I'll add translations.

This comment has been minimized.

Copy link
@manucorporat

manucorporat Mar 11, 2017

Contributor

@AhmadAmri you will need to submit a new PR to do so :)
anyway I understand, it makes a lot of sense to use a RTL language to test (this is a e2e test) if rtl works :)

</ion-slide>

<ion-slide style="background: white; color: blue;">
<h1>شريحة ٢</h1>
</ion-slide>

<ion-slide style="background: blue; color: white;">
<h1>شريحة ٣</h1>
</ion-slide>

</ion-slides>

0 comments on commit e90d692

Please sign in to comment.