Skip to content

Commit

Permalink
Use imageSmoothingQuality
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanziyang committed Apr 15, 2018
2 parents 759eba6 + 769f1ca commit d89bd80
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 53 deletions.
97 changes: 53 additions & 44 deletions docs/src/croppa/vue-croppa.js

Large diffs are not rendered by default.

33 changes: 24 additions & 9 deletions src/cropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ export default {
this._autoSizingInit()
},
beforeDestroy () {
this._autoSizingRemove()
},
watch: {
outputWidth: function () {
this.onDimensionChange()
Expand Down Expand Up @@ -503,17 +507,23 @@ export default {
this.$emit(evt.type, evt);
},
_setContainerSize () {
if (this.$refs.wrapper && getComputedStyle) {
this.realWidth = +getComputedStyle(this.$refs.wrapper).width.slice(0, -2)
this.realHeight = +getComputedStyle(this.$refs.wrapper).height.slice(0, -2)
}
},
_autoSizingInit () {
var setContainerSize = () => {
if (getComputedStyle && (this.$refs.wrapper instanceof Element)) {
this.realWidth = +getComputedStyle(this.$refs.wrapper).width.slice(0, -2)
this.realHeight = +getComputedStyle(this.$refs.wrapper).height.slice(0, -2)
}
if (this.useAutoSizing) {
this._setContainerSize()
window.addEventListener('resize', this._setContainerSize)
}
let useAutoSizing = this.autoSizing
if (useAutoSizing) {
setContainerSize()
window.addEventListener('resize', setContainerSize)
},
_autoSizingRemove () {
if (this.useAutoSizing) {
window.removeEventListener('resize', this._setContainerSize)
}
},
Expand All @@ -522,6 +532,11 @@ export default {
this._setSize()
this.canvas.style.backgroundColor = (!this.canvasColor || this.canvasColor == 'default') ? 'transparent' : (typeof this.canvasColor === 'string' ? this.canvasColor : '')
this.ctx = this.canvas.getContext('2d')
this.ctx.mozImageSmoothingEnabled = true;
this.ctx.imageSmoothingQuality = "high";
this.ctx.webkitImageSmoothingEnabled = true;
this.ctx.msImageSmoothingEnabled = true;
this.ctx.imageSmoothingEnabled = true;
this.originalImage = null
this.img = null
this.imageSet = false
Expand Down

0 comments on commit d89bd80

Please sign in to comment.