You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
578 B
31 lines
578 B
import type { Position } from 'css-box-model';
|
|
import { subtract } from './position';
|
|
|
|
interface Args {
|
|
scrollHeight: number;
|
|
scrollWidth: number;
|
|
height: number;
|
|
width: number;
|
|
}
|
|
|
|
export default ({
|
|
scrollHeight,
|
|
scrollWidth,
|
|
height,
|
|
width,
|
|
}: Args): Position => {
|
|
const maxScroll: Position = subtract(
|
|
// full size
|
|
{ x: scrollWidth, y: scrollHeight },
|
|
// viewport size
|
|
{ x: width, y: height },
|
|
);
|
|
|
|
const adjustedMaxScroll: Position = {
|
|
x: Math.max(0, maxScroll.x),
|
|
y: Math.max(0, maxScroll.y),
|
|
};
|
|
|
|
return adjustedMaxScroll;
|
|
};
|