Anonymous edits have been disabled on the wiki. If you want to contribute please login or create an account.


Warning for game developers: PCGamingWiki staff members will only ever reach out to you using the official press@pcgamingwiki.com mail address.
Be aware of scammers claiming to be representatives or affiliates of PCGamingWiki who promise a PCGW page for a game key.

Difference between revisions of "MediaWiki:Common.js"

From PCGamingWiki, the wiki about fixing PC games
m (Alternate script test)
m (Another test)
Line 1: Line 1:
 
/* Below: necessary for the Beginner's Guide template */
 
/* Below: necessary for the Beginner's Guide template */
  
$(function() {
 
 
     var $sidebar  = $("#guide-nav"),
 
     var $sidebar  = $("#guide-nav"),
 
         $window    = $(window),
 
         $window    = $(window),
 
         offset    = $sidebar.offset(),
 
         offset    = $sidebar.offset(),
 
         topPadding = 15;
 
         topPadding = 15;
       
+
 
    $window.scroll(function() {
+
$(window).scroll(function() {
        if ($window.scrollTop() > offset.top) {
+
    if( $sidebar.scrollTop() >= offset.top ) {
             $sidebar.stop().animate({
+
        if( !fixed ) {
                marginTop: $window.scrollTop() - offset.top + topPadding
+
            fixed = true;
            });
+
             $sidebar.css({position:'fixed',top:20}); // Or set top:20px; in CSS
         } else {
+
         }                                          // It won't matter when static
             $sidebar.stop().animate({
+
    } else {
                marginTop: 0
+
        if( fixed ) {
            });
+
            fixed = false;
 +
             $sidebar.css({position:'static'});
 
         }
 
         }
     });
+
     }
 
});
 
});
  
 
/* end Beginners Guide script */
 
/* end Beginners Guide script */

Revision as of 21:25, 29 April 2012

/* Below: necessary for the Beginner's Guide template */

    var $sidebar   = $("#guide-nav"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 15;

$(window).scroll(function() {
    if( $sidebar.scrollTop() >= offset.top ) {
        if( !fixed ) {
            fixed = true;
            $sidebar.css({position:'fixed',top:20}); // Or set top:20px; in CSS
        }                                           // It won't matter when static
    } else {
        if( fixed ) {
            fixed = false;
            $sidebar.css({position:'static'});
        }
    }
});

/* end Beginners Guide script */