Angularjs $ionicScrollDelegate将视图锁定在滚动值上
当我在cordova应用程序中获取结果列表时,我希望使用以下函数将其滚动到指定元素:Angularjs $ionicScrollDelegate将视图锁定在滚动值上,angularjs,cordova,ionic,Angularjs,Cordova,Ionic,当我在cordova应用程序中获取结果列表时,我希望使用以下函数将其滚动到指定元素: $scope.roll = function () { //var rankScroll = $ionicScrollDelegate.$getByHandle('rank'); var meElement = document.getElementById('scroll'); if (!meElement) { $ionicS
$scope.roll = function () {
//var rankScroll = $ionicScrollDelegate.$getByHandle('rank');
var meElement = document.getElementById('scroll');
if (!meElement) {
$ionicScrollDelegate.scrollTo(0, 0);
return;
}
var top = meElement.getBoundingClientRect().top - 50;
$ionicScrollDelegate.scrollTo(0, top);
console.log(top);
console.log($ionicScrollDelegate.getScrollView());
}
它工作得很好,但我无法滚动到列表中的任何其他位置。我想解锁此解决方案中的滚动或找到更好的解决方案。它应该在加载的页面上滚动,而不是单击
由于$scope的绑定,所有最好的功能都会锁定您的滚动条 如果只希望在加载视图时调用该函数,则应在加载视图时调用它一次 您可以通过以下方式在控制器中执行此操作:
var roll = function () {
//var rankScroll = $ionicScrollDelegate.$getByHandle('rank');
var meElement = document.getElementById('scroll');
if (!meElement) {
$ionicScrollDelegate.scrollTo(0, 0);
return;
}
var top = meElement.getBoundingClientRect().top - 50;
$ionicScrollDelegate.scrollTo(0, top);
console.log(top);
console.log($ionicScrollDelegate.getScrollView());
}
$scope.$on("$ionicView.loaded", function (scopes, states) {
roll();
});
在此中,您可以查看更多$ionicView事件。删除包装有助于提高滚动的流畅性