2013-11-22 35 views
0

我最近一直在嘗試用Transit JS來縮略圖上的某些動畫。這不是必需的,我使用轉運js,這可能是一件好事,因爲我無法找到一種方法來破壞我的div上的動畫調用,如果我需要的話。銷燬對象上的轉運js

基本上我正在嘗試禁用移動設備的動畫,因爲移動設備上沒有懸停設備,所以沒有意義將其留在那裏。但通過文檔,我似乎無法找到停止該過程的方法。

我的代碼如下所示:

$(".spark_burst").css({ scale: 0 }); 

    $("a.trigger").bind('mouseenter play', function() { 
    $(this).find(".spark_burst").transition({ 
     opacity: 0.7, scale: 2, 
     duration: 400, 
     easing: 'in', 
     queue:false, 
     complete: function() { } 
     }); 
    $(this).find(".targeting").transition({ 
     y: 0, 
     x: 235, 
     easing: 'in', 
     queue:false, 
     duration: 200 
    }); 
    }).bind('mouseleave reset', function() { 
      console.log("hover out"); 
     $(this).find(".spark_burst").transition({ 
     opacity: 0, scale: 0, 
     duration: 400, 
     easing: 'out', 
     queue:false, 
     complete: function() { } 
     }); 
     $(this).find(".targeting").transition({ 
     y: 0, 
     x: 0, 
     easing: 'snap', 
     queue:false, 
     duration: 200 
     }); 
    }); 

我試圖拆散這樣的事件:

$(window).resize(function(){ 
    if ($("#all_spark").css("marginRight") == "0px"){ 

    console.log("0 pixels"); 
    $("a.trigger").unbind("mouseover mouseout play reset"); 

    } 
}); 

我的思維過程在這裏設置一個調整大小功能,以觀察當移動風格在父級上觸發,然後解除觸發器mouseovermouseout。但這是在黑暗中拍攝的,並且不起作用,所以我猜測這對我來說是純粹的垃圾。

任何想法?

回答

0

所以你綁定mouseentermouseleave事件觸發,

和取消綁定mouseovermouseout事件,但它不工作.....

....

BUT等待!!!他們是完全不同的事件!

mouseenter是不一樣的mouseover

mouseleave是不一樣的mouseout

unbind一個事件,你需要使用相同的事件名稱:)

在這個演示這個中轉JS測試:http://jsfiddle.net/JuKqK/

希望它能幫助。

+0

嗯,我忽略了我引用不同事件的事實,那會做伎倆。 – Doidgey