Loading ...
Sorry, an error occurred while loading the content.

toggling

Expand Messages
  • tomjnsn
    I am wondering if there is a best practice for toggling using the Anim stuff? Should I create an object for both directions? Register a subscriber for the
    Message 1 of 4 , May 1, 2006
    • 0 Attachment
      I am wondering if there is a best practice for toggling using the Anim
      stuff? Should I create an object for both directions? Register a
      subscriber for the onComplete event that essentially swaps the to and
      from vals?

      Just for clarification: when I say toggling I mean having the ability
      to call a method that will go in both directions like highlighting
      something when it is clicked on, but then removing the highlight when
      it is clicked on again.

      Thanks,

      Tom
    • Matt Sweeney
      Hi Tom, It really depends on your use case. Sometimes its easier to use seperate animation instances for either direction. However, when you have a large
      Message 2 of 4 , May 1, 2006
      • 0 Attachment
        Hi Tom,

        It really depends on your use case. Sometimes its easier to use
        seperate animation instances for either direction.

        However, when you have a large number of potential animations, its
        probably better to try and keep this to a single instance, and set the
        attributes dynamically before calling animate().

        Matt

        tomjnsn wrote:

        >I am wondering if there is a best practice for toggling using the Anim
        >stuff? Should I create an object for both directions? Register a
        >subscriber for the onComplete event that essentially swaps the to and
        >from vals?
        >
        >Just for clarification: when I say toggling I mean having the ability
        >to call a method that will go in both directions like highlighting
        >something when it is clicked on, but then removing the highlight when
        >it is clicked on again.
        >
        >Thanks,
        >
        >Tom
        >
        >
        >
        >
        >
        >
        >Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
      • Tom Jensen
        Thanks Matt for responding. I was thinking along those lines, but I guess I was wondering at a lower level, should I be creating multiple Anim objects, one
        Message 3 of 4 , May 1, 2006
        • 0 Attachment
          Thanks Matt for responding. I was thinking along
          those lines, but I guess I was wondering at a lower
          level, should I be creating multiple Anim objects, one
          for the highlight and one for the unhighlight, or just
          use the same one and reset the to: and from:
          attributes depending on the state property. Does that
          make sense?

          Thanks,

          Tom

          --- "Gatten, Matt" <Matt.Gatten@...> wrote:

          > Why not just create one object that contains an off
          > and on state property and just do the opposite of
          > whatever it is? Give it a 'toggle' method that does
          > it. That's how I do it.
          >
          > Matt I
          > -----Original Message-----
          > From: "tomjnsn" <tomjnsn@yah
          > oo.com>
          > Sent: 5/1/06 2:39:51 PM
          > To: "ydn-javascript@yahoogroups.com"
          > <ydn-javaryahoor SuI -bject: -n-javascript]
          > toggling
          >
          > I am wondering if there is a best practice for
          > toggling using the Anim
          > stuff? Should I create an object for both
          > directions? Register a
          > subscriber for the onComplete event that
          > essentially swaps the to and
          > from vals?
          >
          > Just for clarification: when I say toggling I
          > mean having the ability
          > to call a method that will go in both directions
          > like highlighting
          > something when it is clicked on, but then
          > removing the highlight when
          > it is clicked on again.
          >
          > Thanks,
          >
          > Tom
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          > http://groups.yahoo.com/group/ydn-javascript/
          >
          > ydn-javascript-unsubscribe@yahoogroups.com
          >
          >
          >
          >
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com
        • Gatten, Matt
          Hi Tom, Yeah, I understand what you want to do. I would make two methods in the object. One is the animation from state 1 to state 2. Then the second method
          Message 4 of 4 , May 1, 2006
          • 0 Attachment
            Hi Tom,

            Yeah, I understand what you want to do. I would make two methods in the
            object. One is the animation from state 1 to state 2. Then the second
            method to animate from state 2 back to state 1.

            Somewhere in the object. Name a property 'toggle' or 'toggled' and
            maybe it holds a value of yes/no, true/false, 1/0.

            Make a listener for the element for 'click' or 'dblclick'. Switch
            statement in the object reads 'this.toggled' to see if it's 'on/off' and
            have a simple case statement to handle the toggling.

            Switch(this.toggled){
            Case 'on': //animate to the off state

            Case 'off': //animate to the on state

            }

            Hope that helps. :) I love this stuff but stay mainly quiet. Looks
            like lots of foreign folks on there wanting someone to write code for
            them. haha

            Give me a yell some time. I'm always working on something.

            Matt Gatten
            Software Engineer - Request Systems
            314-512-4083

            -----Original Message-----
            From: Tom Jensen [mailto:tomjnsn@...]
            Sent: Monday, May 01, 2006 4:36 PM
            To: ydn-javascript@yahoogroups.com
            Cc: Gatten, Matt
            Subject: RE: [ydn-javascript] toggling

            Thanks Matt for responding. I was thinking along those lines, but I
            guess I was wondering at a lower level, should I be creating multiple
            Anim objects, one for the highlight and one for the unhighlight, or just
            use the same one and reset the to: and from:
            attributes depending on the state property. Does that make sense?

            Thanks,

            Tom

            --- "Gatten, Matt" <Matt.Gatten@...> wrote:

            > Why not just create one object that contains an off and on state
            > property and just do the opposite of whatever it is? Give it a
            > 'toggle' method that does it. That's how I do it.
            >
            > Matt I
            > -----Original Message-----
            > From: "tomjnsn" <tomjnsn@yah
            > oo.com>
            > Sent: 5/1/06 2:39:51 PM
            > To: "ydn-javascript@yahoogroups.com"
            > <ydn-javaryahoor SuI -bject: -n-javascript]
            > toggling
            >
            > I am wondering if there is a best practice for toggling using the
            > Anim
            > stuff? Should I create an object for both directions? Register a
            > subscriber for the onComplete event that essentially swaps the to
            > and
            > from vals?
            >
            > Just for clarification: when I say toggling I mean having the
            > ability
            > to call a method that will go in both directions like highlighting
            > something when it is clicked on, but then removing the highlight
            > when
            > it is clicked on again.
            >
            > Thanks,
            >
            > Tom
            >
            >
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            > http://groups.yahoo.com/group/ydn-javascript/
            >
            >
            >
            >
            >
            >
            >


            __________________________________________________
            Do You Yahoo!?
            Tired of spam? Yahoo! Mail has the best spam protection around
            http://mail.yahoo.com
          Your message has been successfully submitted and would be delivered to recipients shortly.