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 height and width computed properties #61

Open
mitchlloyd opened this issue Dec 21, 2015 · 0 comments
Open

Add height and width computed properties #61

mitchlloyd opened this issue Dec 21, 2015 · 0 comments

Comments

@mitchlloyd
Copy link

Would you be open to adding height and width properties to the media service?

I made a simple addon service to return the height and width of the screen in pixels. I worked on some projects recently where developers were doing some specific element positioning based on the height and width of window. The ember addon they were finding first had an approach that wasn't working well for us.

I also added some breakpoint functionality to the addon I made. @taras pointed out that Ember Responsive already has this breakpoint feature. Getting the screen height and width is a little different that using matchMedia from an implementation perspective, but it might fit well into the space of "do things with Ember based on the size of the window".

I could create a PR for this although I'm not sure what the testing approach would be. I don't see any tests in this project that integrate with browser APIs. I think this approach is justified since resizing a browser while testing is non-trivial. Perhaps a smoke test that reads the current innerHeight and innerWidth and makes sure that the properties on media match that would be sufficient. You can take a look at the testing approach I used which opens a browser window with window.open so that it can be manipulated during tests. It was interesting to work on, but might be better in the long run to just have a manual test like you have in the dummy app index template.

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

No branches or pull requests

1 participant