From 9147225ade4e6a696f31ab5842a8dd02f69301d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Wed, 22 Mar 2023 07:51:00 +0100 Subject: [PATCH] devicePixelRatio Added option to set devicePixelRatio instead of use window value. When set to fixed value It helps to predict animation scaling when moving from display with devicePixelRatio 1 to 2 and more (retina) --- src/_base.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/_base.js b/src/_base.js index 3796124..b92c5f8 100644 --- a/src/_base.js +++ b/src/_base.js @@ -58,6 +58,7 @@ VANTA.VantaBase = class VantaBase { minWidth: 200, scale: 1, scaleMobile: 1, + devicePixelRatio: window.devicePixelRatio }, defaultOptions) if (userOptions instanceof HTMLElement || typeof userOptions === 'string') { @@ -294,7 +295,7 @@ VANTA.VantaBase = class VantaBase { } if (this.renderer) { this.renderer.setSize(this.width, this.height) - this.renderer.setPixelRatio(window.devicePixelRatio / this.scale) + this.renderer.setPixelRatio(this.options.devicePixelRatio / this.scale) } typeof this.onResize === "function" ? this.onResize() : void 0 } @@ -418,4 +419,4 @@ VANTA.VantaBase = class VantaBase { } } -export default VANTA.VantaBase \ No newline at end of file +export default VANTA.VantaBase