-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.js
54 lines (50 loc) · 1.26 KB
/
move.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function starMove(object,json,fnEnd)
{
clearInterval(object.timer);
object.timer=setInterval(function(){
var stop=true;
for(var attr in json)
{
var curr=parseInt(getStyle(object,attr));
var curr=0;
if(attr=='opacity')
{
curr=Math.round(parseFloat(getStyle(object,attr)*100))
}
else
{
curr=parseInt(getStyle(object,attr));
}
var speed=(json[attr]-curr)/2;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(curr!=json[attr])
{
stop=false;
}
if(attr=='opacity')
{
object.style.filter='alpha(opacity:'+(curr+speed)+')';
object.style.opacity=(curr+speed)/100;
}
else
{
object.style[attr]=curr+speed+'px';
}
}
if(stop)
{
clearInterval(object.timer);
if(fnEnd)return fnEnd;
}
},30)
}
function getStyle (obj,name) {
if(obj.currentStyle)
{
return obj.currentStyle[name];
}
else
{
return getComputedStyle(obj,false)[name];
}
}