Comparing version 3.0.3 to 3.0.4
@@ -35,5 +35,7 @@ /** @module gl-util/context */ | ||
if (o.gl) { | ||
if (!o.container) o.container = o.gl.canvas | ||
return o.gl | ||
} | ||
if (o.canvas) { | ||
o.container = o.canvas.parentNode | ||
} | ||
if (o.container) { | ||
@@ -49,24 +51,16 @@ if (typeof o.container === 'string') { | ||
} | ||
else { | ||
else if (!o.canvas) { | ||
o.canvas = document.createElement('canvas') | ||
o.container.appendChild(o.canvas) | ||
resize(o) | ||
} | ||
} | ||
else { | ||
// blank new canvas | ||
else if (!o.canvas) { | ||
o.container = document.body || document.documentElement | ||
o.canvas = document.createElement('canvas') | ||
o.container.appendChild(o.canvas) | ||
resize(o) | ||
} | ||
// resize canvas | ||
if (o.container != document.body) { | ||
var bounds = o.container.getBoundingClientRect() | ||
o.canvas.width = o.width || (bounds.right - bounds.left) | ||
o.canvas.height = o.height || (bounds.bottom - bounds.top) | ||
} | ||
else { | ||
if (!document.body.style.width) o.canvas.width = o.pixelRatio * window.innerWidth | ||
if (!document.body.style.height) o.canvas.height = o.pixelRatio * window.innerHeight | ||
} | ||
// make sure there is context | ||
@@ -90,2 +84,15 @@ if (!o.gl) { | ||
function resize (o) { | ||
if (o.container) { | ||
if (o.container != document.body) { | ||
var bounds = o.container.getBoundingClientRect() | ||
o.canvas.width = o.width || (bounds.right - bounds.left) | ||
o.canvas.height = o.height || (bounds.bottom - bounds.top) | ||
} | ||
else { | ||
if (!document.body.style.width) o.canvas.width = o.pixelRatio * window.innerWidth | ||
if (!document.body.style.height) o.canvas.height = o.pixelRatio * window.innerHeight | ||
} | ||
} | ||
} | ||
@@ -92,0 +99,0 @@ function isCanvas (e) { |
{ | ||
"name": "gl-util", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "Set of practical webgl utils", | ||
@@ -32,3 +32,6 @@ "main": "index.js", | ||
"pick-by-alias": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.9.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30232
13
731
1