当我在用ng-repeat创建的元素下降时,如何向下滚动
How to scroll down when i descend in the elements created with ng-repeat
我有一个用ng-repeat创建的列表和两个向上或向下的按钮。用户可以选择列表中的任何元素,并使用两个按钮向上或向下移动。
当按钮向下移动选定元素时,滚动条仍然固定,我无法再看到选定的元素。
我想在元素被隐藏时向下滚动
<div class="panel-body panelBodySelectedData" style="padding-left: 10px">
<nav>
<ul ng-repeat="item in resultJson.items" class="nav nav-pills nav-stacked span2">
<li class="itemReporting" ng-click="selectItem($index)" ng-class="{selectedReportingItem: $index==selectedIndex}" >{{item.label}}</li>
</ul>
</nav>
</div>
$scope.goUp = function(){
if($scope.selectedIndex > 0){
console.log('goUp');
$scope.aux = $scope.resultJson.items[$scope.selectedIndex];
$scope.selectedIndex -- ;
$scope.resultJson.items[$scope.selectedIndex+1] = $scope.resultJson.items[$scope.selectedIndex];
$scope.resultJson.items[$scope.selectedIndex] = $scope.aux;
}
};
$scope.goDown = function(){
if($scope.selectedIndex < $scope.resultJson.items.length -1){
console.log('goDown');
$scope.aux = $scope.resultJson.items[$scope.selectedIndex];
$scope.selectedIndex ++ ;
$scope.resultJson.items[$scope.selectedIndex-1] = $scope.resultJson.items[$scope.selectedIndex];
$scope.resultJson.items[$scope.selectedIndex] = $scope.aux;
$location.hash('bottom');
// call $anchorScroll()
$anchorScroll();
}
};
相关文章:
- 使用webdriver io在可滚动元素内滚动
- 每次单击按钮时水平滚动元素
- 可滚动元素,如何在调整大小时更改顶部偏移量
- 如何使用javascript检测不可滚动元素中的滚动事件和方向
- 滚动元素的交叉溶解过渡
- 自动上下滚动元素
- 检测可滚动元素内的滚动位置
- 为滚动元素制作动画
- 如何自动滚动元素
- 使用鼠标滚轮滚动元素时传播的事件是什么
- 在鼠标滚动时使用 JQuery 水平滚动元素
- 在屏幕顶部附近滚动元素时触发的侦听器
- 如何在调整大小时更改滚动元素的行为?(HTML,CSS,JavaScript)
- 滚动元素上的Javascript触摸移动事件
- Poshy提示不随滚动元素移动
- 如何在JQuery中滚动元素
- jsPDFaddHTML获取滚动元素的全部内容
- 使用鼠标滚轮滚动页面时,避免滚动可滚动元素
- 滚动元素到视图中而不与页眉重叠
- 如何为自定义滚动元素添加限制