mercredi 2 mars 2016

Converting jquery "if" statement to "switch"

I am trying to convert my if statement to switch; so far no luck:

if (myapp_config.thisDevice == 'desktop') {

  var primaryNavHeight = $('#primary-nav').height() + app_get_header_height,
    pageWrapperHeight = $('#page-wrapper').height();

  if (primaryNavHeight > pageWrapperHeight) {
    $('#page-wrapper').css("min-height", primaryNavHeight + "px");
  }
  if (primaryNavHeight < pageWrapperHeight) {
    $('#page-wrapper').css("min-height", $(window).height() + "px");
  }

}

And so far I have tried the following:

switch (myapp_config.thisDevice == 'desktop') {
  case (primaryNavHeight > pageWrapperHeight):
    // do stuff
    $('#page-wrapper').css("min-height", primaryNavHeight + "px");
    break;
  case (primaryNavHeight < pageWrapperHeight):
    // do stuff
    $('#page-wrapper').css("min-height", primaryNavHeight + "px");
    break;
}

Would someone be kind enough to point me what I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire