From 99c8e61f4c73ad09e19a048bd53ac41854d07971 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 23 Jan 2019 11:01:15 -0500 Subject: [PATCH] Move the mask on the audio meter outside the svg for repaint performance --- src/components/meter/meter.css | 18 ++++++++++++ src/components/meter/meter.jsx | 54 ++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/components/meter/meter.css b/src/components/meter/meter.css index c16e920cd..953f3641b 100644 --- a/src/components/meter/meter.css +++ b/src/components/meter/meter.css @@ -1,3 +1,5 @@ +@import "../../css/colors.css"; + .green { fill: rgb(171, 220, 170); stroke: rgb(174, 211, 168); @@ -12,3 +14,19 @@ fill: rgb(251, 194, 142); stroke: rgb(235, 189, 142); } + +.mask-container { + position: relative; +} + +.mask { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + transform-origin: top; + will-change: transform; + background: $ui-primary; + opacity: 0.75; +} diff --git a/src/components/meter/meter.jsx b/src/components/meter/meter.jsx index 2d16ce681..4f0711916 100644 --- a/src/components/meter/meter.jsx +++ b/src/components/meter/meter.jsx @@ -20,36 +20,40 @@ const Meter = props => { const barHeight = (height - (barSpacing * (nBars + 1))) / nBars; const nBarsToMask = nBars - Math.floor(level * nBars); + const scale = ((nBarsToMask * (barHeight + barSpacing)) + (barSpacing / 2)) / height; return ( - - {Array(nBars).fill(0) - .map((value, index) => ( - - ))} - + {Array(nBars).fill(0) + .map((value, index) => ( + + ))} + +
- +
); };