Normalize set minPrice and maxPrice values by step (https://github.com/woocommerce/woocommerce-blocks/pull/1379)

* normalize set minPrice and maxPrice values by step

* follow standards for comment blocks
This commit is contained in:
Darren Ethier 2019-12-13 16:54:35 -05:00 committed by GitHub
parent 5485e4c51c
commit 5ac157b14a
1 changed files with 8 additions and 2 deletions

View File

@ -81,16 +81,21 @@ const PriceSlider = ( {
};
}
// Normalize to whatever is the closest step (because range input will
// only jump to the closest step in the range).
const min = Math.round( minPrice / step ) * step;
const max = Math.round( maxPrice / step ) * step;
const low =
Math.round(
100 *
( ( minPrice - minConstraint ) /
( ( min - minConstraint ) /
( maxConstraint - minConstraint ) )
) - 0.5;
const high =
Math.round(
100 *
( ( maxPrice - minConstraint ) /
( ( max - minConstraint ) /
( maxConstraint - minConstraint ) )
) + 0.5;
@ -104,6 +109,7 @@ const PriceSlider = ( {
minConstraint,
maxConstraint,
hasValidConstraints,
step,
] );
/**