Re: why not MediaQueryList.onchange

On Wed, 06 Aug 2014 16:32:26 +0200, Jonathan Fielding  
<hello@jonathanfielding.com> wrote:

> Hi
>
> What I meant was a resize event per MediaQueryList, if you look at  
> www.simplestatemanager.com you would see that it allows your to have a  
> enter, leave and resize event.
>
> So if we think of this in terms of the MediaQueryList, we currently have
>
> var mql = window.matchMedia("screen and (max-width:768px)");
> mql.addListener(function(e){
>     if(e.matches){
>         console.log(‘matched');
>     }
>     else{
>         console.log(‘unmatched');
>     }
> });
>
> But what we might have instead is:
>
> var mql = window.matchMedia("screen and (max-width:768px)”);
>
> mql.addEventListener(“match”, function(){
>  console.log(‘ive matched’);
> });
>
> mql.addEventListener(“unmatch”, function(){
>  console.log(‘ive unmatched’);
> });
>
> mql.addEventListener(“resize”, function(){
>  console.log(‘while matched and browser is resized I will fire’);
> });
>
> So this gives us the ability to add a resize event specific to a “state”  
> i.e. while the media query matches.

OK, so this is just sugar, it doesn't enable any new abilities, right?

-- 
Simon Pieters
Opera Software

Received on Thursday, 7 August 2014 05:58:00 UTC