2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-06-14 20:16:26 +02:00
|
|
|
export function update_padding(opts: {
|
|
|
|
content_sel: string;
|
|
|
|
padding_sel: string;
|
|
|
|
total_rows: number;
|
|
|
|
shown_rows: number;
|
|
|
|
}): void {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $content = $(opts.content_sel);
|
|
|
|
const $padding = $(opts.padding_sel);
|
2019-11-02 00:06:25 +01:00
|
|
|
const total_rows = opts.total_rows;
|
|
|
|
const shown_rows = opts.shown_rows;
|
|
|
|
const hidden_rows = total_rows - shown_rows;
|
2018-07-26 19:50:15 +02:00
|
|
|
|
|
|
|
if (shown_rows === 0) {
|
2022-01-25 11:36:19 +01:00
|
|
|
$padding.height(0);
|
2018-07-26 19:50:15 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const ratio = hidden_rows / shown_rows;
|
2018-07-26 19:50:15 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const content_height = $content.height();
|
2021-06-14 20:16:26 +02:00
|
|
|
if (content_height === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const new_padding_height = ratio * content_height;
|
2018-07-26 19:50:15 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
$padding.height(new_padding_height);
|
|
|
|
$padding.width(1);
|
2021-02-28 01:12:54 +01:00
|
|
|
}
|