W3C home > Mailing lists > Public > www-svg@w3.org > November 2007

Mousedriven hover-animations in SVG/SMIL-animation

From: Erik Dahlström <ed@opera.com>
Date: Mon, 05 Nov 2007 23:49:00 +0100
To: www-smil@w3.org
Cc: "www-svg@w3.org" <www-svg@w3.org>
Message-ID: <op.t1ccbyv6gqiacl@gnorps.palace.opera.no>

Hello www-smil!

Try the included example in for example Opera 9.5  
(http://my.opera.com/desktopteam), or another viewer that supports  
declarative animations (like Batik 1.7 for example).

I'd be happy to hear if it's possible to do something like this:

   desired behavior:
      Mousing over either of the rects have it fade in (the fade should  
last 0.25s or until the mouse leaves).
      At the point the mouse leaves one of the rects it should fade back to  
opacity=0.5
      (the fade should last 0.25s or until the mouse enters).

   If there was a way to reference the current animated value something  
like this might solve the problem:
      <animate attrbuteName="opacity" from="animation-snapshot-value"  
to="1" begin="mouseover" end="mouseout" dur="0.25s"/>
      <animate attrbuteName="opacity" from="animation-snapshot-value"  
to="0.5" begin="mouseout" end="mouseover" dur="0.25s"/>

      The problem with the below experiment is that the out[12] animations  
trigger after 0.25s.
      And the in[12] animations need a duration because the animation  
should play for 0.25s and then freeze.

Example:

<svg xmlns="http://www.w3.org/2000/svg">

   <rect width="100" height="100" fill="blue" opacity="0.5">
     <animate id="in1" attributeName="opacity" begin="mouseover"  
end="mouseout" dur="0.25s" to="1" fill="freeze"/>
     <animate id="out1" attributeName="opacity" begin="in1.endEvent"  
to="0.5" dur="0.25s"/>
   </rect>
   <rect width="100" height="100" fill="green" x="110" opacity="0.5">
     <animate id="in2" attributeName="opacity" begin="mouseover"  
end="mouseout" dur="0.25s" to="1" fill="freeze"/>
     <animate id="out2" attributeName="opacity" begin="in2.endEvent"  
to="0.5" dur="0.25s"/>
   </rect>
</svg>

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Received on Monday, 5 November 2007 22:49:17 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:38 GMT