これは絶対測位を使用するため(フルスクリーンデモを表示しない限り)jsbinでは機能しません。ただし、とにかくコピーして自分のブラウザに貼り付けるために提供しましたhttp://jsbin.com/uteyik/12 / ..以下は変更のハイライトです。
css:
.row {
..
position:absolute; /* changed to absolute */
}
.mask {
..
width:100%; /* changed to 100% */
position:absolute; /*changed to absolute */
}
およびjavascript:
jQuery(document).ready(function() {
function fill_box(rows) {
var rowHeight = getSampleRowHeight();
var thisRowHeight = 0;
for(var i = 0; i < rows; i += 1) {
$('.box').append('<div class="row" style="top: '+thisRowHeight+'"><div class="scan_cursor i1"> </div><div class="scan_cursor i2"> </div><div class="scan_cursor i3"> </div><div class="mask"> </div></div>');
thisRowHeight +=rowHeight;
}
}
fill_box(30);
function tag_animate(el) {
// animate the mask
el.animate( {
'margin-left' : '100%'
},
{
complete : function () {
tag_animate(el.parent().next().find('.mask'));
}
}
);
// animate the stripes
el.siblings().animate( {
'margin-left': '100%'
},
{
complete : function () {
el.siblings().hide();
}
}
);
}
tag_animate($('.box').find('.row').eq(0).find('.mask'));
function getSampleRowHeight() {
// get sample row height, append to dom to calculate
$('.box').append('<div class="row" style="display: hidden"> <div class="scan_cursor i1"> </div></div>');
var rowHeight = $('.row').height();
$('.box').find('.row').remove();
return rowHeight;
}
});
説明:最初にダミーの行を作成し、その高さを計算します。次にposition: absolute
、ダミーの行の高さx行番号を使用して、行を作成し、上から配置します。マスクが100%のときに下のストライプを押さないように、すべてを絶対配置で作成したかったのです。また、コンテンツを非表示にするので行が必要ないため、行は絶対でなければなりません。下にジャンプします。
ボーナス:逆の方法で機能することを確認してください(つまり、テキストが消えます):http: //jsbin.com/uteyik/9これは私の最初の(そして間違った)答えでした