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

feat(spans): Allow horizontal scrolling on left pane of span view #34006

Merged
merged 18 commits into from
May 12, 2022

Conversation

dashed
Copy link
Member

@dashed dashed commented Apr 27, 2022

We make use of the Wheel event to let users use the trackpad to horizontally scroll the span view on the left pane (span tree):

Kapture.2022-04-27.at.10.56.25.mp4

This should be substantially simpler than a previous implementation of this in #22504

Caveats:

@dashed dashed self-assigned this Apr 27, 2022
@0Calories 0Calories self-assigned this May 9, 2022
clearTimeout(this.wheelTimeout);
}

this.wheelTimeout = setTimeout(() => (this.isWheeling = false), 200);
Copy link
Member

@0Calories 0Calories May 11, 2022

Choose a reason for hiding this comment

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

I unfortunately do not think there is any other way to do this aside from using setTimeout, since there is no onWheelEnd event or anything of the sort

Copy link
Member Author

Choose a reason for hiding this comment

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

@0Calories you'll also need to do this.wheelTimeout = null within the timeout callback.

Copy link
Member

Choose a reason for hiding this comment

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

Oh true 👍

@0Calories
Copy link
Member

Just realized I forgot something: I need to add the event listener to spanGroupBar as well

Copy link
Member

@k-fish k-fish left a comment

Choose a reason for hiding this comment

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

Neat!

this.wheelTimeout = null;
}, 200);

const interactiveLayerRefDOM = this.props.interactiveLayerRef.current!;
Copy link
Member

Choose a reason for hiding this comment

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

!

Copy link
Member

Choose a reason for hiding this comment

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

I think it's safe to assume it's not null/undefined here, since the wheel event shouldn't be able to occur otherwise

Comment on lines +271 to +297
// Update scroll position of the virtual scroll bar
selectRefs(this.scrollBarArea, (scrollBarAreaDOM: HTMLDivElement) => {
selectRefs(this.virtualScrollbar, (virtualScrollbarDOM: HTMLDivElement) => {
const scrollBarAreaRect = scrollBarAreaDOM.getBoundingClientRect();
const virtualScrollbarPosition = scrollLeft / scrollBarAreaRect.width;

const virtualScrollBarRect = rectOfContent(virtualScrollbarDOM);
const maxVirtualScrollableArea =
1 - virtualScrollBarRect.width / interactiveLayerRect.width;

const virtualLeft =
clamp(virtualScrollbarPosition, 0, maxVirtualScrollableArea) *
interactiveLayerRect.width;

virtualScrollbarDOM.style.transform = `translate3d(${virtualLeft}px, 0, 0)`;
virtualScrollbarDOM.style.transformOrigin = 'left';
});
});

// Update scroll positions of all the span bars
selectRefs(this.contentSpanBar, (spanBarDOM: HTMLDivElement) => {
const left = -scrollLeft;

spanBarDOM.style.transform = `translate3d(${left}px, 0, 0)`;
spanBarDOM.style.transformOrigin = 'left';
});
};
Copy link
Member

Choose a reason for hiding this comment

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

There is likely a ref-less solution to this or at least less transform changes, but we can try this out for now and measure perf on production to decide whether / how to fix it.

Co-authored-by: Kev <6111995+k-fish@users.noreply.github.com>
@0Calories 0Calories merged commit 1894ff2 into master May 12, 2022
@0Calories 0Calories deleted the wheel-scroll-spanbar branch May 12, 2022 16:31
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants