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

Update: Scroll into view #906

Merged
merged 6 commits into from
Feb 1, 2019

Conversation

ConradJChan
Copy link
Contributor

@ConradJChan ConradJChan commented Jan 28, 2019

TODO:

  • Test in IE & Edge
  • Add Unit tests

scroll into view

@boxcla
Copy link

boxcla commented Jan 28, 2019

Verified that @ConradJChan has signed the CLA. Thanks for the pull request!

@ConradJChan ConradJChan changed the title Scoll into view Update: Scroll into view Jan 28, 2019
Copy link
Contributor

@jeremypress jeremypress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, will approve after tests.

if (foundItem) {
// If it is already present and visible, do nothing, but if not visible
// then scroll it into view
if (!this.isVisible(foundItem)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it that bad to call scrollIntoView even the thumbnail is already visible? that would allow you to get rid of isVisible and it could be kind of nice to top align the thumbnail even if it's already visible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not necessarily bad, but since cross browser support for the "smooth" scrollIntoView is not there, I was trying to avoid the slight jumpiness it causes IMO. I can show you tomorrow to see what you think

this.renderNextThumbnailImage = this.renderNextThumbnailImage.bind(this);
this.requestThumbnailImage = this.requestThumbnailImage.bind(this);
this.thumbnailClickHandler = this.thumbnailClickHandler.bind(this);
this.toggle = this.toggle.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to bind these

const { scrollTop } = this.scrollingEl;
const { offsetTop } = listItemEl;

return scrollTop <= offsetTop && offsetTop <= scrollTop + this.containerHeight;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a () around scrollTop + this.containerHeight? Reading this I saw
scrollTop <= offsetTop && offsetTop <= scrollTop first 😮

* @return {void}
*/
toggle() {
if (!this.anchorEl) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're already checking for anchorEl in each function below you could remove this , if you want

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I can because if there is no anchorEl, then isOpen will return false and it will attempt to invoke toggleOpen

Copy link
Contributor

@DanDeMicco DanDeMicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor feedback. Make sure to verify with the startAt option

return;
}

if (!this.isOpen()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably just use classList.toggle

@ConradJChan ConradJChan merged commit 851f455 into box:thumbnails-sidebar Feb 1, 2019
@ConradJChan ConradJChan deleted the scoll-into-view branch February 1, 2019 22:33
ConradJChan pushed a commit that referenced this pull request Feb 1, 2019
ConradJChan pushed a commit that referenced this pull request Feb 5, 2019
ConradJChan pushed a commit to ConradJChan/box-content-preview that referenced this pull request Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants