diff --git a/src/src/components/ModelisationArea.vue b/src/src/components/ModelisationArea.vue index f936b2a..0cc6389 100644 --- a/src/src/components/ModelisationArea.vue +++ b/src/src/components/ModelisationArea.vue @@ -1,9 +1,7 @@ @@ -17,6 +15,13 @@ export default { data() { return { data: datas, + drag: { + isDown: false, + startX: 0, + startY: 0, + scrollLeft: 0, + scrollTop: 0, + } } }, methods: { @@ -24,7 +29,8 @@ export default { if (document.getElementById('plus-info').classList.contains('on')) { console.log(this.data) document.getElementById('main-box').onmousedown = function(e) { - console.log([e.clientX, e.clientY]) + console.log(e.offsetX) + console.log(e.offsetY) } } else if (document.getElementById('trash-info').classList.contains('on')) { @@ -36,12 +42,36 @@ export default { else if (document.getElementById('slash-lg-info').classList.contains('on')) { console.log('4') } + }, + replace() { + document.getElementById('main-box').scrollTop = 5000; + document.getElementById('main-box').scrollLeft = 5000; + }, + mousedown(e) { + let element = document.getElementById('main-box'); + + this.drag.isDown = true; + this.drag.startX = e.pageX - element.offsetLeft; + this.drag.startY = e.pageY - element.offsetTop; + this.drag.scrollLeft = element.scrollLeft; + this.drag.scrollTop = element.scrollTop; + }, + mousemove(e) { + let element = document.getElementById('main-box'); + if (this.drag.isDown) { + e.preventDefault(); + let x = e.pageX - element.offsetLeft; + let y = e.pageY - element.offsetTop; + let wx = (x - this.drag.startX) * 3; + let wy = (y - this.drag.startY) * 3; + element.scrollLeft = this.drag.scrollLeft - wx; + element.scrollTop = this.drag.scrollTop - wy; + } } }, - mounted() { - document.getElementById('main-box').scrollTop = 5000; - document.getElementById('main-box').scrollLeft = 5000; - } + created() { + window.addEventListener('load', this.replace) + }, }