Skip to content

Instantly share code, notes, and snippets.

@m4r00p
Created April 2, 2014 20:47
Show Gist options
  • Save m4r00p/9942820 to your computer and use it in GitHub Desktop.
Save m4r00p/9942820 to your computer and use it in GitHub Desktop.
function loadContent(href, pushState) {
var el = $('<div></div>');
el.load(href + ' .placeholder', function (response, status, xhr) {
if (status === 'error') {
w.location = href;
} else {
if (pushState) {
window.history.pushState({}, document.title, href);
}
var currentPage = $('.placeholder');
var nextPage = el.find('.placeholder');
overrideLinks(nextPage[0]);
$(d.body).append(nextPage);
nextPage.css('left', $(w).innerWidth())
currentPage.animate({ left: -$(w).innerWidth()}, 500, function () {
currentPage.remove();
});
nextPage.animate({ left: 0}, 500, function () {
//TODO: What more after switch pages
// HOWTO inform google analytics
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment