I’m trying to make an auto-tab and auto-scroll controller which automatically takes the user to a specific element in a specific tab based on what time it is.
I was doing this by using $ionicTabsDelegate followed by delegate.scrollBy, however to get my scrollBy properties I need to find where an element is in the page so I used document.getElementByID.
So the code is as follows:
$ionicTabsDelegate.select(tab); element = document.getElementById(current_menu_key).getBoundingClientRect().top; navbar = document.getElementById('navbar').getBoundingClientRect().bottom; scroll = element - navbar; delegate.scrollBy(0, scroll, true);
The second line in the above code gives an error.
It appears that $ionicTabsDelegate has not switched the tab yet so the element I’m looking for isn’t there.
I went to check when my element becomes available and it seems that it doesn’t until after the controller ends.
Does anyone have this same problem? And is there a solution?