Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Scroll to Element

I have an with:

<span id="quote-{{quote.id}}" ng-repeat="quote in quotes">{{quote.text}}</span>

I'm trying to have an index to scroll to any part of the scroller using:

$scope.jumpToQuote = function (quote) {
  $scope.quoteSelected = quote;
  var quotePosition = $ionicPosition.position(angular.element(document.getElementById('quote-'+quote)));
  $ionicScrollDelegate.$getByHandle('quotes-box').scrollTo(quotePosition.left, quotePosition.top, true);
}

However the value of quotePosition.top always equals 10 which is the top-offset of the <ion-scroll>.

like image 559
davids.1 Avatar asked Sep 27 '22 21:09

davids.1


1 Answers

As far as i see, you need to replace document.getElementById('quote-'+quote) with document.getElementById('quote-'+quote.id) , You are concatenating whole quote object instead of it's id.

like image 198
Mudasser Ajaz Avatar answered Sep 30 '22 07:09

Mudasser Ajaz