【问题标题】:Meteor Interaction with JQuery or Animation in General流星与 JQuery 或动画的一般交互
【发布时间】:2016-05-05 05:00:16
【问题描述】:

所以基本上,我正在 Meteor 中构建一个应用程序,我在 position: fixed;left : -300px 中有左侧导航栏,想将其滑到 left : 300px,但不知道如何为Meteor 中的过渡(有点像 jquery 中的幻灯片过渡)。我了解事物的基本 JQuery 方面,但由于某种原因,当我将它放在脚本的 if Meteor.isClient 方面时,它似乎不起作用。请记住,我对 Meteor 还很陌生,非常感谢包含 JavaScript 代码。

我目前的代码如下。

HTML

<body>
    <div class='topmenu'>
        <div class='menubutton'>
            <span class="icon-bar1"></span>
            <span class="icon-bar2"></span>
            <span class="icon-bar3"></span>
            <!--Needs to be fixed so that we only need to use one icon-bar class!!!-->
        </div>
        <div class='BanditDiv'>
            <h1 class='BanditName'>Bandit</h1>
        </div>
    </div>
    <div class='leftnav'>
        <div class='sitenav'>
            <a class='internalnav' href="#">Home</a>
            <a class='internalnav' href="#">Musicians</a>
            <a class='internalnav' href="#">Recording Space</a>
        </div>
    </div>
    <div class='main'>
    </div>
</body>

CSS

body{
    margin: 0px 0px 0px 0px;    
}

.navitem:hover{
    background-color: #000066;
}

.main{
    background-color: rgb(128,128,128);
    height: 200vh;
    width: 100vw;
    margin: 0px 0px 0px 0px;
    overflow-x:hidden;
}

.topmenu{
    position: fixed;
    z-index: 10;
    top: 0px;
    width: 100vw;
    height: 50px;
    background: white;
    border-bottom: 2px lightgray solid;
}

.BanditDiv{
    position: fixed;
    top: 0px;
    height: 50px;
    width: 30vw;
    margin-left: 35vw;
    float: center;
}

.BanditName{
    text-align: center;
    font: 400 25px/1.3 'Berkshire Swash', Helvetica, sans-serif;
    color: #000066;
}

.menubutton{
    position: fixed;
    top: 5px;
    left: 5px;
    height: 40px;
    width: 40px;
    border: 1px #cccccc solid;
    background-color: white;
    border-radius: 5px;
}

.menubutton:focus{
    outline: 0;
}

.icon-bar1 {
    position: fixed;
    top: 15px;
    left: 10px;
    margin: 0px 0px 0px 0px;
    display: block;
    width: 30px;
    height: 2px;
    background-color: #cccccc;
    border-radius: 1px;
}

.icon-bar2 {
    position: fixed;
    top: 25px;
    left: 10px;
    margin: 0px 0px 0px 0px;
    display: block;
    width: 30px;
    height: 2px;
    background-color: #cccccc;
    border-radius: 1px;
}

.icon-bar3 {
    position: fixed;
    top: 35px;
    left: 10px;
    margin: 0px 0px 0px 0px;
    display: block;
    width: 30px;
    height: 2px;
    background-color: #cccccc;
    border-radius: 1px;
}

.leftnav{
    position: fixed;
    top: 0px;
    left: -300px;
    width: 300px;
    height: 100vh;
    z-index: 9001;
    background-color: yellow;
}

【问题讨论】:

  • 你的 JS 目前是什么样子的,你的代码目前表现如何?
  • 我真的让它工作了!看起来这是因为我缺乏使用角度或模板。不过感谢您的关注!
  • 如果你让它工作,请发布你自己的答案。你的问题得到了赞成,很明显人们对这个话题很好奇。

标签: javascript jquery html css meteor


【解决方案1】:

所以这就是我想出的似乎可行的解决方案。 我在 Meteor.isClient 中创建了一个 Angular 模块,它似乎运行良好。

if (Meteor.isClient) { 
  angular.module('sidebar',['angular-meteor']);

  angular.module('sidebar').controller('SidebarCtrl', ['$scope',
    function ($scope) {
      function Menu (callback){
        $('.menubutton').on('click', function (){
          $('.leftnav').css({"box-shadow" : "2px 2px 2px #888888"});
          $('.leftnav').animate({left : "0px"}, 500, function(){
            $('.main').click(function() {
              $('.leftnav').animate({left: "-302px"}, 500);
              $('.leftnav').css({"box-shadow" : "none"});
            });
            $('.leftnav').click(function(event){
              event.stopPropagation();
            }); 
          });
        });    
      }
      Menu();
  }]);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-26
    • 2018-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    相关资源
    最近更新 更多