Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
logical-everywhere
Advanced tools
Collection of utilities to work around features that are not fully compatible with logical properties and values (such as translateX, translateY or getBoundingClientRect).
Collection of utilities to work around features that are not fully compatible with logical properties and values (such as translateX
, translateY
or getBoundingClientRect
).
When 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
):
This package aims to simplifies this process.
npm i --save logical-everywhere
getPhysicalDirection
Get the physical direction that corresponds to the logical direction of a element.
const myElement = document.getElementById('my-element');
const physicalDirection = getPhysicalDirection(myElement, 'inline-start');
console.log(physicalDirection); // prints "left"
getPhysicalFlexAxes
Get flexbox's main- and cross-axis as physical axes.
const myElement = document.getElementById('my-element');
myElement.style.flexDirection = 'row-reverse';
const axesRR = getPhysicalFlexAxes(myElement);
console.log(axesRR.main); // prints "right-left"
myElement.style.flexDirection = 'column-reverse';
const axesCR = getPhysicalFlexAxes(myElement);
console.log(axesCR.main); // prints "bottom-top"
getElementAxes
Get inline- and block-axis of a HTML element.
const { block, inline } = getElementAxes(myElement);
console.log(inline); // prints "left-right"
console.log(block); // prints "top-bottom"
axisDimensionAndDirection
Get dimension and direction of a physical axis.
This is especially useful when trying to calculate a dynamic translateX
/ translateY
.
const myElement = document.getElementById('my-element');
const { inline } = getElementAxes(myElement);
const { dimension, multiplier } = axisDimensionAndDirection(inline);
// Translate 3rem in inline-end direction.
const transform = `translate${dimension.toUpperCase()}(${3 * multiplier}rem)`;
// use -3 instead of 3 to translate to the inline-start direction
axisStartEnd
Get start- and end-direction of a physical axis.
const { start, end } = axisStartEnd('top-bottom');
console.log(start); // prints "top"
console.log(end); // prints "bottom"
reverseAxis
Reverse a physical axis
const reversed = reverseAxis('top-bottom');
console.log(reversed); // prints "bottom-top"
FAQs
Collection of utilities to work around features that are not fully compatible with logical properties and values (such as translateX, translateY or getBoundingClientRect).
The npm package logical-everywhere receives a total of 13 weekly downloads. As such, logical-everywhere popularity was classified as not popular.
We found that logical-everywhere demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.