--- six sports training logical thinking sixth step

// get a non-inline style
function getStyle (obj, attr) {
return obj.currentStyle obj.currentStyle [attr]:? GetComputedStyle (obj, 1) [attr];

}
// moving frame
function sport_06 (obj, attr, target) {
// Clear timer. 1 a.
The clearInterval (obj.timer);
. 2 // open new timer
obj.timer = setInterval (function () {
// get the current value of 1.
the let CUR = attr === 'Opacity' the parseInt (parseFloat (the getStyle (obj, attr)) * 100): the parseInt (the getStyle (obj, attr));?
// 2 calculation speed.
Speed = the let (target - CUR) /. 8;
.. 3 // detection stop
IF (CUR === target) {
the clearInterval (obj.timer);
} {the else
IF (attr === 'Opacity') {
obj.style = .opacity (CUR + Speed) / 100;
obj.style.filter = 'Alpha (Opacity' + (+ Speed CUR) + ')';
} the else {
obj.style [attr] = CUR + + Speed 'PX' ;
}
}
}, 30)
}

Guess you like

Origin blog.csdn.net/weixin_45052104/article/details/91284312