google / blockly

The web-based visual programming editor.
https://developers.google.com/blockly/
Apache License 2.0
12.51k stars 3.72k forks source link

Customize the workspace scrollbar margin #8587

Open FranciscoCaetano88 opened 2 months ago

FranciscoCaetano88 commented 2 months ago

Check for duplicates

Problem

No response

Request

I want to add a margin to the workspaces scrollbar to create some space between it and the edges of the viewport.

After examining the Blockly code, I discovered that the ScrollbarPair and Scrollbar constructors can accept an optional margin parameter. The issue is that this optional margin isn't being passed to the new ScrollbarPair in the core/inject module.

ScrollbarPair class: constructor( private workspace: WorkspaceSvg, addHorizontal?: boolean, addVertical?: boolean, opt_class?: string, opt_margin?: number, ) { ... }

core/inject mainWorkspace.scrollbar = new ScrollbarPair( mainWorkspace, horizontalScroll, verticalScroll, 'blocklyMainWorkspaceScrollbar', // missing margin );

A quick fix would be to add this property coming from the scrollbar blockly options.

Alternatives considered

Register a new vertical/horizontal Scrollbar using the registry to override the Scrollbar characteristics or behaviours. Remove the read only keyword from the static property DEFAULT_SCROLLBAR_MARGIN.

Additional context

No response

cpcallen commented 1 month ago

This seems like a useful feature request, but we want to do a bit more investigation of alternative approaches before implementing the proposed change, as we're generally trying to move away from configuration options and use CSS for appearance-related configuration wherever possible.