Closed ghost closed 8 years ago
No luck either with Vue's beforeCompile
or created
hooks (instead of ready
) and Enquire's setup
callback:
setup: function() {
self.displayIsSmall = this.match;
self.displayIsLarge = this.unmatch;
},
Good to hear! Enquire was designed with mobile first in mind, hence why unmatch only fires if match has previously fired. You should set sensible defaults for mobile, change them in a match for larger viewports, and then undo the changes in unmatch
Will close this issue
Thanks for the clarification! Had no idea about it before coming upon this issue. I wonder if it wouldn't be better to add this piece of information to the documentation?
It is covered in the docs :)
Unmatch: If supplied, triggered when the media query transitions from a matched state to an unmatched state
Ohh, I'm so dumm! My apologies!
You're not the first person to make this mistake, and i'm sure you won't be the last :) Don't worry
:-) Btw, thanks for the great library!
I'm doing media queries with Enquire.js and Vue.js. It all pretty much works when I resize the browser's window manually. However, nothing happens when switching Chrome's toggle device mode on or when accessing the site on a mobile phone. I checked with the "Match & Unmatch Example", and it works as expected in the said mode. I wonder if there's some sort of incompatibility between Vue.js and Enquire.js or am I doing something wrong?
The logic for the media queries is on my vue instance's ready hook:
On my vue instance, I've the following data propperties:
On my html file, I'm using
v-if="displayIsSmall"
andv-if="displayIsLarge"
to hide/display elements according to the browser's size.Snapshots of large and small browser window firing expected behavior. Snapshot with Chrome toggle device mode on, not firing expected behavior.