davids.1
davids.1

Reputation: 169

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>.

Upvotes: 5

Views: 7035

Answers (1)

Mudasser Ajaz
Mudasser Ajaz

Reputation: 6257

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.

Upvotes: 4

Related Questions