-
Notifications
You must be signed in to change notification settings - Fork 354
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
Improve footer tracking for bottom scroll indicator #873
Improve footer tracking for bottom scroll indicator #873
Conversation
…leod.temp/improve-bottom-scroll-indicator-tracking
97e11b5
to
5e9f9df
Compare
5e9f9df
to
ffa0efa
Compare
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.
The code change looks fine. Could you explain your approach?
@@ -269,6 +317,12 @@ export default Component.extend({ | |||
|
|||
didInsertElement() { | |||
this._super(...arguments); | |||
|
|||
// debounced, runloop-safe version | |||
this._updateIndicators = bind(this, () => { |
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 do we need bind
here?
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.
I think that's a leftover, let's nix it.
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.
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.
Two more questions on this topic:
- Why do we set
this._updateIndicators
insidedidInsertElement
vs.init
? - Are there any issues with using an anonymous function vs. a function defined on the component?
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.
-
No objection; consider it moved.
-
Not afaik. Anything we move to a component function is ultimately going to have to be wrapped in a
bind
or something that produces an anonymous function anyway. This forward declaration does a lot of heavy lifting:
- Context binding for a scroll listener, two
ResizeSensor
s, and aMutationObserver
- Deals with the test runloop situation
- Encapsulates the
scheduleOnce
- Simplifies removing the scroll listener on teardown; don't have to cache a
this._scrollListener
function
What we can do is dump the bind
for a run
. The context is already available via the anonymous closure, so run
is a more precise solution to its problem and can be documented as such.
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.
run
won't cut it for ember-2.8-lts
test suite. I've notated the seemingly redundant bind
for now; we can visit when we drop 2.8 support.
This reverts commit e2da2e9.
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.
Left a comment. Provisional ✅
@@ -269,6 +317,12 @@ export default Component.extend({ | |||
|
|||
didInsertElement() { | |||
this._super(...arguments); | |||
|
|||
// debounced, runloop-safe version | |||
this._updateIndicators = bind(this, () => { |
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.
Two more questions on this topic:
- Why do we set
this._updateIndicators
insidedidInsertElement
vs.init
? - Are there any issues with using an anonymous function vs. a function defined on the component?
In order to position the bottom scroll indicator correctly, we need to know if and when the visible portion of the footer changes height. Presently, we detect when the dimensions of the table's container changes, but not specifically when the height of the footer, or the position of its sticky cells, change. These changes can occur without altering the overall height or width of the table, which can leave the bottom scroll indicator floating in the wrong position.
So far this has only been a problem in testing environments, where it manifests as an erratic race condition during initial render. It is exacerbated by increased functionality in the footer (e.g. child rows), because of increased jostling during layout. During a typical application pageload, there are sufficiently many layout changes that the effect is rarely seen.
Since it is possible to programmatically add and remove a footer from the table, we install and remove those listeners dynamically.
Changes:
ResizeSensor
on footer to detect changes in total footer heightMutationObserver
on footer to detect changes to thestyle
attribute oftd
elements; we are interested in whenbottom
changes value