Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jpederson
Copy link

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 like matchMedia: 'tv' and orientation-based fitText via matchMedia: 'all and (orientation:landscape)', etc.

@jpederson
Copy link
Author

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.

@jpederson
Copy link
Author

Fixes made to readme to use single quotes.

@davatron5000
Copy link
Owner

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.

@jpederson
Copy link
Author

Cool, glad you like it, Dave! By the way, love your podcast, long time listener!

@jpederson
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants