Difference between revisions of "MediaWiki:Vector.js"

From TerraFirmaCraft Wiki
Jump to: navigation, search
(Created page with "Any JavaScript here will be loaded for users using the Vector skin: // Cache selectors outside callback for performance. var $window = $(window), $stickyEl...")
 
m
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for users using the Vector skin */
 
/* Any JavaScript here will be loaded for users using the Vector skin */
  
  // Cache selectors outside callback for performance.  
+
// Cache selectors outside callback for performance.  
  var $window = $(window),
+
var $window = $(window),
      $stickyEl = $('#the-sticky-div'),
+
  $stickyEl = $('#p-googleadsense'),
      elTop = $stickyEl.offset().top;
+
  elTop = $stickyEl.offset().top;
  
  $window.scroll(function() {
+
$window.scroll(function() {
        $stickyEl.toggleClass('sticky', $window.scrollTop() > elTop);
+
$stickyEl.toggleClass('sticky', $window.scrollTop() > elTop);
    });
+
});

Revision as of 23:17, 20 July 2016

/* Any JavaScript here will be loaded for users using the Vector skin */

// Cache selectors outside callback for performance. 
var $window = $(window),
   $stickyEl = $('#p-googleadsense'),
   elTop = $stickyEl.offset().top;

$window.scroll(function() {
	$stickyEl.toggleClass('sticky', $window.scrollTop() > elTop);
});