以下のスニペットでは、設定しました
privates.RADIX = 10;
10
成功したコードで使用する代わりに。これは良い習慣ですか、それとも肛門保持ですか?
function peakOut = function (elem, offset, delay, callback) {
var privates = {};
// constants initialization
privates.RADIX = 10;
privates.GRAN_TIME = 15;
privates.GRAN_DIST = 1;
privates.UNITS = 'px';
// privates initialization
privates.el = elem;
privates.start = parseInt($P.getComputedStyle(privates.el).getPropertyValue("top"),
privates.RADIX);
privates.status = 'down';
privates.end = privates.start + offset;
privates.current = privates.start;
privates.id = null;
(function next() {
if ((privates.status === 'down') && (privates.current < privates.end)) {
privates.current += privates.GRAN_DIST;
privates.el.style.top = privates.current + privates.UNITS;
if (!privates.id) {
privates.id = $P.setInterval(next, privates.GRAN_TIME);
}
} else if ((privates.status === 'down') && (privates.current === privates.end)) {
privates.status = 'up';
$R.resetInterval(privates);
$P.setTimeout(next, delay);
} else if ((privates.status === 'up') && (privates.current > privates.start)) {
privates.current -= privates.GRAN_DIST;
privates.el.style.top = privates.current + privates.UNITS;
if (!privates.id) {
privates.id = $P.setInterval(next, privates.GRAN_TIME);
}
} else if ((privates.status === 'up') && (privates.current === privates.start)) {
$R.resetInterval(privates);
callback();
}
}());
};