-
Notifications
You must be signed in to change notification settings - Fork 107
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
Fixed row height optimization #221
base: fixed-height-optimization
Are you sure you want to change the base?
Changes from 1 commit
61cb0cc
bedd378
71c2f33
8f4bece
551bff3
43561dd
d183273
62c8bc6
fdcca3d
b1be940
45a8387
95a6d4a
359d905
b174ffc
0b62060
bbc1a74
dd3bdfc
3cff84e
07e7047
9c26d38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ angular.module('ui.scroll', []) | |
// | ||
const rowHeight = parseNumericAttr($attr.rowHeight, null, false); | ||
|
||
// PHIL: Read the visibility watch option, true by default | ||
const allowVisibilityWatch = $attr.allowVisibilityWatch!=='false'; | ||
|
||
// Revision IDs | ||
// | ||
let ridActual = 0; // current data revision id | ||
|
@@ -259,7 +262,7 @@ angular.module('ui.scroll', []) | |
} | ||
|
||
function isElementVisible(wrapper) { | ||
return wrapper.element.height() && wrapper.element[0].offsetParent; | ||
return (rowHeight || wrapper.element.height()) && wrapper.element[0].offsetParent; | ||
} | ||
|
||
function visibilityWatcher(wrapper) { | ||
|
@@ -278,10 +281,10 @@ angular.module('ui.scroll', []) | |
|
||
function insertWrapperContent(wrapper, insertAfter) { | ||
createElement(wrapper, insertAfter, viewport.insertElement); | ||
if (!rowHeight && !isElementVisible(wrapper)) { | ||
if (allowVisibilityWatch && !isElementVisible(wrapper)) { | ||
wrapper.unregisterVisibilityWatcher = wrapper.scope.$watch(() => visibilityWatcher(wrapper)); | ||
} | ||
if (!rowHeight) { | ||
if (allowVisibilityWatch) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This particular case, I mean hiding the elements before data binding, is not related to visibility-watcher. I would say that it may relate to rowHeight. We are hiding new rows before data binding, because the height might change after binding, and there could be some bad side effects (scroll bar shifting). And we may not hide new rows if we know that the height is not going to be changed. |
||
elementRoutines.hideElement(wrapper); // hide inserted elements before data binding | ||
} | ||
} | ||
|
@@ -397,7 +400,7 @@ angular.module('ui.scroll', []) | |
// We need the item bindings to be processed before we can do adjustments | ||
!$scope.$$phase && !$rootScope.$$phase && $scope.$digest(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @priandsf This is the bottleneck of the new demo (http://localhost:5005/fixedRowHeight/fixedRowHeight.html). And this $digest can't be removed, it responses for manual data-binding and transforming a row template into final html with all the data and handlers. Running the demo, you'll see that removing this $digest breaks the demo app. From the other hand, I didn't see any significant difference in the performance with and without rowHeight (if don't touch this $digest). Probably the demo is not good, and I would ask you to update it if you can. The demo must show a difference with and without rowHeight. But if this particular $digest is the only call that "can" improve situation, then I would say probably we are on the wrong way. I don't see a situation where this $digest can be removed. So, please look at the demo, try to reproduce performance changing and let me know, what do you think. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you're right, commenting $digest in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @priandsf Answering to your question, I'm not sure about resizeAndScrollHandler $digest, I need some time to investigate it. But the question I would like to consider before is what we are going to improve? Browser reflow problem resulting from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough - So far, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @priandsf I have an answer on why do we need $digest in the end of One of the possible solutions is to html attribute for disable top/bottomVisible properties calculation/propagation + maybe adapter methods to enable/disable this feature runtime, and even the adapter method to calculate top/bottomVisible data immediately. So, users that don't need top/bottomVisible data (or don't need it right now) can switch this functionality off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the investigation, that makes sense. The flag will work for me, although it might complicate the developer experience as understanding the attribute requires a deep knowledge of the internals. Based on our performance result, it is fine for me if we postpone that change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dhilt I believe I got a solution for the $digest: the adapter checks if the directive has any of these attributes (top-visible, ...) defined and publishes it as a public property. Then the ui-scroll checks this property to know if it has to trigger the $digest. |
||
|
||
if (!rowHeight) { | ||
if (allowVisibilityWatch) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Showing new rows after binding relates to hiding new rows before binding. So it does not relate to visibility-watcher, it may relate to rowHeight (see previous comment). |
||
updates.inserted.forEach(w => elementRoutines.showElement(w)); | ||
updates.prepended.forEach(w => elementRoutines.showElement(w)); | ||
} | ||
|
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.
switched to camelcase, which means
row-height="20"
usage