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

basic touch support #13

Open
wants to merge 8 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
47 changes: 47 additions & 0 deletions demo/index-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>vue-multipane - Resizable split panes for Vue.js.</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.3/css/bulma.min.css">
<style>
.is-resizing {
background-color: #F00;
}
</style>
</head>

<body>
<div class="container">

<header>
<section class="hero">
<div class="hero-body">
<h1 class="title is-1">vue-multipane demo</h1>
<h2 class="subtitle">Resizable split panes for Vue.js.</h2>
<a href="https://github.com/yansern/vue-multipane" class="button is-info">View GitHub page &raquo;</a>
</div>
</section>
</header>

<hr style="margin-bottom: 0;" />

<main>
<div id="app"></div>
</main>

<hr style="margin-bottom: 0;" />

<footer class="footer">
<div class="container">
<p><strong><a href="https://github.com/yansern/vue-multipane">vue-multipane</a></strong> by <a href="https://twitter.com/yansernio">Yan Sern</a>. This is an open source project released under the <a href="LICENSE">MIT License</a>.</p>
</div>
</footer>

</div>
<script src="manifest.js"></script>
<script src="vendor.js"></script>
<script src="main.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion demo/main.js

Large diffs are not rendered by default.

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.

66 changes: 54 additions & 12 deletions dist/vue-multipane.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,28 @@ var __vue_module__ = {
},

methods: {
onMouseDown: function onMouseDown(ref) {
var resizer = ref.target;
var initialPageX = ref.pageX;
var initialPageY = ref.pageY;

if (resizer.className && resizer.className.match('multipane-resizer')) {
onMouseDown: function onMouseDown(e) {
var resizer = e.target;
if (resizer.className && typeof resizer.className === 'string' && resizer.className.match('multipane-resizer')) {
e.preventDefault();
var initialPageX, initialPageY;
if (e.type == "touchstart") {
initialPageX = e.touches[0].pageX;
initialPageY = e.touches[0].pageY;
} else {
initialPageX = e.pageX;
initialPageY = e.pageY;
}
var self = this;
var container = self.$el;
var layout = self.layout;

var reversed = Boolean(resizer.className.match('affect-follower'));

var pane = resizer.previousElementSibling;
if (reversed) {
pane = resizer.nextElementSibling;
}
var initialPaneWidth = pane.offsetWidth;
var initialPaneHeight = pane.offsetHeight;

Expand All @@ -63,6 +74,9 @@ var __vue_module__ = {
var resize = function (initialSize, offset) {
if ( offset === void 0 ) offset = 0;

if (reversed) {
offset = -offset;
}
if (layout == LAYOUT_VERTICAL) {
var containerWidth = container.clientWidth;
var paneWidth = initialSize + offset;
Expand Down Expand Up @@ -91,10 +105,16 @@ var __vue_module__ = {
// Trigger paneResizeStart event
self.$emit('paneResizeStart', pane, resizer, size);

var onMouseMove = function(ref) {
var pageX = ref.pageX;
var pageY = ref.pageY;

var onMouseMove = function(e) {
var pageX, pageY;
if (e.type == "touchmove") {
pageX = e.touches[0].pageX;
pageY = e.touches[0].pageY;
} else {
e.preventDefault();
pageX = e.pageX;
pageY = e.pageY;
}
size =
layout == LAYOUT_VERTICAL
? resize(initialPaneWidth, pageX - initialPageX)
Expand All @@ -115,12 +135,16 @@ var __vue_module__ = {

removeEventListener('mousemove', onMouseMove);
removeEventListener('mouseup', onMouseUp);
removeEventListener('touchmove', onMouseMove);
removeEventListener('touchend', onMouseUp);

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

addEventListener('mousemove', onMouseMove);
addEventListener('mouseup', onMouseUp);
addEventListener('touchmove', onMouseMove);
addEventListener('touchend', onMouseUp);
}
},
},
Expand Down Expand Up @@ -174,12 +198,30 @@ var __vue_module__ = {



var __$__vue_module__ = Object.assign(__vue_module__, {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.classnames,style:({ cursor: _vm.cursor, userSelect: _vm.userSelect }),on:{"mousedown":_vm.onMouseDown}},[_vm._t("default")],2)},staticRenderFns: [],});
var __$__vue_module__ = Object.assign(__vue_module__, {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.classnames,style:({ cursor: _vm.cursor, userSelect: _vm.userSelect }),on:{"mousedown":_vm.onMouseDown,"touchstart":_vm.onMouseDown}},[_vm._t("default")],2)},staticRenderFns: [],});
__$__vue_module__.prototype = __vue_module__.prototype;

(function(){ if(typeof document !== 'undefined'){ var head=document.head||document.getElementsByTagName('head')[0], style=document.createElement('style'), css=""; style.type='text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); } })();

var MultipaneResizer = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"multipane-resizer"},[_vm._t("default")],2)},staticRenderFns: [],



var MultipaneResizer = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.classnames},[_vm._t("default")],2)},staticRenderFns: [],
name: 'multipane-resizer',

props: {
affectFollower: {
type: Boolean,
default: false,
},
},
computed: {
classnames: function classnames() {
return [
'multipane-resizer',
this.affectFollower ? 'affect-follower' : '' ];
},
}
};

if (typeof window !== 'undefined' && window.Vue) {
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.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@
},
"engines": {
"node": ">=6.0.0"
},
"dependencies": {
"yarn": "^1.6.0"
}
}
25 changes: 23 additions & 2 deletions src/multipane-resizer.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
<template>
<div class="multipane-resizer"><slot></slot></div>
</template>
<div :class="classnames"><slot></slot></div>
</template>

<script>
export default {
name: 'multipane-resizer',

props: {
affectFollower: {
type: Boolean,
default: false,
},
},
computed: {
classnames() {
return [
'multipane-resizer',
this.affectFollower ? 'affect-follower' : '',
];
},
}
}
</script>
Loading