Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
alarie committed Jan 19, 2022
1 parent 4ca8454 commit cfda948
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 31 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '9.x'
- name: Install dependencies
run: yarn ci
- run: yarn run build --if-present
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"workbench.colorCustomizations": {
"[Default Light+]": {
"colorizer.color-1": "#ff9900",
"colorizer.color-2": "#f500f5",
"colorizer.color-3": "#54b9f8"
},
"colorizer.color-1": "#ffd700",
"colorizer.color-2": "#da70d6",
"colorizer.color-3": "#87cefa",
"activityBar.background": "#2E3001",
"titleBar.activeBackground": "#414301",
"titleBar.activeForeground": "#FBFEC1"
}
}
63 changes: 32 additions & 31 deletions src/multipane.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const LAYOUT_HORIZONTAL = 'horizontal';
const LAYOUT_VERTICAL = 'vertical';
const LAYOUT_HORIZONTAL = "horizontal";
const LAYOUT_VERTICAL = "vertical";

export default {
name: 'multipane',
name: "multipane",

props: {
layout: {
Expand All @@ -20,42 +20,43 @@ export default {
computed: {
classnames() {
return [
'multipane',
'layout-' + this.layout.slice(0, 1),
this.isResizing ? 'is-resizing' : '',
"multipane",
"layout-" + this.layout.slice(0, 1),
this.isResizing ? "is-resizing" : "",
];
},
cursor() {
return this.isResizing
? this.layout == LAYOUT_VERTICAL ? 'col-resize' : 'row-resize'
: '';
? this.layout == LAYOUT_VERTICAL
? "col-resize"
: "row-resize"
: "";
},
userSelect() {
return this.isResizing ? 'none' : '';
return this.isResizing ? "none" : "";
},
},

methods: {
onMouseDown({ target: resizer, pageX: initialPageX, pageY: initialPageY }) {

if (resizer.className && resizer.className.match('multipane-resizer')) {

if (
typeof resizer.className === "string" &&
resizer.className.match("multipane-resizer")
) {
// for stacked panes, make sure only the direct parent of the
// resizer acts
if (resizer.parentElement !== this.$el) {
return
return;
}

let self = this;
let { $el: container, layout } = self;

let pane = resizer.previousElementSibling;
let {
offsetWidth: initialPaneWidth,
offsetHeight: initialPaneHeight,
} = pane;
let { offsetWidth: initialPaneWidth, offsetHeight: initialPaneHeight } =
pane;

let usePercentage = !!(pane.style.width + '').match('%');
let usePercentage = !!(pane.style.width + "").match("%");

const { addEventListener, removeEventListener } = window;

Expand All @@ -65,17 +66,17 @@ export default {
let paneWidth = initialSize + offset;

return (pane.style.width = usePercentage
? paneWidth / containerWidth * 100 + '%'
: paneWidth + 'px');
? (paneWidth / containerWidth) * 100 + "%"
: paneWidth + "px");
}

if (layout == LAYOUT_HORIZONTAL) {
let containerHeight = container.clientHeight;
let paneHeight = initialSize + offset;

return (pane.style.height = usePercentage
? paneHeight / containerHeight * 100 + '%'
: paneHeight + 'px');
? (paneHeight / containerHeight) * 100 + "%"
: paneHeight + "px");
}
};

Expand All @@ -86,18 +87,18 @@ export default {
let size = resize();

// Trigger paneResizeStart event
self.$emit('paneResizeStart', pane, resizer, size);
self.$emit("paneResizeStart", pane, resizer, size);

const onMouseMove = function({ pageX, pageY }) {
const onMouseMove = function ({ pageX, pageY }) {
size =
layout == LAYOUT_VERTICAL
? resize(initialPaneWidth, pageX - initialPageX)
: resize(initialPaneHeight, pageY - initialPageY);

self.$emit('paneResize', pane, resizer, size);
self.$emit("paneResize", pane, resizer, size);
};

const onMouseUp = function() {
const onMouseUp = function () {
// Run resize one more time to set computed width/height.

size =
Expand All @@ -108,14 +109,14 @@ export default {
// This removes is-resizing class to container
self.isResizing = false;

removeEventListener('mousemove', onMouseMove);
removeEventListener('mouseup', onMouseUp);
removeEventListener("mousemove", onMouseMove);
removeEventListener("mouseup", onMouseUp);

self.$emit('paneResizeStop', pane, resizer, size);
self.$emit("paneResizeStop", pane, resizer, size);
};

addEventListener('mousemove', onMouseMove);
addEventListener('mouseup', onMouseUp);
addEventListener("mousemove", onMouseMove);
addEventListener("mouseup", onMouseUp);
}
},
},
Expand Down

0 comments on commit cfda948

Please sign in to comment.