UNPKG

react-aria

Version:
58 lines (52 loc) 2.2 kB
var $b07dd3d1fedd87d6$exports = require("./utils.cjs"); function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "DOMLayoutDelegate", function () { return $0e21c65e8f2fcfc9$export$8f5ed9ff9f511381; }); /* * Copyright 2024 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ class $0e21c65e8f2fcfc9$export$8f5ed9ff9f511381 { constructor(ref){ this.ref = ref; } getItemRect(key) { let container = this.ref.current; if (!container) return null; let item = key != null ? (0, $b07dd3d1fedd87d6$exports.getItemElement)(this.ref, key) : null; if (!item) return null; let containerRect = container.getBoundingClientRect(); let itemRect = item.getBoundingClientRect(); return { x: itemRect.left - containerRect.left - container.clientLeft + container.scrollLeft, y: itemRect.top - containerRect.top - container.clientTop + container.scrollTop, width: itemRect.width, height: itemRect.height }; } getContentSize() { let container = this.ref.current; return { width: container?.scrollWidth ?? 0, height: container?.scrollHeight ?? 0 }; } getVisibleRect() { let container = this.ref.current; return { x: container?.scrollLeft ?? 0, y: container?.scrollTop ?? 0, width: container?.clientWidth ?? 0, height: container?.clientHeight ?? 0 }; } } //# sourceMappingURL=DOMLayoutDelegate.cjs.map