简体   繁体   English

将jQuery幻灯片效果转换为mootools

[英]Convert jquery slide effect to mootools

I have a script that slides a div down from behind the menu, when people click on the tab. 当人们单击选项卡时,我有一个脚本可以从菜单后面向下滑动div。 However its in jquery and I want to use mootools (lots of reasons I wont go into here). 然而,它在jQuery中,我想使用mootools(很多原因我不会在这里介绍)。 However im stuck with mootools 1.1 at present. 但是目前我还停留在mootools 1.1上。 But for some reason my attempt is not working :( 但是由于某种原因,我的尝试不起作用:(

The html HTML

print("code sample");
   <div id="panel">
    <form action="">
           < form here > 
    </form>
</div>
<div class="slide">
  <p class="sl"><a href="#" class="btn-slide" id="toggle"><span></span></a></p>

Div id panel holds the form which slides down, div class slide and the P tag is replaced by a tab/button which hangs down via css, clicking on this slides the tab down. Div id面板包含向下滑动的表单,div类幻灯片,并且P标签由通过CSS悬挂的选项卡/按钮替换,单击此按钮可使选项卡向下滑动。

The jquery (which works fine) jQuery(工作正常)

print("code sample");
  <script type="text/javascript">
  $j(document).ready(function(){
$j(".btn-slide").click(function(){
    $j("#panel").slideToggle("slow");
    $j(this).toggleClass("active"); return false;
});

  });
  </script>

My moo attempt 我的嘘声尝试

print("code sample");
 <script type="text/javascript">
window.addEvent('domready', function(){
 var mySlide = new Fx.Slide('panel');
    $('toggle').addEvent('click', function(e){
        e = new Event(e);
        mySlide.toggle();
        e.stop();
    });
});
 </script>

Like I said above I am restricted to moo 1.1 at present, but if there is a answer that will work with both 1.1 and 1.2 or if its a similar change I would be grateful to hear, as it will be updated at some point. 就像我在上面说的那样,我目前仅限于moo 1.1,但是如果有一个适用于1.1和1.2的答案,或者如果它具有类似的更改,我将不胜感激,因为它将在某个时候进行更新。

This should work both in 1.11 and 1.2: 这应该在1.11和1.2中都有效:

window.addEvent('domready', function() {
    var mySlide = new Fx.Slide('panel');
    $('toggle').addEvent('click', function(e) {
        e = new Event(e); // this isn't needed in 1.2
        e.stop();
        mySlide.toggle();
        this.toggleClass('active');
    });
});

However, in MooTools 1.2 and later, Fx.Slide isn't included in the core – you'll have to download it as a part of MooTools More . 但是,在MooTools 1.2和更高版本中,Fx.Slide不包含在核心中–您必须将其作为MooTools More的一部分进行下载。

A working demo: http://jsbin.com/ewasa 一个有效的演示: http : //jsbin.com/ewasa

Will this work? 这样行吗?

function toggleSlide(){
    var theSlider = new Fx.Slide('slide');
    $('theSlide').addEvent('click', function(e){
        e = new Event(e);
        theSlider.toggle();
        e.stop();
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM