.invalidate()

刷新任何内部记录的开始/结束值,如果您想要重新启动动画而不恢复到以前记录的任何起始值,这将非常有用。
.invalidate()适用于TweenMaxTweenLite

.invalidate()效果展示

  • HTML
  • CSS
  • JS
  • 展示


body {
  background-color:#1d1d1d;
  font-family: Signika Negative, sans-serif;
  color:#989898;
  margin:0px;
  font-size:18px;
}

h1, h2, h3 {
  font-family: "Signika Negative", sans-serif;
  margin: 10px 0 10px 0;
  color:#f3f2ef;
  font-weight: 400;
}

h1 { 
  font-size:42px;
}

h2 {
  font-size:24px;
}

h3 {
  font-size:22px;
}

p{
  line-height:22px;
  margin-bottom:16px;  
}

a {
  color: #88ce02;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

#demo {
  height:100%;
  position:relative;
}
.box {
  width:50px;
  height:50px;
  position:relative;
  border-radius:6px;
  margin-top:4px;
  display:inline-block;
  line-height:50px;
  text-align:center;
  color:#333;
  
}

.green{
  background-color:#6fb936;
}

.orange {
  background-color:#f38630;
}
.grey {
  background-color:#989898;
}

button {
  display:inline-block;
  outline: none;
  border: none;
  padding: 8px 14px;
  background: #414141;
  background-image: -webkit-linear-gradient(top, #575757, #414141);
  background-image: -moz-linear-gradient(top, #575757, #414141);
  background-image: -ms-linear-gradient(top, #575757, #414141);
  background-image: -o-linear-gradient(top, #575757, #414141);
  background-image: linear-gradient(to bottom, #575757, #414141);
  text-shadow: 0px 1px 0px #414141;
  -webkit-box-shadow: 0px 1px 0px 414141;
  -moz-box-shadow: 0px 1px 0px 414141;
  box-shadow: 0px 1px 0px 414141;
  color: #ffffff;
  text-decoration: none;
  margin: 0 auto;
  -webkit-border-radius: 4;
  -moz-border-radius: 4;
  border-radius: 4px;
  padding: 12px 25px;
  font-family: "Signika Negative", sans-serif;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  line-height: 18px;
}

button:hover {
  background: #57a818;
  background-image: -webkit-linear-gradient(top, #57a818, #4d9916);
  background-image: -moz-linear-gradient(top, #57a818, #4d9916);
  background-image: -ms-linear-gradient(top, #57a818, #4d9916);
  background-image: -o-linear-gradient(top, #57a818, #4d9916);
  background-image: linear-gradient(to bottom, #57a818, #4d9916);
  text-shadow: 0px 1px 0px #32610e;
  -webkit-box-shadow: 0px 1px 0px fefefe;
  -moz-box-shadow: 0px 1px 0px fefefe;
  box-shadow: 0px 1px 0px fefefe;
  color: #ffffff;
  text-decoration: none;
}

.brandBar {
  position:absolute;
  width:100%;
  height:40px;
  
  z-index:1000;
  line-height:40px;
  color:#ccc;
  padding-left:0px;
}

.nav{
  margin:20px 0;
}

.brandBar img{
  position:absolute;
  width:90px;
  right:20px;
  top:12px;
}

.wrapper {
  position:absolute;
  padding:20px;
}
body {
  margin:10px;
}

button {
  display:inline;
}
var t = TweenLite.to(".green", 1, {x:"+=100"});

$("#restart").click(function(){
  t.restart();
})

$("#invalidate").click(function(){
  t.invalidate();
  t.restart();
})
重播

转载原创文章请注明:文章转载自:TweenMax中文网 [https://www.tweenmax.com.cn]
本文地址:https://www.tweenmax.com.cn/api/tweenmax/invalidate()