Skip to content

Commit

Permalink
feat: Jump to initial slide without animation closes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
makiJS committed Jul 12, 2019
1 parent de66c43 commit 7a715e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/ng-slider/src/lib/slides/slides.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="jp-s-w" #wrapper>
<div class="jp-s-w-i" [style.width.%]="contentWidth" [style.transform]="transform" #wrapperInner [class.active]="!inPan">
<div class="jp-s-w-i" [style.width.%]="contentWidth" [style.transform]="transform" #wrapperInner [class.active]="!inPan && !blockSlideAnimation">
<div *ngFor="let slide of slides" [style.width.%]="blockWidth">
<ng-template [ngTemplateOutlet]="slide.content"></ng-template>
</div>
Expand Down
5 changes: 5 additions & 0 deletions projects/ng-slider/src/lib/slides/slides.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,13 @@ export class SlidesComponent implements OnInit, AfterViewInit, OnDestroy {
const slides = this.slides.toArray();

if (initialSlide) {
this.blockSlideAnimation = true;
this.left = -this.slideWidthPercentage * initialSlide;
this.cdr.detectChanges();
setTimeout(() => {
this.blockSlideAnimation = false;
// todo: follow up dynamic value when it's implemented #4
}, 500);
} else {
this.left = 0;
}
Expand Down

0 comments on commit 7a715e9

Please sign in to comment.