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,19 +3685,35 @@ function BatchCommand(text) {
} else if (element != null) { } else if (element != null) {
canvas.addedNew = true; canvas.addedNew = true;
element.setAttribute("opacity", cur_shape.opacity); var ani_dur = .2, c_ani;
element.setAttribute("style", "pointer-events:inherit"); if(opac_ani.beginElement && element.getAttribute('opacity') != cur_shape.opacity) {
cleanupElement(element); c_ani = $(opac_ani).clone().attr({
if(current_mode == "path") { to: cur_shape.opacity,
pathActions.toEditMode(element); dur: ani_dur
} else if (current_mode == "text" || current_mode == "image" || current_mode == "foreignObject") { }).appendTo(element);
// keep us in the tool we were in unless it was a text or image element c_ani[0].beginElement();
canvas.addToSelection([element], true); } else {
ani_dur = 0;
} }
// we create the insert command that is stored on the stack
// undo means to call cmd.unapply(), redo means to call cmd.apply() // Ideally this would be done on the endEvent of the animation,
addCommandToHistory(new InsertElementCommand(element)); // but that doesn't seem to be supported in Webkit
call("changed",[element]); setTimeout(function() {
if(c_ani) c_ani.remove();
element.setAttribute("opacity", cur_shape.opacity);
element.setAttribute("style", "pointer-events:inherit");
cleanupElement(element);
if(current_mode == "path") {
pathActions.toEditMode(element);
} else if (current_mode == "text" || current_mode == "image" || current_mode == "foreignObject") {
// keep us in the tool we were in unless it was a text or image element
canvas.addToSelection([element], true);
}
// we create the insert command that is stored on the stack
// undo means to call cmd.unapply(), redo means to call cmd.apply()
addCommandToHistory(new InsertElementCommand(element));
call("changed",[element]);
}, ani_dur * 1000);
} }
start_transform = null; start_transform = null;