Skip to content

Add height and width computed properties #61

Description

@mitchlloyd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions