Skip to content
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

Fix #17 #18

Open
wants to merge 4 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,447 changes: 12,446 additions & 1 deletion demo/main.js

Large diffs are not rendered by default.

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

export default {
components: {
VerticalPanes,
HorizontalPanes,
CustomResizer,
FlexGrowOnTheLeft,
CombinedVerticalHorizontalPanes,
},
};
26 changes: 26 additions & 0 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@
<CustomResizer></CustomResizer>
</div>
</section>
<section class="hero">
<div class="hero-body">
<div class="columns">
<div class="column">
<h2 class="title">Flex Grow on the Left</h2>
</div>
<div class="column is-narrow">
<a href="https://github.com/yansern/vue-multipane/blob/master/demo/src/FlexGrowOnTheLeft.vue" class="button is-warning">View code &raquo;</a>
</div>
</div>
<FlexGrowOnTheLeft></FlexGrowOnTheLeft>
</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 scoped>
.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 {
flex-grow: 1;
width: 100%;
border: 1px solid #ccc;
background: #eee;
}
.bottom {
height: 300px;
min-height: 20%;
max-height: 80%;
width: 100%;
border: 1px solid #ccc;
background: #eee;
}
</style>
2 changes: 1 addition & 1 deletion demo/src/CustomResizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
};
</script>

<style lang="scss">
<style scoped lang="scss">
.custom-resizer {
width: 100%;
height: 400px;
Expand Down
61 changes: 61 additions & 0 deletions demo/src/FlexGrowOnTheLeft.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<multipane layout="vertical" class="container">
<div class="left">
<h6 class="title is-6">Pane 1</h6>
<p class="subtitle is-6">Takes remaining available space.</p>
<p>
<small>
<strong>Configured with:</strong><br/>
flex-grow: 1<br/>
</small>
</p>
</div>
<multipane-resizer></multipane-resizer>
<div class="right">
<h6 class="title is-6">Pane 2</h6>
<p class="subtitle is-6">Fluid width.</p>
<p>
<small>
<strong>Configured with:</strong><br/>
width: 400px;<br/>
min-width: 100px;<br/>
max-width: 800px;<br/>
</small>
</p>
</div>
</multipane>
</template>

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

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

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

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

.right {
width: 400px;
min-width: 100px;
max-width: 800px;
height: 600px;
border: 1px solid #ccc;
background: #eee;
}
</style>
2 changes: 1 addition & 1 deletion demo/src/HorizontalPanes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
};
</script>

<style>
<style scoped>
.horizontal-panes {
width: 100%;
height: 600px;
Expand Down
2 changes: 1 addition & 1 deletion demo/src/VerticalPanes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
};
</script>

<style>
<style scoped>
.vertical-panes {
width: 100%;
height: 400px;
Expand Down
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.

28 changes: 18 additions & 10 deletions dist/vue-multipane.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ 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;

var pane = resizer.previousElementSibling;
var previousPane = true;
var style = window.getComputedStyle(pane);
if (style.flexGrow !== "0") {
pane = resizer.nextElementSibling;
previousPane = false;
}
var initialPaneWidth = pane.offsetWidth;
var initialPaneHeight = pane.offsetHeight;

Expand All @@ -65,7 +72,7 @@ var __vue_module__ = {

if (layout == LAYOUT_VERTICAL) {
var containerWidth = container.clientWidth;
var paneWidth = initialSize + offset;
var paneWidth = initialSize + (previousPane ? offset : -offset);

return (pane.style.width = usePercentage
? paneWidth / containerWidth * 100 + '%'
Expand All @@ -74,7 +81,7 @@ var __vue_module__ = {

if (layout == LAYOUT_HORIZONTAL) {
var containerHeight = container.clientHeight;
var paneHeight = initialSize + offset;
var paneHeight = initialSize + (previousPane ? offset : -offset);

return (pane.style.height = usePercentage
? paneHeight / containerHeight * 100 + '%'
Expand All @@ -86,7 +93,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 +105,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.

Loading