mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00
added Kinetic level pixelRatio property that can be used to override the detected pixel ratio. Also fixed up a pixel ratio related test for FF. added Kinetic.UA for user agent detection
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
init: function(config) {
|
||||
config = config || {};
|
||||
|
||||
var pixelRatio = config.pixelRatio || _pixelRatio;
|
||||
var pixelRatio = config.pixelRatio || Kinetic.pixelRatio || _pixelRatio;
|
||||
|
||||
this.pixelRatio = pixelRatio;
|
||||
this._canvas = document.createElement('canvas');
|
||||
|
@@ -47,6 +47,7 @@ var Kinetic = {};
|
||||
enableTrace: false,
|
||||
traceArrMax: 100,
|
||||
dblClickWindow: 400,
|
||||
pixelRatio: undefined,
|
||||
|
||||
/**
|
||||
* @namespace Filters
|
||||
|
22
src/Util.js
22
src/Util.js
@@ -84,10 +84,7 @@
|
||||
})(n);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
(function() {
|
||||
/*
|
||||
* Last updated November 2011
|
||||
* By Simon Sarris
|
||||
@@ -255,10 +252,25 @@
|
||||
this.translate(xt, yt);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/*
|
||||
* jQuery UA
|
||||
*/
|
||||
Kinetic.UA = (function() {
|
||||
var ua = navigator.userAgent.toLowerCase(),
|
||||
match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(msie) ([\w.]+)/.exec( ua ) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || '',
|
||||
version: match[ 2 ] || '0'
|
||||
};
|
||||
})();
|
||||
|
||||
(function() {
|
||||
// CONSTANTS
|
||||
var CANVAS = 'canvas',
|
||||
CONTEXT_2D = '2d',
|
||||
|
@@ -3,6 +3,8 @@ var assert = chai.assert,
|
||||
kineticContainer = document.getElementById('kinetic-container');
|
||||
|
||||
Kinetic.enableTrace = true;
|
||||
// make sure pixel ratio is 1 or else the tests will fail on devices with retina display
|
||||
Kinetic.pixelRatio = 1;
|
||||
|
||||
function addStage() {
|
||||
var container = document.createElement('div'),
|
||||
|
@@ -21,7 +21,14 @@ suite('Layer', function() {
|
||||
var style = layer.getCanvas()._canvas.style;
|
||||
|
||||
assert.equal(style.position, 'absolute', 'canvas position style should be absolute');
|
||||
assert.equal(style.border, '0px', 'canvas border style should be 0px');
|
||||
|
||||
if (Kinetic.UA.browser === 'mozilla') {
|
||||
assert.equal(style.border, '0px none', 'canvas border style should be 0px');
|
||||
}
|
||||
else {
|
||||
assert.equal(style.border, '0px', 'canvas border style should be 0px');
|
||||
}
|
||||
|
||||
assert.equal(style.margin, '0px', 'canvas margin style should be 0px');
|
||||
assert.equal(style.padding, '0px', 'canvas padding style should be 0px');
|
||||
assert.equal(style.backgroundColor, 'transparent', 'canvas backgroundColor style should be transparent');
|
||||
|
Reference in New Issue
Block a user