Skip to content

Commit 627c3bf

Browse files
committed
Fixed bug in transition where direction would be set wrongly
1 parent daff4af commit 627c3bf

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

components/tabs/tabset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class SuiTabset implements AfterContentInit {
2929

3030
this._tabs.changes.subscribe(tabHeaders => {
3131
setTimeout(() => {
32-
this.loadTabs()
32+
this.loadTabs();
3333
});
3434
});
3535
}

components/transition/transition.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import {Directive, HostBinding, ElementRef, AfterViewInit, Renderer} from "@angu
22

33
export interface ISuiAnimation {
44
name:string;
5-
classes?:string[];
65
duration?:number;
7-
static?:boolean;
86
display?:string;
97
direction?:string;
108
callback?:() => any;
119
}
1210

11+
interface ISuiConfiguredAnimation extends ISuiAnimation {
12+
classes?:string[];
13+
static?:boolean;
14+
}
15+
1316
@Directive({
1417
selector: '[suiTransition]',
1518
exportAs: 'transition'
@@ -62,33 +65,40 @@ export class SuiTransition {
6265
this.renderer.setElementClass(this.el.nativeElement, "hidden", value);
6366
}
6467

65-
private queue:ISuiAnimation[] = [];
68+
private queue:ISuiConfiguredAnimation[] = [];
6669

6770
private queueFirst() {
6871
return this.queue.slice(0, 1).pop();
6972
}
7073

74+
private queueLast() {
75+
return this.queue.slice(-1).pop();
76+
}
77+
7178
public animate(animation:ISuiAnimation) {
7279
animation = Object.assign({}, animation);
73-
animation.classes = animation.name.split(" ");
74-
if (!animation.duration) {
75-
animation.duration = 250;
80+
let anim = animation as ISuiConfiguredAnimation;
81+
82+
anim.classes = animation.name.split(" ");
83+
if (!anim.duration) {
84+
anim.duration = 250;
7685
}
77-
if (!animation.display) {
78-
animation.display = 'block';
86+
if (!anim.display) {
87+
anim.display = 'block';
7988
}
80-
if (!animation.static) {
81-
animation.static = ["jiggle", "flash", "shake", "pulse", "tada", "bounce"].indexOf(animation.name) != -1;
89+
if (!anim.static) {
90+
anim.static = ["jiggle", "flash", "shake", "pulse", "tada", "bounce"].indexOf(anim.name) != -1;
8291
}
83-
if (!animation.direction) {
84-
animation.direction = this.isVisible ? "out" : "in";
85-
let queueLast = this.queueFirst();
92+
if (!anim.direction) {
93+
anim.direction = this.isVisible ? "out" : "in";
94+
let queueLast = this.queueLast();
8695
if (queueLast) {
87-
animation.direction = queueLast.direction == "in" ? "out" : "in"
96+
anim.direction = queueLast.direction == "in" ? "out" : "in"
8897
}
8998
}
9099

91100
this.queue.push(animation);
101+
92102
this.performAnimation();
93103
}
94104

@@ -97,6 +107,7 @@ export class SuiTransition {
97107
return;
98108
}
99109
let animation = this.queue.slice(0, 1).pop();
110+
console.log(animation);
100111
if (!animation) {
101112
return;
102113
}
@@ -115,7 +126,7 @@ export class SuiTransition {
115126
this.animationTimeout = setTimeout(() => this.finishAnimation(animation), animation.duration);
116127
}
117128

118-
private finishAnimation(animation:ISuiAnimation) {
129+
private finishAnimation(animation:ISuiConfiguredAnimation) {
119130
this.isAnimating = false;
120131
animation.classes.forEach(c => this.renderer.setElementClass(this.el.nativeElement, c, false));
121132
this.renderer.setElementClass(this.el.nativeElement, animation.direction, false);

0 commit comments

Comments
 (0)