Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-components
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
scilla-components
Commits
cfd099d5
Commit
cfd099d5
authored
Mar 14, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loop实现
parent
058b046d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
Wave.ts
src/animation/Wave.ts
+28
-3
No files found.
src/animation/Wave.ts
View file @
cfd099d5
...
...
@@ -4,7 +4,7 @@
* 波动组件
*/
import
{
ScillaComponent
,
raw
}
from
"scilla"
;
import
{
ScillaComponent
,
raw
,
ScillaEvent
}
from
"scilla"
;
const
PI2
=
Math
.
PI
*
2
;
...
...
@@ -50,10 +50,14 @@ export default class Wave extends ScillaComponent {
loop
:
number
=
-
1
;
autoPlay
:
boolean
=
true
;
onComplete
:
ScillaEvent
=
new
ScillaEvent
();
onLoopComplete
:
ScillaEvent
=
new
ScillaEvent
();
private
_playing
;
private
_waveMethod
;
private
_startTime
;
private
_oldProps
:
any
=
{};
private
_loopCounting
;
onAwake
()
{
super
.
onAwake
();
...
...
@@ -80,8 +84,16 @@ export default class Wave extends ScillaComponent {
const
{
duration
,
waveParams
,
_waveMethod
,
transform
,
transform
:
{
position
,
scale
},
_oldProps
}
=
this
;
let
loop
=
(
t
-
this
.
_startTime
)
%
duration
;
let
r
=
loop
/
duration
*
PI2
;
let
loopCounting
=
Math
.
floor
((
t
-
this
.
_startTime
)
/
duration
);
if
(
loopCounting
!=
this
.
_loopCounting
){
this
.
_loopCounting
=
loopCounting
;
if
(
this
.
onLoopEnd
()){
return
;
}
}
let
pass
=
(
t
-
this
.
_startTime
)
%
duration
;
let
r
=
pass
/
duration
*
PI2
;
let
params
=
waveParams
||
[];
let
props
=
_waveMethod
(...
params
,
r
);
...
...
@@ -104,7 +116,20 @@ export default class Wave extends ScillaComponent {
}
}
private
onLoopEnd
(){
if
(
this
.
loop
<
0
)
{
this
.
onLoopComplete
.
invoke
();
}
else
if
(
this
.
_loopCounting
<
this
.
loop
)
{
this
.
onLoopComplete
.
invoke
();
}
else
{
this
.
_playing
=
false
;
this
.
onComplete
.
invoke
();
return
true
;
}
}
play
()
{
this
.
_loopCounting
=
-
1
;
this
.
_playing
=
true
;
this
.
_startTime
=
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment