Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrapping a script.aculo.us effect within an If statement

Status
Not open for further replies.

5398

Technical User
Jul 1, 2008
2
GB
Hello, i'm having trouble with the following:

Note: these effects are pulled from script.aculo.us

I'm trying to make it so when a function is called, it cant be called again until another is finished.

I have two buttons which make one div "slide" down and another "slide" up. Using the following:

var login_session = 0;


function login_down(){
if(login_session == 0){
Effect.BlindDown('struc_sub_login_session');
Effect.BlindDown('struc_sub_login_session', { duration: 1.0});
login_session = 1;
return false;
}
}

function login_up(){
if(login_session == 1){
Effect.BlindUp('struc_sub_login_session');
Effect.BlindUp('struc_sub_login_session', { duration: 1.0});
login_session = 0;
return false;
}
}

However, when the first function is called again the effect doesnt work properly.



The onclick code for each button is as followed:

<a href="#" onclick="login_down();">
<a href="#" onclick="login_up();">

Any help would be much appreciated. Thanks
 
how about something like this?

Code:
[red]var foo = 1;[/red]
function login_down(){
	[red]if ( foo == 0 ) {
		return false;
	}
	foo = 0;[/red]
    if(login_session == 0){
        Effect.BlindDown('struc_sub_login_session');
        Effect.BlindDown('struc_sub_login_session', { duration: 1.0});
        login_session = 1;
		[red]foo = 1;[/red]
        return false;
    }
}

function login_up(){
	[red]if ( foo == 0 ) {
		return false;
	}
    foo = 0;[/red]
    if(login_session == 1){
        Effect.BlindUp('struc_sub_login_session');
        Effect.BlindUp('struc_sub_login_session', { duration: 1.0});
        login_session = 0;
		[red]foo = 1;[/red]
        return false;
    }
}


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Thanks for your help.

I found the problem though, due to the script being pulled from another file, each animation was not being reset in the if statemnts

Ive dealt with the issue using timers, thanks guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top