首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Velocity.js动画延迟

Velocity.js动画延迟
EN

Stack Overflow用户
提问于 2017-02-03 01:47:52
回答 2查看 1.4K关注 0票数 0

我有点沮丧,因为velocity js在我的代码中表现得很奇怪。

如果我没有指定任何延迟时间,这些动画如何按顺序进行?在读完Velocity文档后,我认为这应该是模拟动画。但这是类似于:身体动画,菜单动画。它甚至不是代码中的序列。有人能告诉我原因吗?

代码语言:javascript
复制
$('#pr-nav-icon').click(function() {
    $('#hamburger-menu-drop').velocity({marginLeft: "0px"}, {
        duration: 300,
        delay: 0,
        easing: 'easeInOutQuart'
    });
    $('body').velocity({marginLeft: "440px"}, {
        duration: 300,
        delay: 0,
        easing: 'easeInOutQuart'
    });
});

以下是我对这些元素的看法,如果它可能是原因的话:

代码语言:javascript
复制
#hamburger-menu-drop {
  max-width: 420px;
  background: white;
  position: fixed;
  right: 0px;
  bottom: 0px;
  left: 0px;
  top: 0px;
  z-index: 9999;
  background-color: $darktext;
  overflow-y: auto;
  box-shadow: inset -10px 0 5px -5px hsla(0, 0%, 0%, 0.25);
  margin-left: -420px;
}

body {
  width: 100%;
  height: 100%;
  background: #fff;
  line-height: 1.55;
  font-family: $titlefont;
  -webkit-font-smoothing: antialiased;
  font-weight: 300;
  margin: 0;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  color: $darktext;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  min-height: 100vh;
  font-smooth: auto;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  overflow-x: hidden;
  font-size: 1.8rem;
  line-height: 1.25;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-19 19:27:20

我发现问题出在哪里,这真的是我的一个愚蠢的错误。当然,正如托马斯所指出的那样,velocity.js工作正常。问题是,我试图使身体中的菜单和身体本身具有动画效果,所以动画效果消失了。

票数 0
EN

Stack Overflow用户

发布于 2017-02-03 02:59:06

你的持续时间是"300“动画的‘身体’和‘汉堡包-菜单-下降’,你会注意到,如果你设置的持续时间为5秒和‘汉堡-菜单-下降’为.3秒,你会看到一个发生在另一个。我已经将主体的背景更改为黄色,这样您将能够直观地看到发生的更改。

代码语言:javascript
复制
$('#pr-nav-icon').click(function() {
  $('#hamburger-menu-drop').velocity({
    marginLeft: "0px"
  }, {
    duration: 300,
    delay: 0,
    easing: 'easeInOutQuart'
  });
  
    $('body').velocity({
    backgroundColor: "#ffcc3a"
  }, {
    duration: 5000,
    delay: 0,
    easing: 'easeInOutQuart'
  });
});
代码语言:javascript
复制
button {
  width: 15%;
}
#hamburger-menu-drop {
  max-width: 420px;
  background: white;
  position: fixed;
  right: 0px;
  bottom: 0px;
  left: 0px;
  top: 0px;
  z-index: 9999;
  background-color: $darktext;
  overflow-y: auto;
  box-shadow: inset -10px 0 5px -5px hsla(0, 0%, 0%, 0.25);
  margin-left: -420px;
}
body {
  width: 100%;
  height: 100%;
  background: #fff;
  line-height: 1.55;
  font-family: $titlefont;
  -webkit-font-smoothing: antialiased;
  font-weight: 300;
  margin: 0;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  color: $darktext;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  min-height: 100vh;
  font-smooth: auto;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  overflow-x: hidden;
  font-size: 1.8rem;
  line-height: 1.25;
}
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.4.2/velocity.min.js"></script>

<button id="pr-nav-icon">CLICK ME</button>
<div id="hamburger-menu-drop">HAMBURGER</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42008994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档