Skip to content

Commit

Permalink
Merge pull request #359 from kameelyan/master
Browse files Browse the repository at this point in the history
Add beforeChange handler and loading class/state
  • Loading branch information
cmckni3 committed Aug 24, 2019
2 parents 6b85471 + 2c3d08e commit 33ac097
Show file tree
Hide file tree
Showing 8 changed files with 12,286 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -43,3 +43,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db
/.vs
35 changes: 35 additions & 0 deletions README.md
Expand Up @@ -151,6 +151,20 @@ Note that if you are using the switch in a child `NgModule`, such as a lazy load
<ui-switch checked [disabled]="true"></ui-switch>
```

### loading

*Show a loading state for the toggle button when true. Often utilized with beforeChange.*

> type: *boolean*
> default: false
```html
<ui-switch [loading]="isLoading">
<i class="fa fa-spinner fa-pulse" *ngIf="isLoading"></i>
</ui-switch>
```

### change

> type: *boolean*
Expand Down Expand Up @@ -182,6 +196,27 @@ Note that if you are using the switch in a child `NgModule`, such as a lazy load
<ui-switch (valueChange)="onValueChange($event)"></ui-switch>
```

### beforeChange

*Utilize an observable to check that the toggle event should complete*

> type: *Observable<boolean>*
> default: noop
```html
<ui-switch [beforeChange]="OnBeforeChange"></ui-switch>
```

```javascript
OnBeforeChange: Observable<boolean> = Observable.create((observer) => {
const timeout = setTimeout(() => {
observer.next(true);
}, 2000);
return () => clearTimeout(timeout);
});
```

### size

> type: *string*
Expand Down

0 comments on commit 33ac097

Please sign in to comment.