Skip to content

Commit f0f8cba

Browse files
committed
Make handle size configurable
1 parent 837efe9 commit f0f8cba

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/vscode-split-layout/vscode-split-layout.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {styleMap} from 'lit/directives/style-map.js';
55
import {VscElement} from '../includes/VscElement.js';
66
import styles from './vscode-split-layout.styles.js';
77

8-
const HANDLE_SIZE = 4;
9-
108
/**
119
* @cssprop [--hover-border=var(--vscode-sash-hoverBorder)]
1210
*/
@@ -20,6 +18,12 @@ export class VscodeSplitLayout extends VscElement {
2018
@property({type: Boolean, reflect: true, attribute: 'reset-on-dbl-click'})
2119
resetOnDblClick = false;
2220

21+
/**
22+
* Controls the draggable area size in pixels. it is recommended to use the value of `workbench.sash.size`.
23+
*/
24+
@property({type: Number, reflect: true, attribute: 'handle-size'})
25+
handleSize = 4;
26+
2327
@property({attribute: 'initial-position'})
2428
initialPosition = '50%';
2529

@@ -132,7 +136,7 @@ export class VscodeSplitLayout extends VscElement {
132136
this._isDragActive = false;
133137
window.removeEventListener('mouseup', this._handleMouseUp);
134138
window.removeEventListener('mousemove', this._handleMouseMove);
135-
}
139+
};
136140

137141
private _handleMouseMove = (event: MouseEvent) => {
138142
const {clientX, clientY} = event;
@@ -169,7 +173,7 @@ export class VscodeSplitLayout extends VscElement {
169173
this._startPaneBottom = startPaneBottomPercentage;
170174
this._endPaneTop = this._handleTop;
171175
}
172-
}
176+
};
173177

174178
private _handleDblClick() {
175179
if (!this.resetOnDblClick) {
@@ -196,13 +200,13 @@ export class VscodeSplitLayout extends VscElement {
196200
};
197201

198202
if (this.split === 'vertical') {
199-
handleStylesPropObj.marginLeft = `${0 - HANDLE_SIZE / 2}px`;
200-
handleStylesPropObj.width = `${HANDLE_SIZE}px`;
203+
handleStylesPropObj.marginLeft = `${0 - this.handleSize / 2}px`;
204+
handleStylesPropObj.width = `${this.handleSize}px`;
201205
}
202206

203207
if (this.split === 'horizontal') {
204-
handleStylesPropObj.height = `${HANDLE_SIZE}px`;
205-
handleStylesPropObj.marginTop = `${0 - HANDLE_SIZE / 2}px`;
208+
handleStylesPropObj.height = `${this.handleSize}px`;
209+
handleStylesPropObj.marginTop = `${0 - this.handleSize / 2}px`;
206210
}
207211

208212
const handleStyles = styleMap(handleStylesPropObj);

0 commit comments

Comments
 (0)