Skip to content

Commit 4474974

Browse files
fix(slides): expose interface to provide custom animations (#17959)
fixes #16616 Co-Authored-By: CFT-Chris <mail@chrislo.ca>
1 parent 18b347b commit 4474974

File tree

8 files changed

+449
-13
lines changed

8 files changed

+449
-13
lines changed

core/src/components/slides/readme.md

Lines changed: 426 additions & 4 deletions
Large diffs are not rendered by default.

core/src/components/slides/slides.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export class Slides implements ComponentInterface {
313313
// Base options, can be changed
314314
// TODO Add interface SwiperOptions
315315
const swiperOptions: SwiperOptions = {
316-
effect: 'slide',
316+
effect: undefined,
317317
direction: 'horizontal',
318318
initialSlide: 0,
319319
loop: false,
@@ -438,8 +438,13 @@ export class Slides implements ComponentInterface {
438438
}
439439
};
440440

441+
const customEvents = (!!this.options && !!this.options.on) ? this.options.on : {};
442+
443+
// merge "on" event listeners, while giving our event listeners priority
444+
const mergedEventOptions = { on: { ...customEvents, ...eventOptions.on } };
445+
441446
// Merge the base, user options, and events together then pas to swiper
442-
return { ...swiperOptions, ...this.options, ...eventOptions };
447+
return { ...swiperOptions, ...this.options, ...mergedEventOptions };
443448
}
444449

445450
hostData() {
11 KB
Loading

core/src/components/slides/test/image/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
<ion-content id="content">
2525
<ion-slides style="background: black" id="slides" pager>
2626
<ion-slide style="background: rgb(0, 200, 0); color: white;">
27-
<img src="http://lorempixel.com/400/200/cats/">
27+
<img src="image/cat.jpeg">
2828
</ion-slide>
2929
<ion-slide style="background: white; color: blue;">
30-
<img src="http://lorempixel.com/400/200/cats/">
30+
<img src="image/cat.jpeg">
3131
</ion-slide>
3232
<ion-slide style="background: blue; color: white;">
33-
<img src="http://lorempixel.com/400/200/cats/">
33+
<img src="image/cat.jpeg">
3434
</ion-slide>
3535
</ion-slides>
3636
<ion-button expand="block" onclick="slidePrev()">Slide Prev</ion-button>

core/src/components/slides/usage/angular.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import { Component } from '@angular/core';
1818
`
1919
})
2020
export class SlideExample {
21+
// Optional parameters to pass to the swiper instance. See http://idangero.us/swiper/api/ for valid options.
2122
slideOpts = {
22-
effect: 'flip'
23+
initialSlide: 1,
24+
speed: 400
2325
};
2426
constructor() {}
2527
}

core/src/components/slides/usage/javascript.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
```javascript
1919
var slides = document.querySelector('ion-slides');
20+
21+
// Optional parameters to pass to the swiper instance. See http://idangero.us/swiper/api/ for valid options.
2022
slides.options = {
21-
effect: 'flip'
23+
initialSlide: 1,
24+
speed: 400
2225
}
2326
```

core/src/components/slides/usage/react.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import React from 'react';
33

44
import { IonSlides, IonSlide } from '@ionic/react';
55

6+
// Optional parameters to pass to the swiper instance. See http://idangero.us/swiper/api/ for valid options.
67
const slideOpts = {
7-
effect: 'flip'
8+
initialSlide: 1,
9+
speed: 400
810
};
911

1012
const Example: React.SFC<{}> = () => (

core/src/components/slides/usage/vue.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
2020
@Component()
2121
export default class SelectExample extends Vue {
22+
// Optional parameters to pass to the swiper instance. See http://idangero.us/swiper/api/ for valid options.
2223
slideOpts = {
23-
effect: 'flip'
24+
initialSlide: 1,
25+
speed: 400
2426
};
2527
}
2628
</script>

0 commit comments

Comments
 (0)