W3C home > Mailing lists > Public > www-style@w3.org > August 2014

Re: why not MediaQueryList.onchange

From: Simon Pieters <simonp@opera.com>
Date: Thu, 07 Aug 2014 07:57:29 +0200
To: "Jonathan Fielding" <hello@jonathanfielding.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, "Jochen Eisinger" <eisinger@google.com>, "www-style list" <www-style@w3.org>
Message-ID: <op.xj7j53s3idj3kv@simons-mbp>
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

This archive was generated by hypermail 2.3.1 : Thursday, 7 August 2014 05:58:01 UTC