Carlos Salazar Carlos Salazar - 22 days ago 4x
Javascript Question

Ember Action on mobile device orientation change

I've been tasked with taking an ember website and making it responsive to mobile. one of the problems is that they use a component to draw a graph (d3). the graph is not re-rendered when there is a change on the parent container. Not really much of a problem on a desktop display, but on mobile the drawn graph is drastically different between portrait and landscape.

I'm wondering if there is a way to attach an ember observer on a window device orientation change, either hrough jquery or regular javascript?


Not completely sure if Ember has window event handling thus far, but utilizing resize via jQuery might do the trick:

resizeHandler: function() {
    //execute re-render

init: function() {
    $(window).on('resize', this.get('resizeHandler'));

willDestroy: function() {
    $(window).unbind('resize', this.get('resizeHandler'));