Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Amending Dynamic Page script to change the order of effects

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #34840
    nickharambee
    Member

    Hi,

    I am wondering if it would be possible to alter the script that Chris posted on CSS tricks for dynamically loading the content of new pages with a fade effect here, so that the order of the effects is:

    Fade out current page
    Alter height of page to fit new content
    Fade in new page

    Here’s Chris’s script:

    $(function() {

    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() {
    window.location.hash = $(this).attr("href");
    return false;
    });

    $(window).bind('hashchange', function(){

    newHash = window.location.hash.substring(1);

    if (newHash) {
    $mainContent
    .find("#guts")
    .fadeOut(2000, function() {
    $mainContent.hide().load(newHash + " #guts", function() {
    $mainContent.fadeIn(2000, function() {
    $pageWrap.animate({
    height: baseHeight + $mainContent.height() + "px"
    });
    });
    $("nav a").removeClass("current");
    $("nav a[href="+newHash+"]").addClass("current");
    });
    });
    };

    });

    $(window).trigger('hashchange');

    });

    Thanks,

    Nick

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.