mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
chore(slides): pass lint
This commit is contained in:
@ -97,9 +97,6 @@ any
|
|||||||
#### removeView()
|
#### removeView()
|
||||||
|
|
||||||
|
|
||||||
#### resize()
|
|
||||||
|
|
||||||
|
|
||||||
#### setPages()
|
#### setPages()
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,42 +60,68 @@ Show or hide the pager
|
|||||||
|
|
||||||
#### ionSlideDidChange
|
#### ionSlideDidChange
|
||||||
|
|
||||||
|
Emitted after the active slide has changed.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideDrag
|
#### ionSlideDrag
|
||||||
|
|
||||||
|
Emitted when the slider is actively being moved.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideNextEnd
|
#### ionSlideNextEnd
|
||||||
|
|
||||||
|
Emitted when the next slide has ended.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideNextStart
|
#### ionSlideNextStart
|
||||||
|
|
||||||
|
Emitted when the next slide has started.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlidePrevEnd
|
#### ionSlidePrevEnd
|
||||||
|
|
||||||
|
Emitted when the previous slide has ended.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlidePrevStart
|
#### ionSlidePrevStart
|
||||||
|
|
||||||
|
Emitted when the previous slide has started.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideReachEnd
|
#### ionSlideReachEnd
|
||||||
|
|
||||||
|
Emitted when the slider is at the last slide.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideReachStart
|
#### ionSlideReachStart
|
||||||
|
|
||||||
|
Emitted when the slider is at its initial position.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideTouchEnd
|
#### ionSlideTouchEnd
|
||||||
|
|
||||||
|
Emitted when the user releases the touch.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideTouchStart
|
#### ionSlideTouchStart
|
||||||
|
|
||||||
|
Emitted when the user first touches the slider.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideTransitionEnd
|
#### ionSlideTransitionEnd
|
||||||
|
|
||||||
|
Emitted when the slide transition has ended.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideTransitionStart
|
#### ionSlideTransitionStart
|
||||||
|
|
||||||
|
Emitted when the slide transition has started.
|
||||||
|
|
||||||
|
|
||||||
#### ionSlideWillChange
|
#### ionSlideWillChange
|
||||||
|
|
||||||
|
Emitted before the active slide has changed.
|
||||||
|
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Component, Element, Event, EventEmitter, Method, Prop, Watch } from '@stencil/core';
|
import { Component, Element, Event, EventEmitter, Method, Prop, Watch } from '@stencil/core';
|
||||||
import { Swiper } from './vendor/swiper.js';
|
import { Swiper } from './vendor/swiper.js';
|
||||||
// import { SwiperOptions } from './vendor/swiper'; // TODO
|
import { debounce } from '../../utils/helpers';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-slides',
|
tag: 'ion-slides',
|
||||||
styleUrl: 'slides.scss',
|
styleUrl: 'slides.scss',
|
||||||
@ -12,73 +11,71 @@ export class Slides {
|
|||||||
private container: HTMLElement;
|
private container: HTMLElement;
|
||||||
private init: boolean;
|
private init: boolean;
|
||||||
private swiper: any;
|
private swiper: any;
|
||||||
private slidesId: number;
|
|
||||||
private slideId: string;
|
|
||||||
|
|
||||||
@Element() private el: HTMLElement;
|
@Element() private el: HTMLElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted before the active slide has changed.
|
* Emitted before the active slide has changed.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideWillChange: EventEmitter;
|
@Event() ionSlideWillChange: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted after the active slide has changed.
|
* Emitted after the active slide has changed.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideDidChange: EventEmitter;
|
@Event() ionSlideDidChange: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the next slide has started.
|
* Emitted when the next slide has started.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideNextStart: EventEmitter;
|
@Event() ionSlideNextStart: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the previous slide has started.
|
* Emitted when the previous slide has started.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlidePrevStart: EventEmitter;
|
@Event() ionSlidePrevStart: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the next slide has ended.
|
* Emitted when the next slide has ended.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideNextEnd: EventEmitter;
|
@Event() ionSlideNextEnd: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the previous slide has ended.
|
* Emitted when the previous slide has ended.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlidePrevEnd: EventEmitter;
|
@Event() ionSlidePrevEnd: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the slide transition has started.
|
* Emitted when the slide transition has started.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideTransitionStart: EventEmitter;
|
@Event() ionSlideTransitionStart: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the slide transition has ended.
|
* Emitted when the slide transition has ended.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideTransitionEnd: EventEmitter;
|
@Event() ionSlideTransitionEnd: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the slider is actively being moved.
|
* Emitted when the slider is actively being moved.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideDrag: EventEmitter;
|
@Event() ionSlideDrag: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the slider is at its initial position.
|
* Emitted when the slider is at its initial position.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideReachStart: EventEmitter;
|
@Event() ionSlideReachStart: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the slider is at the last slide.
|
* Emitted when the slider is at the last slide.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideReachEnd: EventEmitter;
|
@Event() ionSlideReachEnd: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the user first touches the slider.
|
* Emitted when the user first touches the slider.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideTouchStart: EventEmitter;
|
@Event() ionSlideTouchStart: EventEmitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @output {Event} Emitted when the user releases the touch.
|
* Emitted when the user releases the touch.
|
||||||
*/
|
*/
|
||||||
@Event() ionSlideTouchEnd: EventEmitter;
|
@Event() ionSlideTouchEnd: EventEmitter;
|
||||||
|
|
||||||
@ -116,21 +113,16 @@ export class Slides {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.slidesId = ++slidesId;
|
|
||||||
this.slideId = 'slides-' + this.slidesId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private initSlides() {
|
private initSlides() {
|
||||||
if (!this.init) {
|
if (!this.init) {
|
||||||
console.debug(`ion-slides, init`);
|
console.debug(`ion-slides, init`);
|
||||||
|
|
||||||
this.container = this.el.children[0] as HTMLElement;
|
this.container = this.el.children[0] as HTMLElement;
|
||||||
|
const finalOptions = this.normalizeOptions();
|
||||||
// init swiper core
|
// init swiper core
|
||||||
this.swiper = new Swiper(this.container, this.normalizeOptions());
|
this.swiper = new Swiper(this.container, finalOptions);
|
||||||
|
|
||||||
if (this.options.keyboardControl) {
|
if (finalOptions.keyboardControl) {
|
||||||
// init keyboard event listeners
|
// init keyboard event listeners
|
||||||
this.enableKeyboardControl(true);
|
this.enableKeyboardControl(true);
|
||||||
}
|
}
|
||||||
@ -261,13 +253,9 @@ export class Slides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
/**
|
let timer: number;
|
||||||
* TODO: This should change because currently componentDidLoad fires independent of whether the
|
clearTimeout(timer);
|
||||||
* child components are ready.
|
timer = setTimeout(this.initSlides.bind(this), 10);
|
||||||
*/
|
|
||||||
setTimeout(() => {
|
|
||||||
this.initSlides();
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,10 +280,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transition to the specified slide.
|
* Transition to the specified slide.
|
||||||
*
|
|
||||||
* @param {number} index The index number of the slide.
|
|
||||||
* @param {number} [speed] Transition duration (in ms).
|
|
||||||
* @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
slideTo(index: number, speed?: number, runCallbacks?: boolean) {
|
slideTo(index: number, speed?: number, runCallbacks?: boolean) {
|
||||||
@ -304,9 +288,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transition to the next slide.
|
* Transition to the next slide.
|
||||||
*
|
|
||||||
* @param {number} [speed] Transition duration (in ms).
|
|
||||||
* @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
slideNext(speed?: number, runCallbacks?: boolean) {
|
slideNext(speed?: number, runCallbacks?: boolean) {
|
||||||
@ -315,9 +296,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transition to the previous slide.
|
* Transition to the previous slide.
|
||||||
*
|
|
||||||
* @param {number} [speed] Transition duration (in ms).
|
|
||||||
* @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
slidePrev(speed?: number, runCallbacks?: boolean) {
|
slidePrev(speed?: number, runCallbacks?: boolean) {
|
||||||
@ -326,8 +304,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the index of the active slide.
|
* Get the index of the active slide.
|
||||||
*
|
|
||||||
* @returns {number} The index number of the current slide.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
getActiveIndex(): number {
|
getActiveIndex(): number {
|
||||||
@ -336,8 +312,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the index of the previous slide.
|
* Get the index of the previous slide.
|
||||||
*
|
|
||||||
* @returns {number} The index number of the previous slide.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
getPreviousIndex(): number {
|
getPreviousIndex(): number {
|
||||||
@ -346,8 +320,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the total number of slides.
|
* Get the total number of slides.
|
||||||
*
|
|
||||||
* @returns {number} The total number of slides.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
length(): number {
|
length(): number {
|
||||||
@ -357,7 +329,6 @@ export class Slides {
|
|||||||
/**
|
/**
|
||||||
* Get whether or not the current slide is the last slide.
|
* Get whether or not the current slide is the last slide.
|
||||||
*
|
*
|
||||||
* @returns {boolean} If the slide is the last slide or not.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
isEnd(): boolean {
|
isEnd(): boolean {
|
||||||
@ -366,8 +337,6 @@ export class Slides {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether or not the current slide is the first slide.
|
* Get whether or not the current slide is the first slide.
|
||||||
*
|
|
||||||
* @returns {boolean} If the slide is the first slide or not.
|
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
isBeginning(): boolean {
|
isBeginning(): boolean {
|
||||||
@ -378,7 +347,7 @@ export class Slides {
|
|||||||
* Start auto play.
|
* Start auto play.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
startAutoplay(speed?: number): void {
|
startAutoplay(): void {
|
||||||
this.swiper.startAutoplay();
|
this.swiper.startAutoplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,9 +402,6 @@ export class Slides {
|
|||||||
this.swiper.disableKeyboardControl();
|
this.swiper.disableKeyboardControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @hidden
|
|
||||||
*/
|
|
||||||
componentDidUnload() {
|
componentDidUnload() {
|
||||||
this.init = false;
|
this.init = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user