Template:Team:Berkeley/windowSize.js

From 2013.igem.org

(Difference between revisions)
Tnrich (Talk | contribs)
(Created page with " $(document).ready(function() { // Optimalisation: Store the references outside the event handler: var $window = $(window); var $globalWrapper = $('#globalWrapper'); ...")
Newer edit →

Revision as of 00:21, 25 October 2013

$(document).ready(function() {

   // Optimalisation: Store the references outside the event handler:
   var $window = $(window);
   var $globalWrapper = $('#globalWrapper');
   function checkWidth() {
       var windowsize = $window.width();
       if (windowsize < 1000) {
           //if the window is greater than 440px wide then turn on jScrollPane..
           $globalWrapper.css('width':'100px' });
       }
       else {
           $globalWrapper.css({'width':'100%'});        
       }
   }
   // Execute on load
   checkWidth();
   // Bind event listener
   $(window).resize(checkWidth);

});