Skip to content

Commit b40f28c

Browse files
authored
Merge pull request #82 from edcarroll/develop
v0.8.0 into master
2 parents c022666 + a5105fa commit b40f28c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1491
-321
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The current list of available components with links to their docs is below:
7373
* [Dimmer](https://edcarroll.github.io/ng2-semantic-ui/#/components/dimmer)
7474
* [Dropdown](https://edcarroll.github.io/ng2-semantic-ui/#/components/dropdown)
7575
* [Message](https://edcarroll.github.io/ng2-semantic-ui/#/components/message)
76+
* [Modal](https://edcarroll.github.io/ng2-semantic-ui/#/components/modal)
7677
* [Popup](https://edcarroll.github.io/ng2-semantic-ui/#/components/popup)
7778
* [Progress](https://edcarroll.github.io/ng2-semantic-ui/#/components/progress)
7879
* [Rating](https://edcarroll.github.io/ng2-semantic-ui/#/components/rating)

components/accordion/accordion-panel.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ export class SuiAccordionPanel {
6565

6666
// Cancel all current animations, and fade the contents. The direction is automatic.
6767
this.transitionController.stopAll();
68-
this.transitionController.animate(new Transition("fade", this.transitionDuration));
68+
this.transitionController.animate(new Transition(this.transition, this.transitionDuration));
6969
}
7070
}
7171

72+
public get transition() {
73+
if (this._service) {
74+
return this._service.transition;
75+
}
76+
77+
return "fade";
78+
}
79+
7280
public get transitionDuration() {
7381
if (this._service) {
7482
// Return the service defined transition duration.

components/accordion/accordion.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import {SuiAccordionPanel} from "./accordion-panel";
33
export class SuiAccordionService {
44
public closeOthers:boolean;
55

6+
public transition:string;
67
public transitionDuration:number;
78

89
public panels:SuiAccordionPanel[];
910

1011
constructor() {
1112
this.closeOthers = true;
13+
14+
this.transition = "fade";
1215
this.transitionDuration = 350;
1316

1417
this.panels = [];

components/accordion/accordion.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export class SuiAccordion implements AfterContentInit {
3333
this._service.closeOthers = value;
3434
}
3535

36+
@Input()
37+
public set transition(transition:string) {
38+
this._service.transition = transition;
39+
}
40+
3641
@Input()
3742
public set transitionDuration(duration:number) {
3843
this._service.transitionDuration = duration;

components/collapse/collapse.ts

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Directive, ElementRef, Input, HostBinding, Renderer} from '@angular/core';
1+
import {Directive, ElementRef, Input, HostBinding, Renderer2, HostListener} from '@angular/core';
22
import "web-animations-js";
33

44
@Directive({
@@ -40,7 +40,14 @@ export class SuiCollapse {
4040
@Input()
4141
public collapseDuration:number;
4242

43-
public constructor(private _element:ElementRef, private _renderer: Renderer) {
43+
private get _animationDuration() {
44+
return this._pristine ? 0 : this.collapseDuration;
45+
}
46+
47+
// Timer for window resize counter.
48+
private _resizeTimeout:number;
49+
50+
public constructor(private _element:ElementRef, private _renderer:Renderer2) {
4451
this._pristine = true;
4552

4653
// Collapse animation duration is 350ms by default.
@@ -55,10 +62,10 @@ export class SuiCollapse {
5562
this._isExpanded = false;
5663

5764
// Forcibly hide the overflow so that content is not visible past the boundaries of its container.
58-
this._renderer.setElementStyle(this._element.nativeElement, 'overflow', 'hidden');
65+
this._renderer.setStyle(this._element.nativeElement, 'overflow', 'hidden');
5966

6067
// Animate the host element from its scroll height to 0.
61-
this.animate(this._element.nativeElement.scrollHeight, 0, () => {
68+
this.animate(this._element.nativeElement.scrollHeight, 0, false, () => {
6269
this._isCollapsing = false;
6370
});
6471
}
@@ -67,38 +74,47 @@ export class SuiCollapse {
6774
this._isCollapsing = true;
6875

6976
// Animate the host element from its offset height to its scroll height.
70-
this.animate(this._element.nativeElement.offsetHeight, this._element.nativeElement.scrollHeight, () => {
77+
this.animate(this._element.nativeElement.offsetHeight, this._element.nativeElement.scrollHeight, true, () => {
7178
// Remove the overflow override to enable user styling once again.
72-
this._renderer.setElementStyle(this._element.nativeElement, 'overflow', null);
79+
this._renderer.removeStyle(this._element.nativeElement, 'overflow');
7380

7481
this._isCollapsing = false;
7582
this._isExpanded = true;
7683
});
7784
}
7885

79-
private animate(startHeight:number, endHeight:number, callback:() => void) {
86+
private animate(startHeight:number, endHeight:number, removeOnComplete:boolean = false, callback:() => void = () => {}) {
87+
const heightFrames = [
88+
{
89+
offset: 0,
90+
height: `${startHeight}px`
91+
},
92+
{
93+
offset: 1,
94+
height: `${endHeight}px`
95+
}
96+
];
97+
98+
if (removeOnComplete) {
99+
heightFrames.push({
100+
offset: 1,
101+
height: `auto`
102+
});
103+
}
104+
80105
// Animate the collapse using the web animations API.
81-
this._renderer.invokeElementMethod(
82-
this._element.nativeElement,
83-
"animate",
84-
[
85-
[
86-
{
87-
height: `${startHeight}px`
88-
},
89-
{
90-
height: `${endHeight}px`
91-
}
92-
],
93-
{
94-
delay: 0,
95-
// Disable animation on 1st collapse / expansion.
96-
duration: this._pristine ? 0 : this.collapseDuration,
97-
iterations: 1,
98-
easing: "ease",
99-
fill: "both"
100-
}
101-
]);
106+
// Using directly because Renderer2 doesn't have invokeElementMethod method anymore.
107+
this._element.nativeElement.animate(
108+
heightFrames,
109+
{
110+
delay: 0,
111+
// Disable animation on 1st collapse / expansion.
112+
duration: this._animationDuration,
113+
iterations: 1,
114+
easing: "ease",
115+
fill: "both"
116+
}
117+
);
102118

103119
if (this._pristine) {
104120
// Remove pristine flag when first hit.

components/dimmer/dimmer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import {Component, Input, Output, HostBinding, HostListener, EventEmitter, Renderer, ElementRef, ChangeDetectorRef} from '@angular/core';
1+
import {Component, Input, Output, HostBinding, HostListener, EventEmitter, Renderer2, ElementRef, ChangeDetectorRef} from '@angular/core';
22
import {SuiTransition, Transition, TransitionDirection} from '../transition/transition';
33
import {TransitionController} from '../transition/transition-controller';
44

55
@Component({
66
selector: 'sui-dimmer',
7-
exportAs: 'suiDimmer',
87
template: `
98
<div class="content">
109
<div class="center">
@@ -48,7 +47,7 @@ export class SuiDimmer extends SuiTransition {
4847

4948
if (this._transitionController.isVisible != dimmed) {
5049
this._transitionController.stopAll();
51-
this._transitionController.animate(new Transition("fade", 300, dimmed ? TransitionDirection.In : TransitionDirection.Out));
50+
this._transitionController.animate(new Transition("fade", this.transitionDuration, dimmed ? TransitionDirection.In : TransitionDirection.Out));
5251
}
5352
}
5453
}
@@ -65,7 +64,7 @@ export class SuiDimmer extends SuiTransition {
6564
@Input()
6665
public transitionDuration:number;
6766

68-
constructor(renderer:Renderer, element:ElementRef, changeDetector:ChangeDetectorRef) {
67+
constructor(renderer:Renderer2, element:ElementRef, changeDetector:ChangeDetectorRef) {
6968
super(renderer, element, changeDetector);
7069

7170
this._isDimmed = false;

components/dropdown/dropdown-menu.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Directive, HostBinding, ContentChild, forwardRef, Renderer, ElementRef, AfterContentInit, ContentChildren, QueryList, Input, HostListener, ChangeDetectorRef} from '@angular/core';
1+
import {Directive, HostBinding, ContentChild, forwardRef, Renderer2, ElementRef, AfterContentInit, ContentChildren, QueryList, Input, HostListener, ChangeDetectorRef} from '@angular/core';
22
import {SuiTransition, Transition} from '../transition/transition';
33
import {DropdownService, DropdownAutoCloseType} from './dropdown.service';
44
import {TransitionController} from '../transition/transition-controller';
@@ -25,7 +25,11 @@ export class SuiDropdownMenuItem {
2525

2626
public set isSelected(value:boolean) {
2727
// Renderer is used to enable a dynamic class name.
28-
this._renderer.setElementClass(this.element.nativeElement, this.selectedClass, value)
28+
if(value){
29+
this._renderer.addClass(this.element.nativeElement, this.selectedClass)
30+
}else{
31+
this._renderer.removeClass(this.element.nativeElement, this.selectedClass);
32+
}
2933
}
3034

3135
// Stores the class name used for a 'selected' item.
@@ -38,15 +42,15 @@ export class SuiDropdownMenuItem {
3842
return !!this.childDropdownMenu;
3943
}
4044

41-
constructor(private _renderer:Renderer, public element:ElementRef) {
45+
constructor(private _renderer:Renderer2, public element:ElementRef) {
4246
this.isSelected = false;
4347

4448
this.selectedClass = "selected";
4549
}
4650

4751
public performClick() {
48-
// Manually click the element. Done via renderer so as to avoid nativeElement changes directly.
49-
this._renderer.invokeElementMethod(this.element.nativeElement, "click");
52+
// Using directly because Renderer2 doesn't have invokeElementMethod method anymore.
53+
this.element.nativeElement.click();
5054
}
5155
}
5256

@@ -117,7 +121,7 @@ export class SuiDropdownMenu extends SuiTransition implements AfterContentInit {
117121
@Input()
118122
public menuSelectedItemClass:string;
119123

120-
constructor(renderer:Renderer, public element:ElementRef, changeDetector:ChangeDetectorRef) {
124+
constructor(renderer:Renderer2, public element:ElementRef, changeDetector:ChangeDetectorRef) {
121125
super(renderer, element, changeDetector);
122126

123127
// Initialise transition functionality.

components/dropdown/dropdown.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {CommonModule} from "@angular/common";
33
import {SuiTransitionModule} from "../transition/transition.module";
44
import {SuiDropdown} from './dropdown';
55
import {SuiDropdownMenu, SuiDropdownMenuItem} from './dropdown-menu';
6-
import {DropdownService} from './dropdown.service';
6+
import {DropdownService, DropdownAutoCloseType} from './dropdown.service';
77

88
@NgModule({
99
imports: [
@@ -23,4 +23,4 @@ import {DropdownService} from './dropdown.service';
2323
})
2424
export class SuiDropdownModule {}
2525

26-
export {DropdownService};
26+
export {DropdownService, DropdownAutoCloseType};

components/dropdown/dropdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Directive, Input, HostBinding, EventEmitter, Output, AfterContentInit, ContentChild, Renderer, ElementRef, HostListener, QueryList, ContentChildren, forwardRef} from '@angular/core';
1+
import {Directive, Input, HostBinding, EventEmitter, Output, AfterContentInit, ContentChild, Renderer2, ElementRef, HostListener, QueryList, ContentChildren, forwardRef} from '@angular/core';
22
import {SuiTransition, Transition} from '../transition/transition';
33
import {TransitionController} from '../transition/transition-controller';
44
import {DropdownService, DropdownAutoCloseType} from './dropdown.service';

components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from "./collapse/collapse.module";
44
export * from "./dimmer/dimmer.module";
55
export * from "./dropdown/dropdown.module";
66
export * from "./message/message.module";
7+
export * from "./modal/modal.module";
78
export * from "./popup/popup.module";
89
export * from "./progress/progress.module";
910
export * from "./rating/rating.module";

0 commit comments

Comments
 (0)