UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

44 lines (43 loc) 1.45 kB
/** * DevExtreme (esm/renovation/ui/scroll_view/utils/get_boundary_props.js) * Version: 21.2.3 * Build date: Thu Oct 28 2021 * * Copyright (c) 2012 - 2021 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { getScrollLeftMax } from "./get_scroll_left_max"; import { getScrollTopMax } from "./get_scroll_top_max"; import { ScrollDirection } from "./scroll_direction"; export function isReachedRight(element, scrollOffsetLeft) { return Math.round(getScrollLeftMax(element) - scrollOffsetLeft) <= 0 } export function isReachedBottom(element, scrollOffsetTop, pocketHeight) { return Math.round(getScrollTopMax(element) - scrollOffsetTop - pocketHeight) <= 0 } export function getBoundaryProps(direction, scrollOffset, element, pocketHeight) { var { left: left, top: top } = scrollOffset; var boundaryProps = {}; var { isHorizontal: isHorizontal, isVertical: isVertical } = new ScrollDirection(direction); if (isHorizontal) { boundaryProps.reachedLeft = Math.round(left) <= 0; boundaryProps.reachedRight = isReachedRight(element, left) } if (isVertical) { boundaryProps.reachedTop = Math.round(top) <= 0; boundaryProps.reachedBottom = isReachedBottom(element, top, pocketHeight) } return boundaryProps }