-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding initial page feature #8
Conversation
}); | ||
|
||
$scope.goTo = function(index){ | ||
setTimeout(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is setTimeout needed here? maybe $scope.$$postDigest
would be enough if any delay of execution at all. What happens if the setTimeout is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, $$postDigest might solve the problem, it was just a hacky setTimeout Zero just to run scrollTop after content loaded, waiting all DOM negotiation finishes before scrollTop, or parent height would be 0px.
I'll note this as many others under the hood and not documented useful angular features found.
…ll height checkiing if sizesPropertyExist, all noted from original author (@kamilkp)
var scrollPosition = (sizesPropertyExists) ? | ||
($scope.sizesCumulative[index] + $scope.offsetBefore): | ||
(index * $scope.elementSize + $scope.offsetBefore); | ||
$scrollParent[0].scrollTop = scrollPosition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing. This assumes that we are using vertically stacked element. Whereas vs-repeat also supports scrolling horizontally. Instead of referencing scrollTop
use the scrollPos
variable that i declare in the linking function.
Hi there,
I work at Lumis [http://www.lumis.com.br] and here we'll start to use a fork of your code to our publications viewer app, whose nickname is Poligno. We found useful to set an initial scroll to an element, so I'm sending you this pull request to thank you for your code and collaborate too.
Best regards,
=P