0
所以我想基於一個鍵輸入具有嵌套的滾動焦點。爲此,我使用了ng-focus
,但我似乎誤解了它的目的。AngularJS - 專注於嵌套滾動中的對象
這個JSFiddle顯示了我到目前爲止所做的。無論何時發現匹配,我將ng-focus="x._focus"
設置爲true,並在控制檯日誌中顯示發生了這種情況。但滾動並沒有移動到input
領域的焦點。那個怎麼樣?
所以我想基於一個鍵輸入具有嵌套的滾動焦點。爲此,我使用了ng-focus
,但我似乎誤解了它的目的。AngularJS - 專注於嵌套滾動中的對象
這個JSFiddle顯示了我到目前爲止所做的。無論何時發現匹配,我將ng-focus="x._focus"
設置爲true,並在控制檯日誌中顯示發生了這種情況。但滾動並沒有移動到input
領域的焦點。那個怎麼樣?
嘿,我真的不明白你想要什麼,但檢查這,讓我知道,如果這是你想要jsFiddle
function MyCtrl($scope)
{
$scope.list = []
for(var i = 0; i < 500; i++){
$scope.list.push({
number: i,
_focus: false
})
}
$(document).keypress(function(e)
{
for(var i = 0; i < $scope.list.length; i++)
{
if($scope.list[i].number === e.keyCode)
{
$scope.list[i]._focus = true
console.info('found : ', $scope.list[i])
$scope.$apply(); // Apply changes and change the false to true in dom
$('#nestedScroll').animate(
{
scrollTop: $("#nestedScroll span[scrollTo='true']").offset().top
}, "slow");
return
} else {
$scope.list[i]._focus = false
}
}
});
}
什麼有點。我已經更新你的小提琴http://jsfiddle.net/wjtz8xhr/13/,以便它可以找到我們正在尋找的物品。一個奇怪的是,當你第一次使用它時,如果你輸入的數字小於第一個數字,它就不能正確顯示 –
對不起,我不理解你,但是我給你作爲例如完美的作品,你可以找到你正在尋找的物品 – Diptox