1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { __awaiter, __generator } from "tslib";
- import { useComponent } from 'functional-mini/component';
- import { getInstanceBoundingClientRect } from '../jsapi/get-instance-bounding-client-rect';
- export var useInstanceBoundingClientRect = function () {
- var instance = useComponent();
- function getInstance() {
- if (instance.$id) {
- return my;
- }
- return instance;
- }
- function getBoundingClientRectWithId(prefix) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, getInstanceBoundingClientRect(getInstance(), "".concat(prefix).concat(instance.$id ? "-".concat(instance.$id) : ''))];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- }
- function getBoundingClientRect(query) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, getInstanceBoundingClientRect(getInstance(), query)];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- }
- function getBoundingClientRectWithBuilder(builder) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, getInstanceBoundingClientRect(getInstance(), builder(instance.$id ? "-".concat(instance.$id) : ''))];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- }
- return {
- getBoundingClientRect: getBoundingClientRect,
- getBoundingClientRectWithId: getBoundingClientRectWithId,
- getBoundingClientRectWithBuilder: getBoundingClientRectWithBuilder,
- };
- };
|