問題は、マウスをプラスアイコンの上に移動すると、プラスアイコンを非表示にするproject-thumbnailマウスリーブハンドラーをトリガーし、プラスアイコンを表示するproject-thumbnailマウス入力ハンドラーを再度トリガーすることですが、マウスはすでにプラスの上にあると思いますマウスを離すハンドラーを再度トリガーするなどなど。もちろん、アニメーションが繰り返し開始および停止するため、吃音は発生します。
html 構造を修正して、プラス リンクをproject-thumbnaildiv 内に配置することもできます。bondythegreat でカバーされています。
または、次のようなハックを試すこともできます。
var projectThumbnail = $('.project-thumbnail'),
imgWidth = projectThumbnail.width(),
imgHeight = projectThumbnail.height(),
timeoutID; // <-- new variable
projectThumbnail.mouseenter(function(e) {
$(this).children('a').children('img').stop().animate({ height: imgHeight, left: '0', top: '0', width: imgWidth}, 100);
$(this).children('a').children('span').stop().fadeIn(200);
$(this).next('.zoom-button').show();
}).mouseleave(function(e) {
// move original functionality into a timeout, saving a reference
// to this for use within the timeout
var $this = $(this);
timeoutID = setTimeout(function() {
$this.children('a').children('img').stop().animate({ height: imgHeight + 33, left: '-20', top: '-20', width: imgWidth + 50}, 100);
$this.children('a').children('span').stop().fadeOut(200);
$this.next('.zoom-button').hide();
}, 5);
});
// cancel the timeout when entering the plus button
$(".zoom-button").mouseenter(function(e) {
clearTimeout(timeoutID);
});
デモ: http://jsfiddle.net/NrtvK/2/
(私はこれがかなり危険であることを知っていますが、私は好奇心からそれを試してみました。