2010-09-15 106 views
0

我有一個圖像背景的div,另一個div上面以透明開始。我想在上面duiv中的幻燈片png背景中滑動,更改背景並滑出以顯示它。幻燈片背景封面和更改覆蓋的背景圖片

我已經編碼這個,問題是序列。結構slide_in,更改背景,slide_out隨機混合。

var step = 20;     // How many pixels to move per step 
var current = -1920;   // The current pixel row 
var imageWidth = 1920;  // Background image width 
var headerWidth = 960;  // How wide the header is. 
var init; 

function slide_in(){ 
    current += step; 
$('#bgfade').css("background-position",current+"px 0"); 
if(current==0) clearInterval(init); 
} 

var outstep = 20;     // How many pixels to move per step 
var outcurrent = 0;   // The current pixel row 
var outimageWidth = 1920;  // Background image width 
var outheaderWidth = 960;  // How wide the header is. 
var outinit; 

function slide_out(){ 
outcurrent -= step; 
$('#bgfade').css("background-position",outcurrent+"px 0"); 
if(outcurrent==0) clearInterval(outinit); 
} 

$('#bgfade').click(function(){   
init = setInterval(slide_in, 1); 
$('#bg').css('background-image','url(images/photo2.jpg)'); 
outinit = setInterval(slide_out, 1); 
}); 

由於click事件occurr,第一件事發生在它的背景開始滑出後的圖像被改變,但它從來沒有在

回答