G
Guest
hey all,
am i running the following javascript as fast as possible: All i'm trying to
do is move an innerDIV via an outerDIV left and right. if i click real fast
on the button it only moves one step after 2 clicks, if i click real slow it
will move normal.
<script type="text/javascript">
var x // Gets innerDiv
var y // Gets outerDiv
var z; // Testing: Gets Label for testing purposes only
var xValue=0; // Approximate position of scroll
var count; // The maximum scroll width
var Btn_Left // Scroll Left Button
var Btn_Right // Scroll Right Button
function BtnLeft_onclick() {
inzsr();
xValue+=100;
x.style.left=xValue;
z.innerText=xValue + ' ' + count;
SetButtonStates()
}
function BtnRight_onclick() {
inzsr();
xValue-=100;
x.style.left=xValue;
z.innerText=xValue + ' ' + count;
SetButtonStates();
}
function inzsr(){
x=document.getElementById("SecondDiv");
y=document.getElementById("FirstDiv");
z=document.getElementById("Label1");
Btn_Left=document.getElementById("BtnLeft");
Btn_Right=document.getElementById("BtnRight");
count=x.scrollWidth;
SetButtonStates();
}
function SetButtonStates(){
Btn_Right.disabled=(count+xValue<100)?true:false;
Btn_Left.disabled=(xValue>=0)?true:false;
}
</script>
am i running the following javascript as fast as possible: All i'm trying to
do is move an innerDIV via an outerDIV left and right. if i click real fast
on the button it only moves one step after 2 clicks, if i click real slow it
will move normal.
<script type="text/javascript">
var x // Gets innerDiv
var y // Gets outerDiv
var z; // Testing: Gets Label for testing purposes only
var xValue=0; // Approximate position of scroll
var count; // The maximum scroll width
var Btn_Left // Scroll Left Button
var Btn_Right // Scroll Right Button
function BtnLeft_onclick() {
inzsr();
xValue+=100;
x.style.left=xValue;
z.innerText=xValue + ' ' + count;
SetButtonStates()
}
function BtnRight_onclick() {
inzsr();
xValue-=100;
x.style.left=xValue;
z.innerText=xValue + ' ' + count;
SetButtonStates();
}
function inzsr(){
x=document.getElementById("SecondDiv");
y=document.getElementById("FirstDiv");
z=document.getElementById("Label1");
Btn_Left=document.getElementById("BtnLeft");
Btn_Right=document.getElementById("BtnRight");
count=x.scrollWidth;
SetButtonStates();
}
function SetButtonStates(){
Btn_Right.disabled=(count+xValue<100)?true:false;
Btn_Left.disabled=(xValue>=0)?true:false;
}
</script>