jacopotarantino / angular-match-media

Angular module to use Bootstrap3 media queries in your angular controllers.
https://jack.ofspades.com/angular-matchmedia-module/
Other
135 stars 37 forks source link

onChange event missing #8

Closed demiro closed 8 years ago

demiro commented 9 years ago

Hello,

nice and clean utility. Very handy!

The only thing it misses is a onChange event that would trigger when you actually change t-shirt view port and not on every resize...

so like screenSize.onChange(new, function(....)

but would also help to have an old value, so from->to

jacopotarantino commented 9 years ago

Hey, thanks! Sorry it's poorly documented but there is actually an on method that you could use: https://github.com/jacopotarantino/angular-match-media/blob/master/match-media.js#L115

That should trigger on window resize which sounds like what you want. If you want to document it or add another method that does something different, I wouldn't mind a pull request.

Let me know if you have any other questions or if that wasn't what you wanted.

demiro commented 9 years ago

Sadly it doesn't .... this triggers each time a window is resized...

imagine that you are SM... and resizing window from 768 to 992 .... each time you'd resize it'll still trigger... even though the mq layout hasn't changed...

right now I am having a helper variable: before ... and on each resize checks if the new value is different than "before".. then, and only then I trigger a callback...

jacopotarantino commented 9 years ago

Hmm... you're right. It might be a good idea to refactor a bit as the namespacing is getting a bit cluttered. I'd appreciate a PR with the changes you'd like to see if you have time.

bitflower commented 9 years ago

I've added the .when method a few months ago which - if I understand correctly - is what @demiro wants?

sravenhorst commented 9 years ago

Probably way too late, but check my pull request: https://github.com/jacopotarantino/angular-match-media/pull/22

jacopotarantino commented 8 years ago

Closing this as I believe it has been resolved.