-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add optional support for matchMedia #126
base: master
Are you sure you want to change the base?
Conversation
…guments as Paul Irish's original function. Still runs if matchMedia isn't found.
Had to make a couple quick updates to clean up my code. Let me know if there's anything else you see needing to be done in order for this to be included. |
…ple in the main file.
Fixes made to readme to use single quotes. |
Hey! Just wanted to say I like this. Might be a bit before I have time to pull the branch, QA it and merge it all in. But this is a pretty sweet feature. That ternary + min/max super loop thing we have going on may need some cleaning up, but don't worry about it right now. Cleaning up that min/max stuff has been in the back of my brain for awhile. Thanks! And hopefully I can get to this soon. |
Cool, glad you like it, Dave! By the way, love your podcast, long time listener! |
As far as the ternary, my initial commit has my logic a little more expanded so its more legible (before I made it all one line for file size sake). We can roll back to that version of that chunk of code if you like - it'd also provide the opportunity to output a console message to let devs know if/when matchMedia is asked for, but not found. That part is unnecessary, but convenient and wouldn't add a lot of file size. Up to you! It's a pretty small detail, and that line of code executes quite quickly and is pretty efficient (it's just not as easy/convenient for humans to read), so it may not need adjustment to be honest, but happy to revisit it - let me know your preference. |
Uses Paul Irish's original
matchMedia
function if it's available, and takes a string as a plugin option of the same name. Still runs if matchMedia isn't found. Added usage instructions to the readme and an example line in the demo file. I chose to accept all the same arguments as matchMedia because it was easy, and enables things likematchMedia: 'tv'
and orientation-based fitText viamatchMedia: 'all and (orientation:landscape)'
, etc.