Ember对移动设备方向的动作发生变化 [英] Ember Action on mobile device orientation change

查看:150
本文介绍了Ember对移动设备方向的动作发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是采取一个ember网站,并使其响应移动。其中一个问题是他们使用一个组件绘制图形(d3)。当父容器发生更改时,图形不会重新呈现。在桌面显示器上并不是很大的问题,但是在移动设备上,绘制的图形在纵向和横向之间是截然不同的。



我想知道是否有办法在窗口设备方向更改上附加一个ember观察者,要么通过jquery还是常规javascript?

解决方案

不完全确定Ember是否具有窗口事件处理,但使用 resize 通过jQuery可能会诀窍:

  resizeHandler:function(){
//执行重新渲染
},

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

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


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() {
    this._super(...arguments);
    $(window).on('resize', this.get('resizeHandler'));
},

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

这篇关于Ember对移动设备方向的动作发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆