PDA

View Full Version : Omnislide Onclick Events for Sliding In and Out?



wpthebest
03-06-2007, 01:53 PM
Script Title: Omni Slide Menu

Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm

Hi,

First of all, great script! I am trying to get Omnislide to slide in and out with onclick events instead of mouseover & mouseout events. I found some code on the Dynamic-FX menu that jscheuer1 posted in order to make it possible with that menu:



var dFlag=0
function moveMenu(){
if (dFlag==0){
dFlag=1;
moveOut()
}
else{
dFlag=0;
moveBack()
}
}

function buildMenu() {
if (IE||NS6) {document.write('<DIV ID="basessm" style="visibility:hidden;Position : Absolute ;Left : '+XOffset+'px ;Top : '+YOffset+'px ;Z-Index : 20;width:'+(menuWidth+barWidth+10)+'px"><DIV ID="thessm" style="Position : Absolute ;Left : '+(-menuWidth)+'px ;Top : 0 ;Z-Index : 20;" onclick="moveMenu()" onclick="moveMenu()">')}

The above code worked great in the Dynamic-FX menu. It only opens and closes when it is clicked. I tried something similar to this code in the Omnislide's mmenu.js file around Line 278 where it has the following:

var tb='<div id="'+o.id+'" onmouseover="movein(this);" onmouseout="moveout(this);"><div><table>\n';
tb+=o.menupos=='right'? make_bar(o) : '';

It seems like I get ONE onclick event (i.e. onclick="movein(this)) to work which slides the menu out, but the second onclick event doesn't trigger and the menu is "stuck" open. Even when I create a function with if statements like the Dynamic-Fx example above. Thanks so much in advance for your help!

jscheuer1
03-06-2007, 02:21 PM
You would have to do a similar thing to what was done with the other code. That is add a function:


function MoveMenu(obj){
if(!obj.dFlag){
movein(obj);
obj.dFlag=1;
}
else {
moveout(obj);
obj.dFlag=0;
}
}

Then you could change it to:


var tb='<div id="'+o.id+'" onclick="MoveMenu(this);"><div><table>\n';
tb+=o.menupos=='right'? make_bar(o) : '';

Untested.

wpthebest
03-06-2007, 03:03 PM
John,

I racked my brain all lastnite trying to get this to work when I probably should have written you sooner! I guess I try so hard to figure things out first, before bugging anyone else. Anyway, works like a charm now! I can't thank you enough. I've read many of your posts on here and you are like a javascript God in my book! Thanks again!