-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to trigger match on initial pageload? #122
Comments
I am looking for this feature too. It seems trivial to implement. Just pass along I can make up a pull request if this is a feature that would be merged into the project? @WickyNilliams |
Looking through the code I see that it can be extended even further to make But the |
@khromov In the meantime you can do something like this as a workaround: var query = '(max-width: 767px)';
...
enquire.queries[query].matches() // returns true or undefined Note that There is a bug in the API where a call to |
I'm trying to do something similar, calling ajax for different parts during page load. If page loaded while matching, match triggered. But if page load while not matching, unmatch doesn't fire. The workaround works. Tried the suggested code change, seems no effect. |
Maybe an extra option can be added to set whether |
+1 |
1 similar comment
+1 |
@michaellopez has some valid arguments for adding an argument to the setup function (a In addition to that, it feels a bit wrong that currently only the |
As workaround, you could also register an additional negated media query by prepending enquire.register('screen and (min-width: 45em)', function () {
});
enquire.register('not screen and (min-width: 45em)', function () {
}); See also: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#not |
enquire.js : v2.1.6
My questions are:
Can you please fix behavior 3 and 4! Behaviors 1, 2, 5, 6 - are OK! |
We want to trigger match() and unmatch() on initial pageload. The setup() function runs but it doesn't have any useful parameters and what we really want is to check whether the media queri matches or not so we can perform logic on the initial page load.
I'm not sure how such a common use case could be glossed over?
The text was updated successfully, but these errors were encountered: