動(dòng)畫(huà)bug的處理方法
/**
* Created by Administrator on 2015/6/30.
*/
$(function(){
? ?$('.link .button').hover(function(){
? ? ? ?var title = $(this).attr('data');
? ? ? ?$('.tip em').text(title);
? ? ? ?var pos = $(this).position().left+10;
? ? ? ?var distance = ($('.tip').outerWidth()-$(this).outerWidth())/2;
? ? ? ?var l = pos-distance;
? ? ? ?//$('.xx').Stop(true,true)與$('.xx').Stop(true,false)的區(qū)別?
? ? ? ?// (1)stop()效果第一個(gè)參數(shù)規(guī)定是否停止被選元素的所有加入隊(duì)列的動(dòng)畫(huà),
? ? ? ?// (2)第二個(gè)參數(shù)規(guī)定是否允許完成當(dāng)前的動(dòng)畫(huà)。但前提是要設(shè)置了第一個(gè)參數(shù)。
? ? ? ?$('.tip').css({'left':l+'px'}).stop(true,true).animate({'top':150,'opacity':1},500);
? ?},function(){
? ? ? ? ? ?$('.tip').stop(true,true).animate({'top':100,'opacity':0},500);
? ?})
})
2015-12-04
在2個(gè).animate前都加.stop(true,true)去掉if語(yǔ)句就可以解決了。