所以我碰到了下面的代码片段,这对于在div中更改页面非常有用。但是,我正在努力做到以下几点:
- 进行设置,使其在CSS预加载器中消失,例如preload(https://projects.lukehaas.me/css-loaders/)
- 然后在x秒内显示此预加载器
- 然后让预加载器淡出并显示内容。
如果外面有人可以帮助我指出正确的方向,请先谢谢。
$(function() {
if(Modernizr.history){
var newHash = "",$mainContent = $("#main-content"),$pageWrap = $("#page-wrap"),baseHeight = 0,$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
$("nav").delegate("a","click",function() {
_link = $(this).attr("href");
history.pushState(null,null,_link);
loadContent(_link);
return false;
});
function loadContent(href){
$mainContent
.find("#guts")
.fadeOut(2000,function() {
$mainContent.hide().load(href + " #guts",function() {
$mainContent.fadeIn(1000,function() {
$pageWrap.animate({
});
});
$("nav a").removeclass("current");
console.log(href);
$("nav a[href$="+href+"]").addClass("current");
});
});
}
$(window).bind('popstate',function(){
_link = location.pathname.replace(/^.*[\\\/]/,'');
loadContent(_link);
});
}
});