timeline: floor dispWp instead of round
parent
2b9e7ee5b7
commit
b6adacc19b
|
@ -337,7 +337,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
|
||||||
row.photos[j] = {
|
row.photos[j] = {
|
||||||
flag: this.c.FLAG_PLACEHOLDER,
|
flag: this.c.FLAG_PLACEHOLDER,
|
||||||
fileid: Math.random(),
|
fileid: Math.random(),
|
||||||
dispWp: utils.round(100 / this.numCols, 2),
|
dispWp: utils.round(100 / this.numCols, 2, true),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
delete row.pct;
|
delete row.pct;
|
||||||
|
@ -721,7 +721,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
|
||||||
utils.convertFlags(photo);
|
utils.convertFlags(photo);
|
||||||
|
|
||||||
// Get aspect ratio
|
// Get aspect ratio
|
||||||
photo.dispWp = utils.round(100 * jbox.width / this.rowWidth, 2);
|
photo.dispWp = utils.round(100 * jbox.width / this.rowWidth, 2, true);
|
||||||
|
|
||||||
// Move to next index of photo
|
// Move to next index of photo
|
||||||
dataIdx++;
|
dataIdx++;
|
||||||
|
|
|
@ -95,10 +95,12 @@ export function binarySearch(arr: any, elem: any, key?: string) {
|
||||||
* Round a number to N decimal places
|
* Round a number to N decimal places
|
||||||
* @param num Number to round
|
* @param num Number to round
|
||||||
* @param places Number of decimal places
|
* @param places Number of decimal places
|
||||||
|
* @param floor If true, round down instead of to nearest
|
||||||
*/
|
*/
|
||||||
export function round(num: number, places: number) {
|
export function round(num: number, places: number, floor=false) {
|
||||||
const pow = Math.pow(10, places);
|
const pow = Math.pow(10, places);
|
||||||
return Math.round(num * pow) / pow;
|
const int = num * pow;
|
||||||
|
return (floor ? Math.floor : Math.round)(int) / pow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue