javascript efficiency

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top