Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

image creation fix #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wScratchPad",
"title": "wScratchPad jQuery Plugin",
"version": "2.1.0",
"version": "2.2.3",
"description": "A jQuery plugin to mimic a scratch card or pad behaviour. Allowing you to scratch off an overlay as either a color or image.",
"main": "wScratchPad.js",
"repository": {
Expand All @@ -13,10 +13,11 @@
"email": "[email protected]",
"url": "http://websanova.com"
},
"homepage" : "http://wscratchpad.websanova.com",
"homepage": "http://wscratchpad.websanova.com",
"license": "MIT, GPL",
"dependencies": {
"grunt-contrib-uglify": "",
"grunt-contrib-jshint": ""
"grunt": "^1.0.1",
"grunt-contrib-jshint": "",
"grunt-contrib-uglify": ""
}
}
}
23 changes: 13 additions & 10 deletions src/wScratchPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
},

reset: function () {
var _this = this,
width = Math.ceil(this.$el.innerWidth()),
var width = Math.ceil(this.$el.innerWidth()),
height = Math.ceil(this.$el.innerHeight()),
devicePixelRatio = window.devicePixelRatio || 1;

Expand Down Expand Up @@ -119,13 +118,17 @@
}
else {
// Have to load image before we can use it.
$(new Image())
.attr('crossOrigin', '')
.attr('src', this.options.fg)
.load(function () {
_this.ctx.drawImage(this, 0, 0, width, height);
_this.$img.show();
});
var self = this;
var frame = new Image();

frame.onload = function() {

self.ctx.drawImage(frame, 0, 0, width, height);
self.$img.show();
};

frame.crossOrigin = '';
frame.src = this.options.fg;
}
}
},
Expand Down Expand Up @@ -199,7 +202,7 @@
_scratchDown: function (e) {
this.ctx.globalCompositeOperation = 'destination-out';
this.ctx.lineJoin = 'round';
this.ctx.lineCap = 'round';
this.ctx.lineCap = 'square';
this.ctx.strokeStyle = this.options.color;
this.ctx.lineWidth = this.options.size;

Expand Down
2 changes: 1 addition & 1 deletion wScratchPad.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.