私は溶岩ランプのナビゲーションで奇妙な問題を経験しています。これは、JeffreyWayのLavaランプチュートリアルの後に適応されています。溶岩ランプのコードは下部にあります。問題は主にFirefox(私はFF6を使用しています)で発生しますが、ChromeとSafari(IE9ではない)でも発生することがあります。メニュー項目の上のオレンジ色の線が長すぎて、ページが読み込まれるときに右側に多すぎることがあります。アイテムにカーソルを合わせると、アイテムはその上に中央に配置され、最初から必要なようにそこにとどまります。なぜそれが起こるのか考えはありますか?position()。leftとouterWidth()で何か奇妙なことがありますか?フィードバックは非常に高く評価されています!
(function($) {
$.fn.spasticNav = function(options) {
options = $.extend({
speed: 500,
reset: 1500,
color: '#F29400',
easing: 'easeOutExpo'
}, options);
return this.each(function() {
var nav = $(this),
currentPageItem = $('#active', nav),
stroke,
reset;
$('<li id="stroke"></li>').css({
width: currentPageItem.outerWidth(),
height: 4,
margin: 0,
left: currentPageItem.position().left,
top: currentPageItem.position().top,
backgroundColor: options.color
}).appendTo(this);
stroke = $('#stroke', nav);
$('a:not(#stroke)', nav).hover(function() {
// mouse over
clearTimeout(reset);
stroke.animate(
{
left : $(this).position().left,
width : $(this).width()
},
{
duration : options.speed,
easing : options.easing,
queue : false
}
);
}, function() {
// mouse out
reset = setTimeout(function() {
stroke.animate({
width : currentPageItem.outerWidth(),
left : currentPageItem.position().left
}, options.speed)
}, options.reset);
});
});
};
})(jQuery);