javascript – Meteor与JQuery或动画的交互

前端之家收集整理的这篇文章主要介绍了javascript – Meteor与JQuery或动画的交互前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

所以基本上,我正在Meteor中构建一个应用程序,我将左侧导航栏放在一个位置:固定;并离开:-300px并希望将其向左滑动:300px,但不知道如何在Meteor中设置转换动画(有点像jquery中的幻灯片转换).我理解事物的基本JQuery方面,但由于某种原因,当我把它放在脚本的if Meteor.isClient方面时它似乎不起作用.请记住,我对Meteor相当新,包容性的javascript代码将非常感激.

我目前的代码如下.

HTML

@H_404_9@

CSS

@H_404_9@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; }
最佳答案
所以这就是我想出的解决方案似乎有效的方法.
我在Meteor.isClient中创建了一个角度模块,似乎运行良好.

@H_404_9@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(); }]); }

猜你在找的jQuery相关文章