mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-09 03:04:49 -04:00
Optimise DomElement.getPrefixValue()
This commit is contained in:
parent
22e13df102
commit
d158056899
2 changed files with 4 additions and 4 deletions
src
|
@ -205,10 +205,10 @@ var DomElement = new function() {
|
||||||
*/
|
*/
|
||||||
getPrefixValue: function(el, name) {
|
getPrefixValue: function(el, name) {
|
||||||
var value = el[name],
|
var value = el[name],
|
||||||
|
prefixes = ['webkit', 'moz', 'ms', 'o'],
|
||||||
suffix = name[0].toUpperCase() + name.substring(1);
|
suffix = name[0].toUpperCase() + name.substring(1);
|
||||||
Base.each(['webkit', 'moz', 'ms', 'o'], function(prefix) {
|
for (var i = 0; i < 4 && value == null; i++)
|
||||||
value = el[prefix + suffix] || value;
|
value = el[prefixes[i] + suffix];
|
||||||
});
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,7 +40,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
||||||
// http://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
// http://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
||||||
var ratio = (window.devicePixelRatio || 1) / (DomElement.getPrefixValue(
|
var ratio = (window.devicePixelRatio || 1) / (DomElement.getPrefixValue(
|
||||||
ctx, 'backingStorePixelRatio') || 1);
|
ctx, 'backingStorePixelRatio') || 1);
|
||||||
// Upscale the canvas if the two ratios don't match
|
// Upscale the canvas if the two ratios don't match.
|
||||||
if (ratio > 1) {
|
if (ratio > 1) {
|
||||||
var width = canvas.clientWidth,
|
var width = canvas.clientWidth,
|
||||||
height = canvas.clientHeight,
|
height = canvas.clientHeight,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue