Skip to content

Commit

Permalink
fix: fix positioning of categories when scrolling via the toolbox (#186)
Browse files Browse the repository at this point in the history
* fix: fix positioning of categories when scrolling via the toolbox

* refactor: use GRID_UNIT for calculating flyout alignment
  • Loading branch information
gonfunko authored Sep 18, 2024
1 parent 6c9d3a6 commit 6d14530
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/checkable_continuous_flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ export class CheckableContinuousFlyout extends ContinuousFlyout {
this.checkboxes_.clear();
}

layout_(contents, gaps) {
super.layout_(contents, gaps);
// We want large gaps between categories (see GAP_Y), but don't want those
// counted as part of the category for purposes of scrolling to show the
// category, so we reset/adjust the label gaps used for the scroll position
// calculation here.
this.labelGaps.fill(
this.getWorkspace().getRenderer().getConstants().GRID_UNIT
);
}

calculateBottomPadding(contentMetrics, viewMetrics) {
// Since we're messing with the alignment by munging the label gaps, we also
// need to adjust the bottom padding.
return (
super.calculateBottomPadding(contentMetrics, viewMetrics) -
this.getWorkspace().getRenderer().getConstants().GRID_UNIT * 4
);
}

addBlockListeners_(root, block, rect) {
if (block.checkboxInFlyout) {
const coordinates = block.getRelativeToSurfaceXY();
Expand Down

0 comments on commit 6d14530

Please # to comment.