From dfab37b3e041f69c15877e962e8a758407e4044d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 18 Jan 2018 18:21:22 +0100 Subject: [PATCH] basics of player component, global imageLoad bus --- src/App.vue | 5 +-- src/components/Canvas.vue | 6 ++-- src/components/Player.vue | 65 ++++++++++++++++++++++++++++++++++++++ src/components/Sidebar.vue | 13 ++++++-- src/main.js | 2 ++ 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 src/components/Player.vue diff --git a/src/App.vue b/src/App.vue index cc474ac..babd389 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,7 @@
- +
@@ -24,9 +24,6 @@ }, guideSize: function (size) { this.$refs.canvas.slice = size - }, - updateImageSize: function (size) { - this.$refs.sidebar.imageSize = size } } } diff --git a/src/components/Canvas.vue b/src/components/Canvas.vue index 26f66f1..6752af5 100644 --- a/src/components/Canvas.vue +++ b/src/components/Canvas.vue @@ -1,6 +1,6 @@ @@ -36,7 +36,7 @@ this.image = new Image() this.image.onload = () => { this.imageLoaded = true - this.$emit('imageLoaded', [this.image.width, this.image.height]) + this.$bus.$emit('imageLoaded', this.image) this.refresh() } this.image.src = imageUrl @@ -44,7 +44,7 @@ refresh: function () { if (!this.imageLoaded) return let image = this.image - let canvas = document.getElementById('canvas') + let canvas = this.$refs.canvas let ctx = canvas.getContext('2d') ctx.clearRect(0, 0, canvas.width, canvas.height) diff --git a/src/components/Player.vue b/src/components/Player.vue new file mode 100644 index 0000000..bc739f6 --- /dev/null +++ b/src/components/Player.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 9cb2997..416f0d0 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -41,18 +41,24 @@
+