mirror of
https://github.com/konvajs/konva.git
synced 2025-07-16 01:55:21 +08:00
Enable devicePixelRatio for desktop browsers
This commit is contained in:
parent
98e575aaf7
commit
cf93f973ec
@ -2,12 +2,7 @@
|
|||||||
// calculate pixel ratio
|
// calculate pixel ratio
|
||||||
var canvas = Konva.Util.createCanvasElement(),
|
var canvas = Konva.Util.createCanvasElement(),
|
||||||
context = canvas.getContext('2d'),
|
context = canvas.getContext('2d'),
|
||||||
// if using a mobile device, calculate the pixel ratio. Otherwise, just use
|
_pixelRatio = (function() {
|
||||||
// 1. For desktop browsers, if the user has zoom enabled, it affects the pixel ratio
|
|
||||||
// and causes artifacts on the canvas. As of 02/26/2014, there doesn't seem to be a way
|
|
||||||
// to reliably calculate the browser zoom for modern browsers, which is why we just set
|
|
||||||
// the pixel ratio to 1 for desktops
|
|
||||||
_pixelRatio = Konva.UA.mobile ? (function() {
|
|
||||||
var devicePixelRatio = window.devicePixelRatio || 1,
|
var devicePixelRatio = window.devicePixelRatio || 1,
|
||||||
backingStoreRatio = context.webkitBackingStorePixelRatio
|
backingStoreRatio = context.webkitBackingStorePixelRatio
|
||||||
|| context.mozBackingStorePixelRatio
|
|| context.mozBackingStorePixelRatio
|
||||||
@ -16,7 +11,7 @@
|
|||||||
|| context.backingStorePixelRatio
|
|| context.backingStorePixelRatio
|
||||||
|| 1;
|
|| 1;
|
||||||
return devicePixelRatio / backingStoreRatio;
|
return devicePixelRatio / backingStoreRatio;
|
||||||
})() : 1;
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Canvas Renderer constructor
|
* Canvas Renderer constructor
|
||||||
|
Loading…
Reference in New Issue
Block a user