Added fade-in SMIL animation when creating most elements in SMIL-enabled browsers

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1451 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-03-10 15:07:28 +00:00
parent 5c02c98a3f
commit 57da0c02f3
1 changed files with 36 additions and 12 deletions

View File

@ -943,6 +943,14 @@ function BatchCommand(text) {
$(svgroot).appendTo(container); $(svgroot).appendTo(container);
var opac_ani = document.createElementNS(svgns, 'animate');
$(opac_ani).attr({
attributeName: 'opacity',
begin: 'indefinite',
dur: 1,
fill: 'freeze'
}).appendTo(svgroot);
//nonce to uniquify id's //nonce to uniquify id's
var nonce = Math.floor(Math.random()*100001); var nonce = Math.floor(Math.random()*100001);
var randomize_ids = false; var randomize_ids = false;
@ -3677,6 +3685,21 @@ function BatchCommand(text) {
} else if (element != null) { } else if (element != null) {
canvas.addedNew = true; canvas.addedNew = true;
var ani_dur = .2, c_ani;
if(opac_ani.beginElement && element.getAttribute('opacity') != cur_shape.opacity) {
c_ani = $(opac_ani).clone().attr({
to: cur_shape.opacity,
dur: ani_dur
}).appendTo(element);
c_ani[0].beginElement();
} else {
ani_dur = 0;
}
// Ideally this would be done on the endEvent of the animation,
// but that doesn't seem to be supported in Webkit
setTimeout(function() {
if(c_ani) c_ani.remove();
element.setAttribute("opacity", cur_shape.opacity); element.setAttribute("opacity", cur_shape.opacity);
element.setAttribute("style", "pointer-events:inherit"); element.setAttribute("style", "pointer-events:inherit");
cleanupElement(element); cleanupElement(element);
@ -3690,6 +3713,7 @@ function BatchCommand(text) {
// undo means to call cmd.unapply(), redo means to call cmd.apply() // undo means to call cmd.unapply(), redo means to call cmd.apply()
addCommandToHistory(new InsertElementCommand(element)); addCommandToHistory(new InsertElementCommand(element));
call("changed",[element]); call("changed",[element]);
}, ani_dur * 1000);
} }
start_transform = null; start_transform = null;