如何使用 Ember 更新属性后滚动到 DOWN
how to scrolled to DOWN after updating the properties using ember
I am using ember view, once the page loads i want to scroll down to the page.In view didInsertElement will call and make the page load to scroll down, here is my code
App.MessagesView = Ember.View.extend({
didInsertElement: function() {
this._super();
var $target = $('.chat-area .chat-list')
, height = 0;
if ($target) {
$target.each(function(i, items_list) {
$(items_list).find('li').each(function() {
console.log($(this).height());
height = height + parseInt($(this).height());
});
});
$target.animate({ scrollTop: height});
}
}
但是一旦进入控制器,如果加载了新的其他消息,因为视图已经加载,滚动条不会向下滚动到页面。 对于另一条消息,新消息将更新为计算属性,我想在更新 DOM 消息后调用并调用向下滚动代码。
App.MessagesController = Ember.ArrayController.extend({
newmsgsCaptured: function(uuid) {
this.setProperties({
'newSelectedMessages': response,
});
var $target = $('.chat-area .chat-list')
, height = 0;
if ($target) {
$target.each(function(i, items_list) {
$(items_list).find('li').each(function() {
console.log($(this).height());
height = height + parseInt($(this).height());
});
});
console.log(height);
$target.animate({ scrollBottom: height});
}
}
});
after calling newmsgsCaptured 'acction', the property is updated with new data and the scrolled down is not working.
您需要在消息的存储位置设置观察器:
messagesUpdated: function() {
//scroll action here
}.observes('messagesArray'),
这将在"消息数组"更改时触发该函数
实际上我已经完成了如下视图
didInsertElement: function() {
Ember.run.schedule("afterRender", this, function() {
if (this.get('controller.isScrollDown')) {
this.send("scrollDown");
}
});
}.observes('controller.vehicleSelectedMessages'),
相关文章:
- 幻灯片滚动javascript不起作用
- 将视口底部滚动到元素底部
- jQuery Lazy加载动画滚动
- 设置滑块分区上的滚动
- 结合jQuery和jetpack无限滚动
- 单击顶部导航时如何进行向下滚动效果(向下滑动).
- 滚动到容器中的下一个元素-几乎到了
- 只覆盖箭头键滚动事件
- Javascript如何找到滚动事件的来源
- Image赢得't隐藏在滚动jQuery上
- Safari(Mac OS)上的jQuery平滑滚动问题
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- 禁用(而不是隐藏)浏览器滚动条
- JavaScript上下滚动不可预测
- 滚动和表格
- 谷歌地图劫持了iphone's滚动(触摸事件)-如何恢复
- 我希望只有在我滚动页面后才能显示我的返回页首图标
- 循环滚动数组
- 滚动以修复向上滚动的问题
- 如何使用 Ember 更新属性后滚动到 DOWN