-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b61435
commit c6a8256
Showing
6 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './spinner.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="sim-spinner-loading" *ngIf="loading"> | ||
<span class="sim-spinner-loading-dot"><i></i><i></i><i></i><i></i></span> | ||
<div class="sim-spinner-loading-text">{{_tips}}</div> | ||
</div> | ||
<div class="sim-spinner-container" [ngClass]="{'sim-spinner-masking': loading}"> | ||
<ng-content></ng-content> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
.sim-spinner { | ||
position: relative; | ||
display: block; | ||
&-loading { | ||
position: absolute; | ||
height: 100%; | ||
max-height: 320px; | ||
width: 100%; | ||
z-index: 4; | ||
color: #108ee9; | ||
vertical-align: middle; | ||
text-align: center; | ||
transition: transform .3s cubic-bezier(.78, .14, .15, .86); | ||
font-size: 12px; | ||
&-text { | ||
position: absolute; | ||
top: 50%; | ||
width: 100%; | ||
padding-top: 24px; | ||
} | ||
&-dot { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
margin: -16px; | ||
width: 32px; | ||
height: 32px; | ||
transform: rotate(45deg); | ||
animation: rotate 1.2s infinite linear; | ||
i { | ||
width: 14px; | ||
height: 14px; | ||
border-radius: 100%; | ||
background-color: #108ee9; | ||
-webkit-transform: scale(.75); | ||
transform: scale(.75); | ||
display: block; | ||
position: absolute; | ||
opacity: .3; | ||
animation: spinnerMove 1s infinite linear alternate; | ||
-webkit-transform-origin: 50% 50%; | ||
transform-origin: 50% 50%; | ||
} | ||
i:first-child { | ||
left: 0; | ||
top: 0; | ||
} | ||
i:nth-child(2) { | ||
right: 0; | ||
top: 0; | ||
animation-delay: .4s; | ||
} | ||
i:nth-child(3) { | ||
right: 0; | ||
bottom: 0; | ||
animation-delay: .8s; | ||
} | ||
i:nth-child(4) { | ||
left: 0; | ||
bottom: 0; | ||
animation-delay: 1.2s; | ||
} | ||
} | ||
} | ||
&-container { | ||
position: relative; | ||
z-index: 1; | ||
} | ||
&-masking:after { | ||
content: ""; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
background: #fff; | ||
opacity: .3; | ||
transition: all .3s; | ||
z-index: 10; | ||
} | ||
} | ||
|
||
@keyframes rotate { | ||
to { | ||
-webkit-transform: rotate(405deg); | ||
transform: rotate(405deg) | ||
} | ||
} | ||
|
||
@keyframes spinnerMove { | ||
to { | ||
opacity: 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SpinnerComponent } from './spinner.component'; | ||
|
||
describe('SpinnerComponent', () => { | ||
let component: SpinnerComponent; | ||
let fixture: ComponentFixture<SpinnerComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ SpinnerComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SpinnerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, HostBinding, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
// tslint:disable-next-line:component-selector | ||
selector: 'sim-spinner', | ||
templateUrl: './spinner.component.html', | ||
styleUrls: ['./spinner.component.scss'], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class SpinnerComponent implements OnInit { | ||
@HostBinding('class.sim-spinner') _simSpinner = true; | ||
|
||
@Input() loading = true; | ||
|
||
_tips = '正在读取数据...'; | ||
@Input() | ||
get tips(): string { | ||
return this._tips; | ||
} | ||
set tips(value: string) { | ||
this._tips = value; | ||
} | ||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SpinnerComponent } from './spinner.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule | ||
], | ||
declarations: [SpinnerComponent], | ||
exports: [SpinnerComponent] | ||
}) | ||
export class SpinnerModule { } |