Skip to content

Commit

Permalink
check if global object exists
Browse files Browse the repository at this point in the history
  • Loading branch information
namniak committed Dec 1, 2015
1 parent 8e1b4b4 commit 50a85dd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
canvas-text-wrapper
=================
v0.6.6
##v0.6.7


## Syntax
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-text-wrapper",
"version": "0.6.6",
"version": "0.6.7",
"ignore": [
"**/.*",
"**/*.log",
Expand Down
8 changes: 5 additions & 3 deletions canvas-text-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! canvas-text-wrapper
* https://github.com/namniak/canvas-text-wrapper
* Version: 0.6.6
* Version: 0.6.7
* MIT License (http://www.opensource.org/licenses/mit-license.html)
*/

Expand Down Expand Up @@ -37,7 +37,9 @@
context.textBaseline = 'bottom';

var scale = 1;
if (opts.renderHDPI && global.devicePixelRatio) {
var devicePixelRatio = (typeof global !== 'undefined') ? global.devicePixelRatio : root.devicePixelRatio;

if (opts.renderHDPI && devicePixelRatio > 1) {
var tempCtx = {};

// store context settings in a temp object before scaling otherwise they will be lost
Expand All @@ -47,7 +49,7 @@

var canvasWidth = canvas.width;
var canvasHeight = canvas.height;
scale = global.devicePixelRatio;
scale = devicePixelRatio;

canvas.width = canvasWidth * scale;
canvas.height = canvasHeight * scale;
Expand Down
4 changes: 2 additions & 2 deletions canvas-text-wrapper.min.js

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-text-wrapper",
"description": "Split canvas text into lines on specified rule with optional alignment, padding, and more. Supports HDPI screens.",
"version": "0.6.6",
"version": "0.6.7",
"license": "MIT",
"main": "canvas-text-wrapper.min.js",
"keywords": [
Expand All @@ -25,6 +25,7 @@
"test": "beefy test/test.js --live --open"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-uglify": "^0.9.1",
"uglify-save-license": "^0.4.1"
}
Expand Down

0 comments on commit 50a85dd

Please sign in to comment.