Skip to content

Commit 79ca7e9

Browse files
committed
Made side-panel resizable
1 parent 39c92c4 commit 79ca7e9

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

packages/perspective-viewer/src/html/viewer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
</div>
3232
<perspective-computed-column></perspective-computed-column>
3333
</div>
34+
<div id="resize_bar"></div>
3435
</div>
3536
<div class="column noselect">
3637
<div id='top_panel'>

packages/perspective-viewer/src/js/viewer/action_element.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,18 @@ export class ActionElement extends DomElement {
198198
this.setAttribute("column-pivots", row_pivots);
199199
}
200200

201+
_resize_sidepanel() {
202+
const resize = event => {
203+
this._side_panel.style.width = `${event.clientX}px`;
204+
};
205+
const stop = () => {
206+
document.removeEventListener("mousemove", resize);
207+
document.removeEventListener("mouseup", stop);
208+
};
209+
document.addEventListener("mousemove", resize);
210+
document.addEventListener("mouseup", stop);
211+
}
212+
201213
// most of these are drag and drop handlers - how to clean up?
202214
_register_callbacks() {
203215
this._sort.addEventListener("drop", drop.bind(this));
@@ -236,6 +248,7 @@ export class ActionElement extends DomElement {
236248
this._download_button.addEventListener("click", event => this.download(event.shiftKey));
237249
this._transpose_button.addEventListener("click", this._transpose.bind(this));
238250
this._drop_target.addEventListener("dragover", dragover.bind(this));
251+
this._resize_bar.addEventListener("mousedown", this._resize_sidepanel.bind(this));
239252

240253
this._vis_selector.addEventListener("change", () => {
241254
this.setAttribute("plugin", this._vis_selector.value);

packages/perspective-viewer/src/js/viewer/dom_element.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export class DomElement extends PerspectiveElement {
270270
this._plugin_information_action = this.shadowRoot.querySelector(".plugin_information__action");
271271
this._plugin_information_dismiss = this.shadowRoot.querySelector(".plugin_information__action--dismiss");
272272
this._plugin_information_message = this.shadowRoot.querySelector("#plugin_information_count");
273+
this._resize_bar = this.shadowRoot.querySelector("#resize_bar");
273274
}
274275

275276
// sets state, manipulates DOM

packages/perspective-viewer/src/less/viewer.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
}
414414
}
415415
#side_panel {
416+
position: relative;
416417
flex: 0 0 auto;
417418
padding: var(--side_panel--padding, 10px 10px 0px 11px);
418419
}
@@ -438,4 +439,13 @@
438439
color: var(--button-hover--color, inherit);
439440
}
440441
}
442+
443+
#resize_bar {
444+
position: absolute;
445+
top: 0;
446+
right: 0;
447+
bottom: 0;
448+
width: 8px;
449+
cursor: col-resize;
450+
}
441451
}

0 commit comments

Comments
 (0)