Team:UNITN-Trento/JS/Library/onWidthChange

From 2013.igem.org

(Difference between revisions)
(Created page with "/** * onWidthChange (oWri) event handler * @version onWidthChange 1.0 * @copyright Copyright (c) 2010-2012, Gabriele Girelli * @author ggirelli <g.girelli@studenti.unitn.it> ...")
 

Latest revision as of 16:36, 8 August 2013

/**

* onWidthChange (oWri) event handler
* @version onWidthChange 1.0
* @copyright Copyright (c) 2010-2012, Gabriele Girelli
* @author ggirelli <g.girelli@studenti.unitn.it>
*/

function oWch(event) {

   var getWidthValue = function() {
       return window.innerWidth;
   }
       var lastWidth = getWidthValue();
   (function listenWidth() {
       var width = getWidthValue();
       if (width !== lastWidth) {
           event();
           lastWidth = width;
       }
       var w = setTimeout(listenWidth, 100);
   })();

}