diff --git a/VueWebcam.js b/VueWebcam.js index 5492207..9db4a20 100755 --- a/VueWebcam.js +++ b/VueWebcam.js @@ -1,6 +1,18 @@ const Vue = require('vue'); const WebcamComponent = Vue.extend({ + render: function (h) { + return h('video', { + ref: 'video', + attrs: { + width: this.width, + height: this.height, + src: this.src, + autoplay: this.autoplay, + style: this.styleObject + } + }); + }, props: { autoplay: { type: Boolean, @@ -23,16 +35,6 @@ const WebcamComponent = Vue.extend({ default: 'image/jpeg' } }, - template: ` - - `, data () { return { video: '', @@ -55,7 +57,7 @@ const WebcamComponent = Vue.extend({ getCanvas () { if (!this.hasUserMedia) return null; - const video = this.$els.video; + const video = this.$refs.video; if (!this.ctx) { const canvas = document.createElement('canvas'); canvas.height = video.clientHeight; @@ -79,8 +81,8 @@ const WebcamComponent = Vue.extend({ } }, - ready () { - this.video = this.$els.video; + mounted: function () { + this.video = this.$refs.video; navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; if (navigator.getUserMedia) { @@ -93,12 +95,12 @@ const WebcamComponent = Vue.extend({ }); } }, - beforeDestroy () { + beforeDestroy: function () { this.video.pause(); this.src = ''; this.stream.getTracks()[0].stop(); }, - destroyed () { + destroyed: function () { console.log('Destroyed'); } }); diff --git a/example/.babelrc b/example/.babelrc index a31fc60..7fb3493 100755 --- a/example/.babelrc +++ b/example/.babelrc @@ -1,5 +1,5 @@ { - "presets": ["es2015", "stage-2"], - "plugins": ["transform-runtime"], - "comments": false + "presets": [ + ["es2015", { "modules": false }] + ] } diff --git a/example/README.md b/example/README.md index 2fc88fe..ee3b7c1 100755 --- a/example/README.md +++ b/example/README.md @@ -1,11 +1,11 @@ # vue-cropperjs-example -> Example project for vue-webcam component. +> Example project for vue-webcam package ## Build Setup ``` bash -# install dependencies. +# install dependencies npm install # serve with hot reload at localhost:8080 diff --git a/example/index.html b/example/index.html index 7f700cb..3dcf997 100755 --- a/example/index.html +++ b/example/index.html @@ -6,7 +6,7 @@
-