Can someone Explain this jQuery code?

前端 未结 3 771
悲哀的现实
悲哀的现实 2021-01-25 06:13

This code is taken from http://wilq32.googlepages.com/wilq32.rollimage222, and is supposed to animate an image rotation.

I can\'t figure out the structure exactly, and h

3条回答
  •  天涯浪人
    2021-01-25 06:49

    Here's what it does. 1) Waits for page load $(document).ready() 2) Assigns "rot" to equal a jQuery.rotate object. 3) This object is then bound to two different events, mouseover, and mouseout. Binding means that when those events trigger that piece of code will execute.

    Mouseover starts "rotateAnimation(85)" and mouseout sets the same function -35. I'm guessing that it reverses the rotation of the image it's looking at.

    To add things to the rotation, you could just do this.

    $(document).ready(function()
        {
                var rot=$('#image3').rotate({maxAngle:25,minAngle:-55,
                bind:
                        [
                                {"mouseover":function(){
                                     rot[0].rotateAnimation(85);}
                                     //insert awesome fades and effects here.
                                },
                                {"mouseout":function(){
                                     rot[0].rotateAnimation(-35);}
                                     // insert more cool fades and effects here.
                                }
                        ]
                });
        });
    

    Hope that helps.

提交回复
热议问题