问题描述
我的任务是采取一个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对移动设备方向的动作发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!