选中复选框时如何禁止`mouseenter`和`mouseleave`事件?

问题描述 投票:0回答:1

如何在复选框已选中禁止 mouseentermouseleave事件?

window.addEvent('domready',function() {
    var z = 2;
    var e = document.id('draggable');
    var drag = new Drag.Move(e, {
        grid: false,
        preventDefault: true,
        onStart: function() {
            e.setStyle('z-index',z++);
        }
    });
    //e.store('Drag', drag);

    var w = e.getStyle('width');
    var h = e.getStyle('height');
     e.set("morph", {duration:700,delay:400}).addEvents({
        mouseenter: function(){
            this.store("timer", (function() {
                this.morph({
                    width: '700px',
                    height: '500px',
                    opacity: [0.5, 1]
                });
            }).delay(1000, this));
        },
        mouseleave: function() {
           var pin = this.store("timerB", (function() { //probably there is some missateke
                this.morph({
                    width: w,
                    height: h,
                    opacity: [1, 0.5]
                });
            }).delay(1000, this));
            $clear(this.retrieve("timer"));
        }
    });

});

function check(elem) {
    var pin = document.id('draggable').retrieve('timerB');

    if(elem.checked) {
        pin.detach();
    }
    else {
        pin.attach();
    }
}
#draggable{
    background-color: grey;
    width: 300px;
    height: 200px;
    opacity: 0.5;
}​
​<input type="checkbox" onclick="check(this);">
<div id="draggable">Draggable DIV 1</div>

代码粘贴在http://jsfiddle.net/89RJp/4/

javascript mootools mouseover mouseleave mootools-events
1个回答
1
投票
http://jsfiddle.net/89RJp/6/

您想要if (element.get("checked")) return位于mouseenter / mouseleave回调的顶部。

© www.soinside.com 2019 - 2024. All rights reserved.