From be15db0a5c93319b634f52e59ef5b396a8ca8095 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Tue, 18 Aug 2020 21:44:34 +0300 Subject: [PATCH] Fixed main stickers (monkey, folders) blur --- src/lib/lottieLoader.ts | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/lib/lottieLoader.ts b/src/lib/lottieLoader.ts index 06b885ae..9b7af086 100644 --- a/src/lib/lottieLoader.ts +++ b/src/lib/lottieLoader.ts @@ -16,7 +16,8 @@ type RLottieOptions = { width?: number, height?: number, group?: string, - noCache?: true + noCache?: true, + needUpscale?: true }; export class RLottiePlayer { @@ -83,17 +84,23 @@ export class RLottiePlayer { this[i] = options[i]; } } - - //this.cachingEnabled = true;//this.width < 100 && this.height < 100; - if(window.devicePixelRatio > 1 && this.width > 100 && this.height > 100) { - if(isApple || !mediaSizes.isMobile) { - /* this.width = Math.round(this.width * (window.devicePixelRatio - 1)); - this.height = Math.round(this.height * (window.devicePixelRatio - 1)); */ - this.width = Math.round(this.width * window.devicePixelRatio); - this.height = Math.round(this.height * window.devicePixelRatio); - } else if(window.devicePixelRatio > 2.5) { - this.width = Math.round(this.width * (window.devicePixelRatio - 1.5)); - this.height = Math.round(this.height * (window.devicePixelRatio - 1.5)); + + const pixelRatio = window.devicePixelRatio; + if(pixelRatio > 1) { + //this.cachingEnabled = true;//this.width < 100 && this.height < 100; + if(options.needUpscale) { + this.width = Math.round(this.width * pixelRatio); + this.height = Math.round(this.height * pixelRatio); + } else if(pixelRatio > 1 && this.width > 100 && this.height > 100) { + if(isApple || !mediaSizes.isMobile) { + /* this.width = Math.round(this.width * (pixelRatio - 1)); + this.height = Math.round(this.height * (pixelRatio - 1)); */ + this.width = Math.round(this.width * pixelRatio); + this.height = Math.round(this.height * pixelRatio); + } else if(pixelRatio > 2.5) { + this.width = Math.round(this.width * (pixelRatio - 1.5)); + this.height = Math.round(this.height * (pixelRatio - 1.5)); + } } } @@ -623,7 +630,7 @@ class LottieLoader { .then(res => res.arrayBuffer()) .then(data => apiManager.gzipUncompress(data, true)) .then(str => { - return this.loadAnimationWorker(Object.assign(params, {animationData: JSON.parse(str)})); + return this.loadAnimationWorker(Object.assign(params, {animationData: JSON.parse(str), needUpscale: true})); }); }