2012-11-21 57 views
7

即時搜索與jQuery版本一起出來的解決方案,Drupal本身包含了這個解決方案。它的舊版本。實際上沒有任何問題 - 但一個:D我使用一個隊列爲false的.animate()函數,並且沒有這個屬性(因爲這個屬性是jquery 1.7中的.animate()的),所以它不是我想要的動畫。.animate() - 舊版jquery Verions(Drupal)的隊列模擬衝突

的代碼是:

//When mouse rolls over 
$("#login").bind('mouseover mouseenter',function(){ 
$("#logo").stop().delay(500).animate({top:'-44px'},{queue:false, duration:600, easing: 'swing'}) 

$("#login").stop().animate({top:'89px'},{queue:false, duration:600, easing: 'easeOutBounce'}) 
}); 

//When mouse is removed 
$("#login").bind('mouseout mouseleave',function(){ 
$("#logo").stop().animate({top:'6px'},{queue:false, duration:600, easing: 'easeOutBounce'}) 

$("#login").stop().animate({top:'40px'},{queue:false, duration:600, easing: 'swing'}) 
}); 

也許你能幫我想想辦法?問題,爲什麼我想排除我用於這個(1.8.3)的jquery版本是一個Drupal模塊沒有顯示wysiwyg(CKEditor),當jquery 1.8.3包括另外,很遺憾我不能替換jquery核心的版本使用jQuery 1.8.3 :(

+1

你見過[jQuery Multi](http://drupal.org/project/jqmulti)嗎?它可以讓你加載不同的jQuery版本到同一個頁面,沒有衝突 – Clive

回答

2

我一直通過普通的老香草JS做到了這一點,可以通過簡單的射擊延遲/超時事件這對抗隊列問題

Check this out on JsFiddle.

<style type="text/css"> 
.redBlock{ 
    height:2em; 
    background-color:red; 
    color:white; 
    border:2px solid silver; 
}​ 
</style> 
<input type="button" id="testFoo" value="click me a bunch of times super fast" /> 
<div id="testBar" style="width:100px;" class="redBlock"> Red Block </div>​ 
<script type="text/javascript"> 
    $(document).ready(function(){ 
     $("#testFoo").click(function(){ 
      fireOneAnimateEvent(); 
     }); 
    }); 
    function animateRedBlock() { 
     $("#testBar").css('width', '100px') 
      .animate({ 
       width: ($("#testBar").width() * 3) + "px" 
      }, 500, function() { }); 
    } 
    var delay = (function() { 
     var timer = 0; 
     return function (callback, ms) { 
      clearTimeout(timer); 
      timer = setTimeout(callback, ms); 
     }; 
    })(); 
    function fireOneAnimateEvent() { 
     delay(function() { 
      animateRedBlock(); 
     }, 500); 
    }​ 
</script>