Skip to content

feat(span-tree): Horizontal autoscrolling on the span tree#34706

Merged
0Calories merged 11 commits into
masterfrom
feat/span-tree-autoscroll
May 25, 2022
Merged

feat(span-tree): Horizontal autoscrolling on the span tree#34706
0Calories merged 11 commits into
masterfrom
feat/span-tree-autoscroll

Conversation

@0Calories

@0Calories 0Calories commented May 17, 2022

Copy link
Copy Markdown
Contributor

This PR adds a new feature to the span tree, that will cause the view to adjust horizontally as the user scrolls down the tree. As a span goes out of the view, it will adjust by shifting all spans to the left so that the spans that are still in the view are given more visibility.

Similarly, if a span that was previously out of view comes back in the view (from the user scrolling up), the tree will readjust the spans to the right.

Demo

Addresses PERF-1429

@0Calories

Copy link
Copy Markdown
Contributor Author

Please approve this PR for the feature flag as well :)

@k-fish

k-fish commented May 18, 2022

Copy link
Copy Markdown
Member

Okay, no comments on the code yet, it mostly looks fine, but I played around with it. It still has a somewhat "boaty" feel, and I noticed depending on how fast you scroll you get inconsistencies (I'll dm you a recording).

Two things:

  • If we want to make it more consistent feeling I'm thinking we should create an 'active view area' and average the X positions of all spans inside it (which stops the random jumps between tree indentations), then the horizontal scroll is always a function of vertical scroll, this is probably the thing that will help it feel less out of sync.
  • We should try to get it so the root span is always in view at a certain point of scrolling in the page (like when the page begins), maybe with some sort of biasing or using the page offset of the container.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
src/sentry/static/sentry/dist/entrypoints/app.js 61.66 KB (-0.29% 🔽)
src/sentry/static/sentry/dist/entrypoints/sentry.css 69.93 KB (0%)

@k-fish k-fish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! I pulled and tried locally and aside from the small bug I dm'd you, I think this is good enough to try out. No need to over-optimize, we can tune it more later or if we get feedback.

return;
}

const left = this.spansInView.getScrollVal();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you might want to calc left inside the performScroll since it would be the most up to date there? It might not matter functionally though, it does save calling it twice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, this makes sense, but performScroll would have to be restructured since it's also being used for the manual scrolling/wheeling. As you said functionally it wouldn't make a difference, and I think it would require some unnecessary effort to facilitate it

Comment on lines +489 to +512
startAnimation() {
selectRefs(this.contentSpanBar, (spanBarDOM: HTMLDivElement) => {
spanBarDOM.style.transition = 'transform 0.3s';
});

if (this.animationTimeout) {
clearTimeout(this.animationTimeout);
}

// This timeout is set to trigger immediately after the animation ends, to disable the animation.
// The animation needs to be cleared, otherwise manual horizontal scrolling will be animated
this.animationTimeout = setTimeout(() => {
selectRefs(this.contentSpanBar, (spanBarDOM: HTMLDivElement) => {
spanBarDOM.style.transition = '';
});
this.animationTimeout = null;
}, 300);
}

disableAnimation() {
selectRefs(this.contentSpanBar, (spanBarDOM: HTMLDivElement) => {
spanBarDOM.style.transition = '';
});
}

Copy link
Copy Markdown
Member

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 any of this, just put a static transition: transform 0.3s; on the element style wherever it is defined, it's okay if it's css animating during wheel movements, it won't look that weird I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@k-fish It actually makes it quite obnoxious to use unfortunately, I gave it a try when I first set this up lol

@0Calories 0Calories merged commit bbadcbb into master May 25, 2022
@0Calories 0Calories deleted the feat/span-tree-autoscroll branch May 25, 2022 13:15
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 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.

2 participants