mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-06-14 14:11:18 -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) {
|
||||
var value = el[name],
|
||||
prefixes = ['webkit', 'moz', 'ms', 'o'],
|
||||
suffix = name[0].toUpperCase() + name.substring(1);
|
||||
Base.each(['webkit', 'moz', 'ms', 'o'], function(prefix) {
|
||||
value = el[prefix + suffix] || value;
|
||||
});
|
||||
for (var i = 0; i < 4 && value == null; i++)
|
||||
value = el[prefixes[i] + suffix];
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
// http://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
||||
var ratio = (window.devicePixelRatio || 1) / (DomElement.getPrefixValue(
|
||||
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) {
|
||||
var width = canvas.clientWidth,
|
||||
height = canvas.clientHeight,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue