ionic-framework: bug: anchorScroll throws exceptoin : Cannot read property 'attributes' of null

Type: <span ionic-type>bug</span>

Platform: <span ionic-platform>all</span>

<span ionic-description>On line 160: https://github.com/driftyco/ionic/blob/master/js/angular/controller/scrollController.js#L160 it reads the attributes property, but on the line before curElm.offsetParent returns null for me. curElm is being set correctly by the doucment.getElementById above, it just does’t have an offsetParent attribute. And the DOM spec seems to not have it either (in current browser). Is there a missing angular.element somewhere here?</span>

<span is-issue-template></span>

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

Hi!!

I had the same problem, and found that it was caused by $ location.hash (idElement);

The function $ location.hash () creates a map id’s, even the id’s being different pages, it is important that they are unique throughout the project.

I recommend the following use:

In HTML:

<div id="nameView-{{variableId}}> POINT </div>

And in controller function:

` this.scrollTo = function (targetPoint){

$location.hash( 'nameView-' + targetPoint);
$ionicScrollDelegate.anchorScroll(true);    

}`

This work to me!

hi, after the navigation from scroll page to other, page, when i com back to the scroll and i try to scroll the items, its giving the

TypeError: Cannot read property ‘attributes’ of null
please help me thank you.