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
| var fnUpdatePosition = function(intLeft, intTop, jNode){
setTimeout(vibration, 2);
nb = 1 ;
function vibration(){
intCurrentLeft = parseInt(document.getElementById(jNode).offsetLeft);
intCurrentTop = parseInt(document.getElementById(jNode).offsetTop);
if (blnVibrate){
if (Math.random() > .5){
if (intCurrentTop > intTop){
intCurrentTop = (intTop - 2);
} else {
intCurrentTop = (intTop + 2);
}
} else {
if (intCurrentLeft > intLeft){
intCurrentLeft = (intLeft - 2);
} else {
intCurrentLeft = (intLeft + 2);
}
}
nb++;
}
if(nb < 20){
setTimeout(vibration,10);
} else {
intCurrentLeft = intLeft;
intCurrentTop = intTop;
}
document.getElementById(jNode).style.top = intCurrentTop+'px' ;
document.getElementById(jNode).style.left = intCurrentLeft+'px' ;
}
} |
Partager