Skip to content
Snippets Groups Projects
Commit b8f972ba authored by Adam Procter's avatar Adam Procter
Browse files

textareas

parent 1b622510
Branches textarea
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
mixins: [draw], mixins: [draw],
computed: mapState({ computed: mapState({
configRect: state => state.configRect, configConnect: state => state.configConnect,
configHandle: state => state.configHandle configHandle: state => state.configHandle
}), }),
......
<template> <template>
<div class="editor"> <div class="node" ref="nodes">
<form id="editForm" class="myScroll"> <form id="editForm" class="myScroll">
<textarea></textarea> <textarea></textarea>
<p>markdown supported</p> <p>markdown supported</p>
...@@ -16,7 +16,11 @@ export default { ...@@ -16,7 +16,11 @@ export default {
name: 'NodesLayer', name: 'NodesLayer',
mixins: [drag], mixins: [drag],
mounted() {}, mounted() {
var nodes = this.$refs.nodes
this.makeDraggable(nodes)
},
methods: { methods: {
setFocus() { setFocus() {
this.$refs.notetext.focus() this.$refs.notetext.focus()
...@@ -30,7 +34,7 @@ export default { ...@@ -30,7 +34,7 @@ export default {
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style scoped>
.editor { .node {
background-color: aquamarine; background-color: aquamarine;
position: absolute; position: absolute;
} }
......
export const drag = { export const drag = {
methods: {} methods: {
makeDraggable(nodes) {
var active = false
var currentX
var currentY
var initialX
var initialY
var xOffset = 0
var yOffset = 0
nodes.addEventListener('mousedown', startDrag)
nodes.addEventListener('mousemove', drag)
nodes.addEventListener('mouseup', endDrag)
nodes.addEventListener('mouseleave', endDrag)
nodes.addEventListener('touchstart', startDrag)
nodes.addEventListener('touchmove', drag)
nodes.addEventListener('touchend', endDrag)
nodes.addEventListener('touchleave', endDrag)
nodes.addEventListener('touchcancel', endDrag)
function startDrag(e) {
if (e.type === 'touchstart') {
initialX = e.touches[0].clientX - xOffset
initialY = e.touches[0].clientY - yOffset
} else {
initialX = e.clientX - xOffset
initialY = e.clientY - yOffset
}
if (e.target.parentNode.classList.contains('node')) {
active = true
}
}
function drag(e) {
if (active) {
e.preventDefault()
if (e.type === 'touchmove') {
currentX = e.touches[0].clientX - initialX
currentY = e.touches[0].clientY - initialY
} else {
currentX = e.clientX - initialX
currentY = e.clientY - initialY
}
xOffset = currentX
yOffset = currentY
setTranslate(currentX, currentY, nodes)
}
}
function endDrag() {
initialX = currentX
initialY = currentY
active = false
}
function setTranslate(xPos, yPos, el) {
el.style.transform = 'translate3d(' + xPos + 'px, ' + yPos + 'px, 0)'
}
}
}
} }
...@@ -7,12 +7,12 @@ export const draw = { ...@@ -7,12 +7,12 @@ export const draw = {
box(ctx, x, y) { box(ctx, x, y) {
ctx.setTransform(1, 0, 0, 1, x, y) ctx.setTransform(1, 0, 0, 1, x, y)
ctx.fillStyle = this.configRect.fill ctx.fillStyle = this.configConnect.fill
ctx.fillRect( ctx.fillRect(
this.configRect.x, this.configConnect.x,
this.configRect.y, this.configConnect.y,
this.configRect.height, this.configConnect.height,
this.configRect.width this.configConnect.width
) )
ctx.fillStyle = this.configHandle.fill ctx.fillStyle = this.configHandle.fill
......
...@@ -5,7 +5,8 @@ Vue.use(Vuex) ...@@ -5,7 +5,8 @@ Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
configRect: { // this will be objects containing arrays of all the handles / connections and nodes
configConnect: {
x: -25, x: -25,
y: -25, y: -25,
height: 50, height: 50,
...@@ -15,10 +16,11 @@ export default new Vuex.Store({ ...@@ -15,10 +16,11 @@ export default new Vuex.Store({
configHandle: { configHandle: {
x: 25, x: 25,
y: 25, y: 25,
height: 4, height: 10,
width: 4, width: 10,
fill: 'black' fill: 'black'
} },
configNodes: {}
}, },
mutations: {}, mutations: {},
actions: {}, actions: {},
......
<template> <template>
<div class="home"> <div class="home">
<!-- The number of NodesLayers comes from store -->
<NodesLayer />
<NodesLayer /> <NodesLayer />
<CanvasLayer /> <CanvasLayer />
<ControlsLayer /> <ControlsLayer />
...@@ -12,13 +14,18 @@ import CanvasLayer from '@/components/CanvasLayer.vue' ...@@ -12,13 +14,18 @@ import CanvasLayer from '@/components/CanvasLayer.vue'
import NodesLayer from '@/components/NodesLayer.vue' import NodesLayer from '@/components/NodesLayer.vue'
import ControlsLayer from '@/components/ControlsLayer.vue' import ControlsLayer from '@/components/ControlsLayer.vue'
import { mapState } from 'vuex'
export default { export default {
name: 'Home', name: 'Home',
components: { components: {
CanvasLayer, CanvasLayer,
NodesLayer, NodesLayer,
ControlsLayer ControlsLayer
} },
computed: mapState({
configNodes: state => state.configNodes
})
} }
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment