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

fix: updating scrollview reseting scroll position #223

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions dist/famous-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -5592,7 +5592,9 @@ angular.module('famous.angular')

$famousDecorator.addRole('renderable',isolate);
isolate.show();


isolate.renderNode.viewSeq = [];
isolate.renderNode.sequenceFrom(isolate.renderNode.viewSeq);

var updateScrollview = function(init){
// Synchronize the update on the next digest cycle
Expand All @@ -5602,23 +5604,14 @@ angular.module('famous.angular')
_children.sort(function(a, b){
return a.index - b.index;
});

var options = {
array: function(_children) {
var _ch = [];
angular.forEach(_children, function(c, i) {
_ch[i] = c.renderGate;
});
return _ch;
}(_children)
};
//set the first page on the scrollview if
//specified
if(init)
options.index = scope.$eval(attrs.faStartIndex);

var viewSeq = new ViewSequence(options);
isolate.renderNode.sequenceFrom(viewSeq);

angular.forEach(_children, function(c, i) {
if (!isolate.renderNode.viewSeq[i] || isolate.renderNode.viewSeq[i] !== c.renderGate) {
isolate.renderNode.viewSeq[i] = c.renderGate;
}
});

isolate.renderNode.viewSeq.length = _children.length;
});
};

Expand All @@ -5634,11 +5627,13 @@ angular.module('famous.angular')
angular.forEach(_children, function(c) {
if (c.id !== childScopeId) {
_ch.push(c);
} else {
isolate.renderNode.viewSeq.splice(i, 1);
}
});
return _ch;
}(_children);
updateScrollview();
isolate.renderNode.viewSeq.length = _children.length;
},
updateScrollview
);
Expand Down
2 changes: 1 addition & 1 deletion dist/famous-angular.min.js

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions src/scripts/directives/fa-scrollview.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ angular.module('famous.angular')

$famousDecorator.addRole('renderable',isolate);
isolate.show();


isolate.renderNode.viewSeq = new ViewSequence();
isolate.renderNode.sequenceFrom(isolate.renderNode.viewSeq);

var updateScrollview = function(init){
// Synchronize the update on the next digest cycle
Expand All @@ -288,23 +290,18 @@ angular.module('famous.angular')
_children.sort(function(a, b){
return a.index - b.index;
});

var options = {
array: function(_children) {
var _ch = [];
angular.forEach(_children, function(c, i) {
_ch[i] = c.renderGate;
});
return _ch;
}(_children)
};

angular.forEach(_children, function(c, i) {
if (!isolate.renderNode.viewSeq._.array[i] || isolate.renderNode.viewSeq._.array[i] !== c.renderGate) {
isolate.renderNode.viewSeq._.array[i] = c.renderGate;
}
});

isolate.renderNode.viewSeq._.array.length = _children.length;
//set the first page on the scrollview if
//specified
if(init)
options.index = scope.$eval(attrs.faStartIndex);

var viewSeq = new ViewSequence(options);
isolate.renderNode.sequenceFrom(viewSeq);
isolate.renderNode.viewSeq.index = scope.$eval(attrs.faStartIndex) || 0;
});
};

Expand All @@ -317,14 +314,16 @@ angular.module('famous.angular')
function(childScopeId) {
_children = function(_children) {
var _ch = [];
angular.forEach(_children, function(c) {
angular.forEach(_children, function(c, i) {
if (c.id !== childScopeId) {
_ch.push(c);
} else {
isolate.renderNode.viewSeq.splice(i, 1);
}
});
return _ch;
}(_children);
updateScrollview();
isolate.renderNode.viewSeq.length = _children.length;
},
updateScrollview
);
Expand Down
1 change: 0 additions & 1 deletion test/directives/faScrollViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe('faScrollView', function() {
var scrollView = $famous.find('fa-scroll-view')[0].renderNode;

// The watcher resolves view sequencing
expect(scrollView._node).toBeNull();
$scope.$apply();
expect(scrollView._node.index).toBe(0);

Expand Down