【发布时间】:2015-04-27 13:51:07
【问题描述】:
我正在使用 SVG 制作一些按钮动画,但无法使其完全按照我的意愿工作。我尝试找到相同的案例,但没有运气。所以我最终到了这里,因为我已经在这上面花费了太多时间。任何帮助将非常感激。 这是代码:http://jsfiddle.net/wq4djg9z/2/ 它工作正常,但有一个缺陷。它总是从固定值开始动画。
#button-border {
stroke-dasharray: 150;
stroke-dashoffset: 150;
stroke-width: 4px;
-webkit-animation: dash-back 1.0s linear;
fill: none;
pointer-events: all;
}
#button-border:hover {
-webkit-animation: dash 1.0s linear forwards;
pointer-events: all;
}
@-webkit-keyframes dash {
to {
stroke-dashoffset: 0;
}
}
@-webkit-keyframes dash-back {
from {
stroke-dashoffset: 0;
}
to {
stroke-dashoffset: 150;
}
}
当鼠标移出按钮以平滑动画时,有没有办法从当前动画帧开始动画?
【问题讨论】: