Skip to content

Fix #15 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,202 changes: 12,201 additions & 1 deletion demo/main.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions demo/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import VerticalPanes from './VerticalPanes.vue';
import HorizontalPanes from './HorizontalPanes.vue';
import CustomResizer from './CustomResizer.vue';
import CombinedVerticalHorizontalPanes from './CombinedVerticalHorizontalPanes.vue';

export default {
components: {
VerticalPanes,
HorizontalPanes,
CustomResizer,
CombinedVerticalHorizontalPanes,
},
};
13 changes: 13 additions & 0 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
<CustomResizer></CustomResizer>
</div>
</section>
<section class="hero">
<div class="hero-body">
<div class="columns">
<div class="column">
<h2 class="title">Combined Vertical and Horizontal Panes</h2>
</div>
<div class="column is-narrow">
<a href="https://github.com/yansern/vue-multipane/blob/master/demo/src/CombinedVerticalHorizontalPanes.vue" class="button is-warning">View code &raquo;</a>
</div>
</div>
<CombinedVerticalHorizontalPanes></CombinedVerticalHorizontalPanes>
</div>
</section>
</div>
</template>

Expand Down
66 changes: 66 additions & 0 deletions demo/src/CombinedVerticalHorizontalPanes.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<multipane layout="vertical" class="container">
<div class="left">
<h6 class="title is-6">Pane 1</h6>
</div>
<multipane-resizer></multipane-resizer>
<multipane layout="horizontal" class="right">
<div class="top">
<h6 class="title is-6">Pane 2</h6>
</div>
<multipane-resizer></multipane-resizer>
<div class="bottom">
<h6 class="title is-6">Pane 3</h6>
</div>
</multipane>
</multipane>
</template>

<script>
import { Multipane, MultipaneResizer } from '@/src';

export default {
components: {
Multipane,
MultipaneResizer,
},
};
</script>

<style>
.container {
height: 600px;
width: 100%;
}

.left {
width: 50%;
min-width: 20%;
max-width: 80%;
height: 600px;
border: 1px solid #ccc;
background: #eee;
}

.right {
flex-grow: 1;
height: 600px;
border: 1px solid #ccc;
background: #eee;
}

.top {
height: 300px;
min-height: 20%;
max-height: 80%;
width: 100%;
border: 1px solid #ccc;
background: #eee;
}
.bottom {
flex-grow: 1;
width: 100%;
border: 1px solid #ccc;
background: #eee;
}
</style>
2 changes: 1 addition & 1 deletion dist/vue-multipane.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions dist/vue-multipane.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var __vue_module__ = {
var initialPageY = ref.pageY;

if (resizer.className && resizer.className.match('multipane-resizer')) {
if (resizer.parentElement !== this.$el) { return; }
var self = this;
var container = self.$el;
var layout = self.layout;
Expand Down Expand Up @@ -86,7 +87,10 @@ var __vue_module__ = {
self.isResizing = true;

// Resize once to get current computed size
var size = resize();
// let size = resize();
var size = (layout == LAYOUT_VERTICAL
? resize(initialPaneWidth)
: resize(initialPaneHeight));

// Trigger paneResizeStart event
self.$emit('paneResizeStart', pane, resizer, size);
Expand All @@ -95,20 +99,18 @@ var __vue_module__ = {
var pageX = ref.pageX;
var pageY = ref.pageY;

size =
layout == LAYOUT_VERTICAL
var size = (layout == LAYOUT_VERTICAL
? resize(initialPaneWidth, pageX - initialPageX)
: resize(initialPaneHeight, pageY - initialPageY);
: resize(initialPaneHeight, pageY - initialPageY));

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

var onMouseUp = function() {
// Run resize one more time to set computed width/height.
size =
layout == LAYOUT_VERTICAL
? resize(pane.clientWidth)
: resize(pane.clientHeight);
var size = (layout == LAYOUT_VERTICAL
? resize(pane.clientWidth)
: resize(pane.clientHeight));

// This removes is-resizing class to container
self.isResizing = false;
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-multipane.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:prod": "cross-env rollup -c rollup.config.prod.js",
"build:dev": "cross-env rollup -c rollup.config.dev.js",
"build:esm": "cross-env rollup -c rollup.config.esm.js",
"build:demo": "cross-env NODE_ENV=production webpack --progress --hide-modules --env.entry=demo --config=node_modules/laravel-mix/setup/webpack.config.js",
"build:demo": "cross-env NODE_ENV=development webpack --progress --hide-modules --env.entry=demo --config=node_modules/laravel-mix/setup/webpack.config.js",
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --inline --env.entry=demo --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"license": "MIT",
Expand Down
18 changes: 10 additions & 8 deletions src/multipane.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
methods: {
onMouseDown({ target: resizer, pageX: initialPageX, pageY: initialPageY }) {
if (resizer.className && resizer.className.match('multipane-resizer')) {
if (resizer.parentElement !== this.$el) return;
let self = this;
let { $el: container, layout } = self;

Expand Down Expand Up @@ -75,26 +76,27 @@ export default {
self.isResizing = true;

// Resize once to get current computed size
let size = resize();
// let size = resize();
let size = (layout == LAYOUT_VERTICAL
? resize(initialPaneWidth)
: resize(initialPaneHeight));

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

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

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

const onMouseUp = function() {
// Run resize one more time to set computed width/height.
size =
layout == LAYOUT_VERTICAL
? resize(pane.clientWidth)
: resize(pane.clientHeight);
let size = (layout == LAYOUT_VERTICAL
? resize(pane.clientWidth)
: resize(pane.clientHeight));

// This removes is-resizing class to container
self.isResizing = false;
Expand Down