fancy-canvas
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -18,2 +18,5 @@ export declare type Size = { | ||
} | ||
export declare function bindToDevicePixelRatio(canvas: HTMLCanvasElement): Binding; | ||
export interface BindingOptions { | ||
allowDownsampling: boolean; | ||
} | ||
export declare function bindToDevicePixelRatio(canvas: HTMLCanvasElement, options?: BindingOptions): Binding; |
@@ -1,6 +0,10 @@ | ||
export function bindToDevicePixelRatio(canvas) { | ||
return new DevicePixelRatioBinding(canvas); | ||
var defaultBindingOptions = { | ||
allowDownsampling: true, | ||
}; | ||
export function bindToDevicePixelRatio(canvas, options) { | ||
if (options === void 0) { options = defaultBindingOptions; } | ||
return new DevicePixelRatioBinding(canvas, options); | ||
} | ||
var DevicePixelRatioBinding = /** @class */ (function () { | ||
function DevicePixelRatioBinding(canvas) { | ||
function DevicePixelRatioBinding(canvas, options) { | ||
var _this = this; | ||
@@ -15,2 +19,3 @@ this._resolutionMediaQueryList = null; | ||
}; | ||
this._options = options; | ||
this._configureCanvas(); | ||
@@ -49,3 +54,3 @@ this._installResolutionListener(); | ||
} | ||
return win.devicePixelRatio; | ||
return win.devicePixelRatio > 1 || this._options.allowDownsampling ? win.devicePixelRatio : 1; | ||
}, | ||
@@ -52,0 +57,0 @@ enumerable: true, |
{ | ||
"name": "fancy-canvas", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "smakarov@tradingview.com", | ||
@@ -5,0 +5,0 @@ "description": "Functionality on top of HTML canvas element, including support for HiDPI and pixel-perfect rendering", |
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
6263
128