-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Collapse nested variations #15488
Collapse nested variations #15488
Conversation
- Remove the "head" rendered as part of the <lines> element as it doesn't accurately represent where we're branching from - Remove the "tail" that extends past the bottom variation as it's visually unnecessary. This means the height is no longer the same as the parent height, so we need a new <branch> element with variable height. Tested on Firefox & Chrome with inline & column mode in various zoom levels.
The node's "collapse" flag we now treat as a tri-state where "undefined" means to use the default collapse state.
We've added "position: relative" to the <line> elements for styling purposes, but that affects the calculation of the "offsetTop" property. We can instead calculate the offset ourselves.
ui/tree/css/_tree.scss
Outdated
} | ||
|
||
lines lines:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
lines.collapsed > * { | ||
display: none; |
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.
instead of hiding them, can we avoid rendering them altogether? And maybe get some perf gains in deep trees.
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.
Done.
@@ -59,7 +59,8 @@ const autoScroll = throttle(200, (ctrl: AnalyseCtrl, el: HTMLElement) => { | |||
cont.scrollTop = ctrl.path ? 99999 : 0; | |||
return; | |||
} | |||
cont.scrollTop = target.offsetTop - cont.offsetHeight / 2 + target.offsetHeight; | |||
const targetOffset = target.getBoundingClientRect().y - el.getBoundingClientRect().y; |
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 now require 2 calls to getBoundingClientRect
?
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 put a note in the "Fix autoscroll offset" commit, let me copy it here:
We've added "position: relative" to the <line> elements for styling purposes, but that affects the calculation of the "offsetTop" property. We can instead calculate the offset ourselves.
Looking great. |
Thanks for the heads up. |
You have to test it better, though. It's buggy. |
Yes, that's intended. Main lines are not collapsible. And variations expand/collapse as a group, which is certainly debatable but it keeps things simple. |
This is great! |
Deeply nested variations (in studies etc.) can cause visual clutter that make it difficult to navigate through complex trees.
This PR includes some baseline visual changes to the left-side "branch" to improve clarity (before, after):
![](https://private-user-images.githubusercontent.com/3195342/339208362-433d508e-6daf-41d3-a043-90796d59b7ad.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzMzY2OTcsIm5iZiI6MTcyMzMzNjM5NywicGF0aCI6Ii8zMTk1MzQyLzMzOTIwODM2Mi00MzNkNTA4ZS02ZGFmLTQxZDMtYTA0My05MDc5NmQ1OWI3YWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTFUMDAzMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmU5M2MwOTQyZTFhODkzYjE3Njc1YTljMmZiNGRjY2Y1ZjEzMzg1OGI4MmZkMTAyY2I1MjIyOTdkMmUxZmIzMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.hR57-7VoGJcW2mP_jJWK6O0rTJTs07pDaZDoXO-37Sw)
![](https://private-user-images.githubusercontent.com/3195342/339208153-296d193c-0856-40fd-9eea-07dc15e398c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzMzY2OTcsIm5iZiI6MTcyMzMzNjM5NywicGF0aCI6Ii8zMTk1MzQyLzMzOTIwODE1My0yOTZkMTkzYy0wODU2LTQwZmQtOWVlYS0wN2RjMTVlMzk4YzAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTFUMDAzMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjU4Mzk2YzYwZWFjNjRhOGE3NzBiNDJmYTlhYzA1MGNmMGIzZjYzNTg0ODFmMmQxYjQzM2RiN2NjMTYyNzNjZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.fXlLFUwrNAJEQmq4-kI0bfXvMoLYJ4p7lJukoJcNIYM)
On initial load deep variations are now collapsed (depth 3, 5, 7, etc. are collapsed by default). Clicking the + or navigating to the parent move will expand the variations out.
![image](https://private-user-images.githubusercontent.com/3195342/339209125-8beb9c08-f9e3-4c17-ac94-7364e9f4d668.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzMzY2OTcsIm5iZiI6MTcyMzMzNjM5NywicGF0aCI6Ii8zMTk1MzQyLzMzOTIwOTEyNS04YmViOWMwOC1mOWUzLTRjMTctYWM5NC03MzY0ZTlmNGQ2NjgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTFUMDAzMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjgyNDMxODI2N2YzNTAwMTA3NWM1ZDgyOGYyOTI5MzcxNTAxYzQ0ODcxMjY3NDFmMmI5NjAxYzFhYzIzNTM4ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.XQvSEtQlfh1z4j2JRJ0q798y58Ull7NaztDnrqhAIJE)
You can also expand or collapse variations from the context menu:
![image](https://private-user-images.githubusercontent.com/3195342/339209789-9a4ff7cf-946d-40e8-b2a0-4337122a40fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzMzY2OTcsIm5iZiI6MTcyMzMzNjM5NywicGF0aCI6Ii8zMTk1MzQyLzMzOTIwOTc4OS05YTRmZjdjZi05NDZkLTQwZTgtYjJhMC00MzM3MTIyYTQwZmIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTFUMDAzMzE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjZlZDY1ZjYyYzE5MDBlZmU4NjhkZGViYTQ3YWM2NmU2ZWEwN2ZhOWRiZTcwZTYyNjAxMTJiYTU0OWZhZjNkNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Z3BgDyS_wkmwCvd7A9dOk42FvYuSpKQJ1O5FLHpGLLY)
When you do this from the context menu it will operate recursively. So for example if you right-click the first move of the game, it effectively acts as "collapse all" or "expand all". Or you can right-click on a specific variation to just collapse that variation and its siblings.