user2252219
user2252219

Reputation: 865

Jquery change script elements on browser width adjust

I'm trying to use matchMedia in Jquery so that the script will draw smallBlock when the browser is 479px wide or less and draw largeBlock on every other size.

Here is the full script code: The first part of the script is TweenMax and the second part is my script. https://jsfiddle.net/h0eu0edd/

You can see the rectangle being drawn on here (http://imdarrien.com/#)

  function handleScreen(mql) {
   if (mql.matches) {
       smallBlock();
   } else {
       largeBlock();
   }
  }

Upvotes: 0

Views: 40

Answers (1)

Jose Basilio
Jose Basilio

Reputation: 51548

There were a few syntax errors in the code you posted to jsfiddle.

Also, I changed the code to use $(document).ready instead of $(window).load as jsfiddle doesn't handle it.

See here: https://jsfiddle.net/w1xnsgcg/

Upvotes: 1

Related Questions