WickyNilliams / enquire.js

Awesome Media Queries in JavaScript
http://wicky.nillia.ms/enquire.js/
MIT License
3.62k stars 269 forks source link

strange fire events after match/unmatch #85

Closed simonschaufi closed 10 years ago

simonschaufi commented 10 years ago

my code:

enquire
    /* phone */
    .register('(max-width:766px)', {
        match : function() {
            console.log('phone enter');
        },
        unmatch : function() {
            console.log('phone leave');
        }
    })
    /* tablet */
    .register('(min-width:768px) and (max-width:979px)', {
        match : function() {
            console.log('tablet enter');
        },
        unmatch : function() {
            console.log('tablet leave');
        }
});

console output after resizing the browser into smaller direction:

phone enter
tablet leave
phone leave
tablet enter
phone enter
tablet leave 

i use google chrome version 25.0.1400.0 (185000)

risizing bigger is no problem, the output is as expected phone leave, tablet enter. am I doing something wrong or is there a problem in your code?

hannesjohansson commented 10 years ago

It's a webkit bug present in old versions of Chrome but also the present version of Safari on OSX.

You can test it here: http://jsfiddle.net/tmaynard/6p8nC/embedded/result/

simonschaufi commented 10 years ago

ok, good that you are aware of this.

it happens in google chrome 30 on OSX as well.