X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=8d19f3a0d133a010e6c50f5fcfabe0d754ef5861;hb=383378d6a66b3b00bb540e2c1738d18d470b557e;hp=4a48c485335e9db9f1e1eef428d804af84906688;hpb=6bf13517fbd14d3847f45acf802395dbe0742974;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 4a48c48..8d19f3a 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -332,12 +332,26 @@ mkws.pagerNext = function(tname) { function resizePage() { var list = ["mkwsSwitch", "mkwsLang"]; - var width = mkws.config.responsive_design_width; var parent = $(".mkwsTermlists").parent(); - - if ($(window).width() <= width && + var targetWidth = mkws.config.responsive_design_width; + var width = $(window).width(); + + if (mkws.width === undefined) { + // No state change, since we have no previous state + } else if (mkws.width <= targetWidth && width > targetWidth) { + log("narrow -> wide"); + } else if (mkws.width > targetWidth && width <= targetWidth) { + log("wide -> narrow"); + } else if (width > targetWidth) { + log("already wide"); + } else { + log("already narrow"); + } + mkws.width = width; + + if (width <= targetWidth && parent.hasClass("mkwsTermlist-Container-wide")) { - log("changing from wide to narrow: " + $(window).width()); + log("changing from wide to narrow: " + width); $(".mkwsTermlist-Container-wide").hide(); $(".mkwsTermlist-Container-narrow").show(); for (var tname in mkws.teams) { @@ -347,9 +361,9 @@ mkws.pagerNext = function(tname) { $("." + list[i] + ".mkwsTeam_" + tname).hide(); } } - } else if ($(window).width() > width && + } else if (width > targetWidth && parent.hasClass("mkwsTermlist-Container-narrow")) { - log("changing from narrow to wide: " + $(window).width()); + log("changing from narrow to wide: " + width); $(".mkwsTermlist-Container-wide").show(); $(".mkwsTermlist-Container-narrow").hide(); for (var tname in mkws.teams) {