{"id":21600033,"url":"https://github.com/derzade/logical-everywhere","last_synced_at":"2025-07-25T10:35:57.023Z","repository":{"id":153244826,"uuid":"616487413","full_name":"DerZade/logical-everywhere","owner":"DerZade","description":"Collection of utilities to work around features that are not fully compatible with logical properties and values (such as translateX, translateY or getBoundingClientRect).","archived":false,"fork":false,"pushed_at":"2025-06-06T11:00:31.000Z","size":413,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T01:59:20.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DerZade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-20T13:38:50.000Z","updated_at":"2025-06-06T11:00:33.000Z","dependencies_parsed_at":"2023-11-15T11:25:08.154Z","dependency_job_id":"d08db820-a5dc-4a99-a479-0498c7c1a3f5","html_url":"https://github.com/DerZade/logical-everywhere","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/DerZade/logical-everywhere","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerZade%2Flogical-everywhere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerZade%2Flogical-everywhere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerZade%2Flogical-everywhere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerZade%2Flogical-everywhere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DerZade","download_url":"https://codeload.github.com/DerZade/logical-everywhere/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerZade%2Flogical-everywhere/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266991122,"owners_count":24017738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T18:17:10.096Z","updated_at":"2025-07-25T10:35:56.990Z","avatar_url":"https://github.com/DerZade.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logical Properties and Values EVERYWHERE [![NPM](https://img.shields.io/npm/v/logical-everywhere?style=flat-square)](https://npmjs.com/package/logical-everywhere)\n\n_Collection of utilities to work around features that are not fully compatible with logical properties and values (such as [`translateX`](https://developer.mozilla.org/docs/Web/CSS/transform-function/translateX), [`translateY`](https://developer.mozilla.org/docs/Web/CSS/transform-function/translateY) or [`getBoundingClientRect`](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect))._\n\n## Motivation\n\nWhen positioning elements with JS, it is difficult to work with logical properties and values in mind. For example, if I want to display a tooltip in the `block-start `direction of an element (usually physically above), I first need to know where the inline and block axes are located in order to then position the tooltip in the correct physical direction (`top`, `left`, `bottom` or `right`):\n\nThis package aims to simplifies this process.\n\n## Installation\n\n```\nnpm i --save logical-everywhere\n```\n\n## Utilities\n\n### `getBoundingClientLogicalRect`\n\nSame as [`getBoundingClientRect`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect), but returns a `LogicalDOMRect`, which includes logical properties (`inlineStart`, `inlineEnd`, `blockStart`, `blockEnd`, `inlineSize` and `blockSize`) in addition to the non-logical properties (`width`, `left` etc.).\n\n```ts\nconst myElement = document.getElementById('my-element');\n\nconst rect = getBoundingClientLogicalRect(myElement);\n\nconsole.log(rect.blockSize); // corresponds to rect.height (in normal conditions)\nconsole.log(rect.inlineStart); // corresponds to rect.left (in normal conditions)\n```\n\n### `getPhysicalDirection`\n\nGet the physical direction that corresponds to the logical direction of a element.\n\n```ts\nconst myElement = document.getElementById('my-element');\n\nconst physicalDirection = getPhysicalDirection(myElement, 'inline-start');\n\nconsole.log(physicalDirection); // prints \"left\" (in normal conditions)\n```\n\n### `getPhysicalFlexAxes`\n\nGet flexbox's [main- and cross-axis](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox#the_two_axes_of_flexbox) as physical axes.\n\n```ts\nconst myElement = document.getElementById('my-element');\n\nmyElement.style.flexDirection = 'row-reverse';\nconst axesRR = getPhysicalFlexAxes(myElement);\nconsole.log(axesRR.main); // prints \"right-left\" (in normal conditions)\n\nmyElement.style.flexDirection = 'column-reverse';\nconst axesCR = getPhysicalFlexAxes(myElement);\nconsole.log(axesCR.main); // prints \"bottom-top\" (in normal conditions)\n```\n\n### `getElementAxes`\n\nGet inline- and block-axis of a HTML element.\n\n```ts\nconst myElement = document.getElementById('my-element');\n\nconst { block, inline } = getElementAxes(myElement);\n\nconsole.log(inline); // prints \"left-right\" (in normal conditions)\nconsole.log(block); // prints \"top-bottom\" (in normal conditions)\n```\n\n### `axisDimensionAndDirection`\n\nGet dimension and direction of a physical axis.\n\nThis is especially useful when trying to calculate a dynamic `translateX` / `translateY`.\n\n```ts\nconst myElement = document.getElementById('my-element');\n\nconst { inline } = getElementAxes(myElement);\n\nconst { dimension, multiplier } = axisDimensionAndDirection(inline);\n\n// Translate 3rem in inline-end direction.\nconst transform = `translate${dimension.toUpperCase()}(${3 * multiplier}rem)`;\n// use -3 instead of 3 to translate to the inline-start direction\n```\n\n### `axisStartEnd`\n\nGet start- and end-direction of a physical axis.\n\n```ts\nconst { start, end } = axisStartEnd('top-bottom');\nconsole.log(start); // prints \"top\"\nconsole.log(end); // prints \"bottom\"\n```\n\n### `reverseAxis`\n\nReverse a physical axis\n\n```ts\nconst reversed = reverseAxis('top-bottom');\n\nconsole.log(reversed); // prints \"bottom-top\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderzade%2Flogical-everywhere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderzade%2Flogical-everywhere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderzade%2Flogical-everywhere/lists"}