2014-07-24 31 views
1

我正尝试使用css动画创建一个完整的页面转换。我在路上来到了一个岔路口。我在链接上放置了一个类,并使用JQuery调用它,然后将css类应用于页面以激活转换。现在,当我分配新的窗口位置时,它想要覆盖动画。这就像我可以有一个或另一个,而不是两个,至少不是我如何做它......任何提示?我的页面转换不起作用

下面的代码

$(document).ready(function() { 

    var linkLocation 

    $("a.transition").click(function(event){ 
     event.preventDefault(); 
     linkLocation = this.href; 
     redirectPage();  

    }); 

    function redirectPage() { 
     $("body").attr('class', 'page-rotateSlideOut'); 
     window.location = linkLocation; 
    } 

}); 
+1

删除$("body").attr('class', 'page-rotateSlideOut');而不是创造全球varible,这将是很好的传递参数的功能直接'redirectPage(this.href);'和'功能redirectPage(linkLocation) ' –

回答

1

window.location = linkLocation将刷新页面。这就是为什么你的转换不起作用。

如果您.page-rotateSlideOut风格上有一个时间,你可以这样做:

setTimeout(function() { window.location = linkLocation; }, duration); 
0

尝试使用setTimeout

$("a.transition").click(function(event){ 
    event.preventDefault(); 
    linkLocation = this.href; 
    $("body").attr('class', 'page-rotateSlideOut'); 
    setTimeout(redirectPage,5000);  

}); 

redirectPage