Open jeme opened 11 years ago
Example usages desired on state:
scrollTo:top
- scroll to top, explicitly stated. (This also enables one to override another scrollTo from a parent)scrollTo:null
- don't scroll, not even to top.scrollTo:@viewname
- scroll to a view.scrollTo:elementid
- scroll to an element idscrollTo:['$stateParams', function($stateParams) { return stateParams.section; }]
- function providing either of the aboveExample usages of $scroll
:
$scroll('element-id')
- scroll to an element id$scroll(200)
- scroll the viewport 200px down$scroll('@viewname')
- scroll to a view$scroll('top')
- scroll to the top$scroll()
- scroll to the top
https://github.com/dotJEM/angular-routing/issues/15 gave an initial implementation for scrolling that relies on an directive on element so scroll to that element.
This is due to the fact that it will be hard to determine when elements are loaded from a "state" perspective and even from a "view" perspective. Therefore it was necessary to provide scrolling at the right time (after DOM loading/rendering).
However, right now we could have duplicated anchors etc. causing for some unpredictable behavior (fairly sure it will go to the last element)
Instead we should just register these elements with the $scroll service so we can detect duplicates etc.