Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Commit

Permalink
Fixed all event sending bugs caused by typos
Browse files Browse the repository at this point in the history
  • Loading branch information
sconix committed Aug 1, 2017
1 parent 342fadb commit 8fbc9b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Angular wrapper library for Swiper",
"bugs": "https://github.com/zefoy/ngx-swiper-wrapper/issues",
"license": "MIT",
"version": "4.5.1",
"version": "4.5.2",
"main": "bundles/ngx-swiper-wrapper.umd.js",
"module": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/swiper.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="swiper-container" [swiper]="getConfig()" [hidden]="hidden" [disabled]="disabled" [useSwiperClass]="useSwiperClass" [runInsideAngular]="runInsideAngular" (onIndexChange)="onIndexUpdate($event, 'indexChange')" (init)="onIndexUpdate($event, 'S_INIT')" (destroy)="S_DESTROY.emit($event)" (scroll)="S_SCROLL.emit($event)" (progress)="S_PROGRESS.emit($event)" (setTranslate)="S_SETTRANSLATE.emit($event)" (setTransition)="S_SETTRANSITION.emit($event)" (autoplay)="S_AUTOPLAY.emit($event)" (autoplayStart)="S_AUTOPLAYSTART.emit($event)" (autoplayStop)="S_AUTOPLAYSTOP.emit($event)" (reachBeginning)="S_REACHBEGINNING.emit($event)" (reachEnd)="S_REACHEND.emit($event)" (slideChangeStart)="S_SLIDECHANGESTART.emit($event)" (slideChangeEnd)="S_SLIDECHANGEEND.emit($event)" (slideNextStart)="S_SLIDENEXTSTART.emit($event)" (slideNextEnd)="S_SLIDENEXTEND.emit($event)" (slidePrevStart)="S_SLIDEPREVSTART.emit($event)" (slidePrevEnd)="S_SLIDEPREVEND.emit($event)" (sliderMove)="S_SLIDERMOVE.emit($event)" (swiperClick)="S_CLICK.emit($event)" (swiperTap)="S_TAP.emit($event)" (swiperDoubleTap)="S_DOUBLETAP.emit($event)" (swiperTouchStart)="S_TOUCHSTART.emit($event)" (swiperTouchMove)="S_TOUCHMOVE.emit($event)" (swiperTouchMoveOpposite)="S_TOUCHMOVEOPPOSITE.emit($event)" (swiperTouchEnd)="S_TOUCHEND.emit($event)" (swiperTransitionStart)="S_TRANSITIONSTART.emit($event)" (swiperTransitionEnd)="S_TRANSITIONEND.emit($event)" (imagesReady)="S_IMAGESREADY.emit($event)" (lazyImageLoad)="S_LAZYIMAGELOAD.emit($event)" (lazyImageReady)="S_LAZYIMAGEREADY.emit($event)" (paginationRendered)="S_PAGINATIONRENDERED.emit($event)">
<div class="swiper-container" [swiper]="getConfig()" [hidden]="hidden" [fxHide]="fxHide" [fxShow]="fxShow" [disabled]="disabled" [useSwiperClass]="useSwiperClass" [runInsideAngular]="runInsideAngular" (indexChange)="onIndexUpdate($event, 'indexChange')" (init)="onIndexUpdate($event, 'S_INIT')" (destroy)="S_DESTROY.emit($event)" (scroll)="S_SCROLL.emit($event)" (progress)="S_PROGRESS.emit($event)" (setTranslate)="S_SETTRANSLATE.emit($event)" (setTransition)="S_SETTRANSITION.emit($event)" (autoplay)="S_AUTOPLAY.emit($event)" (autoplayStart)="S_AUTOPLAYSTART.emit($event)" (autoplayStop)="S_AUTOPLAYSTOP.emit($event)" (reachBeginning)="S_REACHBEGINNING.emit($event)" (reachEnd)="S_REACHEND.emit($event)" (slideChangeStart)="S_SLIDECHANGESTART.emit($event)" (slideChangeEnd)="S_SLIDECHANGEEND.emit($event)" (slideNextStart)="S_SLIDENEXTSTART.emit($event)" (slideNextEnd)="S_SLIDENEXTEND.emit($event)" (slidePrevStart)="S_SLIDEPREVSTART.emit($event)" (slidePrevEnd)="S_SLIDEPREVEND.emit($event)" (sliderMove)="S_SLIDERMOVE.emit($event)" (swiperClick)="S_CLICK.emit($event)" (swiperTap)="S_TAP.emit($event)" (swiperDoubleTap)="S_DOUBLETAP.emit($event)" (swiperTouchStart)="S_TOUCHSTART.emit($event)" (swiperTouchMove)="S_TOUCHMOVE.emit($event)" (swiperTouchMoveOpposite)="S_TOUCHMOVEOPPOSITE.emit($event)" (swiperTouchEnd)="S_TOUCHEND.emit($event)" (swiperTransitionStart)="S_TRANSITIONSTART.emit($event)" (swiperTransitionEnd)="S_TRANSITIONEND.emit($event)" (imagesReady)="S_IMAGESREADY.emit($event)" (lazyImageLoad)="S_LAZYIMAGELOAD.emit($event)" (lazyImageReady)="S_LAZYIMAGEREADY.emit($event)" (paginationRendered)="S_PAGINATIONRENDERED.emit($event)">
<div #swiperSlides class="swiper-wrapper">
<ng-content></ng-content>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class SwiperComponent implements DoCheck {

private paginationBulletRender: Function;

@Input() fxShow: boolean = true;
@Input() fxHide: boolean = false;

@HostBinding('hidden')
@Input() hidden: boolean = false;

Expand Down
18 changes: 12 additions & 6 deletions src/lib/swiper.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges {

private initialIndex: number;

@HostBinding('hidden')
@Input() fxShow: boolean = true;
@Input() fxHide: boolean = false;

@Input() hidden: boolean = false;

@Input() disabled: boolean = false;
Expand Down Expand Up @@ -144,8 +146,8 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges {
args = args[0];
}

if (self[`S_${eventName.toUpperCase()}`]) {
self[`S_${eventName.toUpperCase()}`].emit(args);
if (this[`S_${eventName.toUpperCase()}`]) {
this[`S_${eventName.toUpperCase()}`].emit(args);
}
});
});
Expand Down Expand Up @@ -191,12 +193,16 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges {
}

ngOnChanges(changes: SimpleChanges) {
if (this.swiper && changes['hidden'] && this.hidden) {
if (this.swiper && ((changes['hidden'] && this.hidden) ||
(changes['fxHide'] && this.fxHide) || (changes['fxShow'] && !this.fxShow)))
{
// For some reason resize causes Swiper to change index when hidden
this.initialIndex = this.swiper.activeIndex || 0;
}

if (this.swiper && changes['hidden'] && !this.hidden) {
if (this.swiper && ((changes['hidden'] && !this.hidden) ||
(changes['fxHide'] && !this.fxHide) || (changes['fxShow'] && this.fxShow)))
{
// For some reason resize causes Swiper to change index when hidden
this.swiper.activeIndex = this.initialIndex || 0;

Expand Down Expand Up @@ -275,7 +281,7 @@ export class SwiperDirective implements OnInit, DoCheck, OnDestroy, OnChanges {
}

setIndex(index: number, speed?: number, silent?: boolean) {
if (!this.swiper || this.hidden) {
if (!this.swiper || this.hidden || this.fxHide || !this.fxShow) {
this.initialIndex = index;
} else {
let realIndex = index * this.swiper.params.slidesPerGroup;
Expand Down

0 comments on commit 8fbc9b4

Please sign in to comment.