TechTalks from Nitin

September 8, 2007

Moo.fx: Guide to use it with prototype (part 2)

Filed under: Uncategorized — TheOne @ 4:17 pm

Continuing with me last blog about accordion, here is another code example to use moo.fx V2.0 for changing style.

So lets start……

Just see the following lines of code to change left style property of any DOM element.

var leftdec = new Fx.Style(“panel2″,”left”,{duration:1000});
var d = $(‘panel2′);
leftdec.custom(parseInt(d.style.left), (parseInt(d.style.left) – 105));

Here Fx.Style(“panel2″,”left”,{duration:1000}); is everything. “panel2″ is the id of the DOM element. “left” is the property, and last argument of the constructor is optional properties.

Now it is the last line to change the “left” property. All we have to do is:

leftdec.custom(parseInt(d.style.left), (parseInt(d.style.left) – 105));

Here leftdec is the object we created.

custom is the function which requires two arguments, first is the property “FROM” and second is property “TO”. In this particular example i wanted to change left property current-105 so what is did is (parseInt(d.style.left) – 105).

Isn’t it really easy.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.