Should event and accessKey timing respect preventDefault?

(Cross-posting to www-smil and www-svg since although this is a SMIL
issue it is probably recently of more concern to SVG implementers and
authors.)

Dear all,

SMIL as incorporated in SVG allows for animations to be keyed off
various DOM events such as mouse clicks (event timing) as well as
keyboard inputs (accessKey timing).

One area that would benefit from clarification is whether animations
should be triggered when preventDefault is called on the event in
question (and presuming that event is cancelable).

Generally preventDefault cancels the default action associated with an event.[1]

Certainly, triggering an animation feels like a default action yet my
testing with Opera 10.61, Batik 1.7, Safari 5.0.1 (recent WebKit
nightlies fail to run for me but as of about one month ago, late June,
the result was the same) suggests preventDefault is ignored with
regard to triggering animations to begin or end.

Specifically with the following test case the animation plays when
either the circle is clicked or 'a' is pressed (except in WebKit
browsers which don't seem to support accessKey) despite the fact that
preventDefault is called:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
  <script type="application/ecmascript">
    function cancel(event) {
      if (typeof event.charCode == 'undefined'
          ? event.keyCode == 97 : event.charCode == 97) {
        event.preventDefault();
      }
    }
    document.addEventListener("keypress", cancel, true);
  </script>
  <circle id="circle" r="25" cx="50" cy="50" fill="brown"
    onclick="evt.preventDefault()">
    <animate begin="circle.click; accessKey(a)"
      attributeName="cx" from="50" to="150" dur="1s"/>
  </circle>
</svg>

I think it would be sensible to define the behaviour for SMIL
Animation so that cancelled events are ignored.

Best regards,

Brian Birtles

[1] http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-cancelation-h3

Received on Friday, 27 August 2010 02:38:04 UTC