如何正确控制css3动画速度

时间:2017-06-11 17:47:20

标签: css3 animation

我借了一个css3“工作旋转”动画,其中给定的“工作每3秒旋转一次”。 我试图通过操纵css动画延迟值来加速它达到1.5秒,但我最终会用那些互相破坏的词来结束,而不是替换。

这是css:

class Database {
static let si = Database() // when removed it also resolves into an error

init() {
    print("Hello") // isn't printed.
    self.setONs() // see code below to see where collected gets a new value
    print("current device id: \(UIDevice.current.identifierForVendor!.uuidString)") // resolves into an error when declared as uuid which is now "TestUID"
}

var uuid: String = "TestUID" // its actual the device id.
var gkid: String = "" // GKPlayerID
var collected: [String : [String : Int]] = [:] // <- Thread 1: EXC_BAD_ACCESS(code=2,address=0x7fff59de4f8)
private var collectedProgress: [String : [String : Int]] = [:]

这是我目前的小提琴:

https://jsfiddle.net/eugene_goldberg/2y81qLd6/

如何正确调整这些设置,使旋转需要1.5秒而不是完整3?

1 个答案:

答案 0 :(得分:1)

将主要持续时间和所有延迟改为一半。

.words-1 span{
    position: absolute;
    margin-top: 10px;
    opacity: 0;
    overflow: hidden;
    color: #6b969d;
    -webkit-animation: rotateWord 9s linear infinite 0s;
    -moz-animation: rotateWord 9s linear infinite 0s;
    -o-animation: rotateWord 9s linear infinite 0s;
    -ms-animation: rotateWord 9s linear infinite 0s;
    animation: rotateWord 9s linear infinite 0s;
}
.words-1 span:nth-child(2) {
    -webkit-animation-delay: 1.5s;
    -moz-animation-delay: 1.5s;
    -o-animation-delay: 1.5s;
    -ms-animation-delay: 1.5s;
    animation-delay: 1.5s;
    color: #6b889d;
}
.words-1 span:nth-child(3) {
    -webkit-animation-delay: 3s;
    -moz-animation-delay: 3s;
    -o-animation-delay: 3s;
    -ms-animation-delay: 3s;
    animation-delay: 3s;
    color: #6b739d;
}
.words-1 span:nth-child(4) {
    -webkit-animation-delay: 4.5s;
    -moz-animation-delay: 4.5s;
    -o-animation-delay: 4.5s;
    -ms-animation-delay: 4.5s;
    animation-delay: 4.5s;
    color: #7a6b9d;
}
.words-1 span:nth-child(5) {
    -webkit-animation-delay: 6s;
    -moz-animation-delay: 6s;
    -o-animation-delay: 6s;
    -ms-animation-delay: 6s;
    animation-delay: 6s;
    color: #8d6b9d;
}
.words-1 span:nth-child(6) {
    -webkit-animation-delay: 7.5s;
    -moz-animation-delay: 7.5s;
    -o-animation-delay: 7.5s;
    -ms-animation-delay: 7.5s;
    animation-delay: 7.5s;
    color: #9b6b9d;
}

https://jsfiddle.net/gaby/2y81qLd6/1/

更新了演示