0

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();
   }
  }

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

2 Comments

Ah I see thank you. :) Is there any reason why matchMedia still doesn't work?
As far as I can tell it looks like it's working in the jsfiddle link that I gave you. When I resize the screen, the correct block is getting invoked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.