Skip to content
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

Closed
wants to merge 8 commits into from
14 changes: 14 additions & 0 deletions src/angular-vs-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
// vs-excess="value" - an integer number representing the number of elements to be rendered outside of the current container's viewport
// (defaults to 2)
// vs-size-property - a property name of the items in collection that is a number denoting the element size (in pixels)
// vs-initial-element - an integer for an element index to start scroll position to that element
// vs-autoresize - use this attribute without vs-size-property and without specifying element's size. The automatically computed element style will
// readjust upon window resize if the size is dependable on the viewport size

Expand Down Expand Up @@ -139,6 +140,19 @@
$scope.offsetAfter = 0;
$scope.excess = 2;

$scope.$watch($attrs.vsInitialElement, function(elementIndex){
$scope.goTo(elementIndex);
});

$scope.goTo = function(index){
$scope.$$postDigest(function(){
var scrollPosition = (sizesPropertyExists) ?
($scope.sizesCumulative[index] + $scope.offsetBefore):
(index * $scope.elementSize + $scope.offsetBefore);
$scrollParent[0][scrollPos] = scrollPosition;
});
};

Object.keys(attributesDictionary).forEach(function(key){
if($attrs[key]){
$attrs.$observe(key, function(value){
Expand Down
2 changes: 1 addition & 1 deletion src/angular-vs-repeat.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.