关于使用smil动画和使用javascript/jquery更改内容,我有一些问题。
以下是我已经尝试过的:
HTML/XML:
<svg version="1.1" id="story_animation_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 400 500" enable-background="new 0 0 400 500" xml:space="preserve" style="background-color:#4B4542;">
<g id="story_1">
<path id="story_1_1" style="fill:none; stroke:#fff; stroke-width:2;" d="M200,100z">
<animate id="story_1_1_1"
attributeName="d"
from="M200,100l0,0" to="M200,100l0,380" dur="1s"
begin="0s;story_1_1_2.end"
end=""
/>
<animate id="story_1_1_2"
attributeName="d"
from="M200,100l0,380" to="M200,100l0,0" dur="1s"
begin="story_1_1_1.end"
end=""
/>
</path>
<path id="story_1_2" style="fill:none; stroke:#fff; stroke-width:2;" d="M200,500z">
<animate id="story_1_2_1"
attributeName="d"
from="M200,500l0,0" to="M200,500l0,-380" dur="1s"
begin="story_1_1_1.begin+1s;story_1_2_2.end"
end=""
/>
<animate id="story_1_2_2"
attributeName="d"
from="M200,500l0,-380" to="M200,500l0,0" dur="1s"
begin="story_1_2_1.end"
end=""
/>
</path>
<g/>
<g id="story_2">
<path id="story_2_1" style="fill:none; stroke:#fff; stroke-width:2; stroke-dasharray:795.8291015625,795.8291015625; stroke-dashoffset:795.8291015625;" d="M200,100l86,50l-172,100l172,100l-172,100l86,50">
<animate id="story_2_1_1"
attributeName="stroke-dashoffset"
from="795.8291015625" to="-795.8291015625" dur="2s"
begin=""
calcMode="spline"
keySplines=".28 .25 .265 .25"
keyTimes="0;1"
end=""
/>
<animate id="story_2_1_2"
attributeName="stroke-dashoffset"
from="795.8291015625" to="0" dur="1s"
begin=""
calcMode="spline"
keySplines=".28 .25 .265 .25"
keyTimes="0;1"
end=""
/>
</path>
<g/>
</svg> JS/jQuery:
在本例中,键按事件执行以下操作:
document.getElementById( 'story_1_1_1' ).attributes[ 5 ].value = '';
document.getElementById( 'story_1_1_1' ).attributes[ 6 ].value ='story_1_1_1.end';
document.getElementById( 'story_1_2_1' ).attributes[ 6 ].value ='story_1_2_1.end';
document.getElementById( 'story_2_1_1' ).attributes[ 5 ].value= 'story_1_1_2.end;story_2_1_1.end';佩服结果:
我想要做到:
实际结果:
到目前为止发生了什么:
对于如何做到这一点,我对不同的方法和/或想法持开放态度。至少在一开始,SMIL似乎是一种快速简便的方式,也是在移动环境下表现良好的方式,它的工作效果非常好。也许css3动画在这种情况下更好?
我怎么才能解决这个问题?
发布于 2015-08-28 16:16:38
这太难了.我在这里捣乱了
$(window).keypress(function(e) {//spacebar trigger
if (e.keyCode === 0 || e.keyCode === 32) {
$('#story_1_1_1, #story_1_1_2, #story_1_2_1, #story_1_2_2').attr('end', 'story_2_1_1.begin');
$('#story_2_1_1').attr('begin', '0s;story_2_1_2.end');
}
});https://stackoverflow.com/questions/28294933
复制相似问题