jquery.load
div(高さが0pxでoverflow:hidden)を使用してコンテンツをそのdivにロードし、そのjquery.css
高さをautoにすばやく変更してから、.height()
関数を使用して次の値を取得しているときに、この問題が発生しました。高さauto
なので、アニメートすると、アニメートする値がわかります。問題は.height()
、関数を最初に実行したときに値として0を返すことですが、2回目には正しい値を返します。これが私が使っているコードです。
$('#adobe').click(function()
{
$('#info').animate(
{
height:'0px'
},600,function()
{
$('#info').load('projects/adobe.html',animateHeight());
});
});
function animateHeight()
{
console.log($('#info'));
var temp = $('#info');
var curHeight = temp.height();
temp.css('height', 'auto');
var autoHeight = temp.height();
temp.css('height',curHeight);
console.log(autoHeight);
$('#info').animate(
{
height:autoHeight
},600);
$(window).scrollTo($('#info'),600,{axis:'y'});
}