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

Re: why not MediaQueryList.onchange

From: Jonathan Fielding <hello@jonathanfielding.com>
Date: Fri, 08 Aug 2014 17:37:04 +0000
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Jochen Eisinger <eisinger@google.com>, www-style list <www-style@w3.org>
Message-Id: <4CC37054-D783-4B31-AD2A-3CF29180F41A@jonathanfielding.com> (sfid-20140808_173710_902708_D98B76AB)
To: Simon Pieters <simonp@opera.com>
By baking this right into the browser, the browser controls the performance optimisation, so in the case of a resize event only for large viewports, on smaller viewports we won’t have any resize methods firing. 

Jonathan Fielding
@jonthanfielding



On 7 Aug 2014, at 06:57, Simon Pieters <simonp@opera.com> wrote:

> 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 Tuesday, 12 August 2014 14:46:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 12 August 2014 14:46:28 UTC