Team:UNITN-Trento/JS/Library/onWidthChange

From 2013.igem.org

(Difference between revisions)
Ggirelli (Talk | contribs)
(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> ...")
Newer edit →

Revision as of 16:19, 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);
   })();

}