
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Quantpos makes FLIP (First Last Invert Play) simple !
It handles all the transform part of the FLIP method.
npm package : https://www.npmjs.com/package/quantpos
github repo : https://github.com/hl037/quantpos
The main usage of this library is to move an html element at another place in the DOM while retaining its graphical position.
import {getGlobalMat, setGlobalMat} from 'quantpos'
// let el = document.getElementById('my-el')
let mat = getGlobalMat(el)
(Using either method you want)
// let el = document.getElementById('my-el')
setGlobalMat(el, mat)
And you're done !
(See Advanced pattern for FLIP animation)
one of these three commands :
npm install quantpos
pnpm add quantpos
yarn add quantpos
...You know better than me =)
The matrix class is from rematrix
https://github.com/jlmakes/rematrix
All rematrix functions are forward-exported.
The following functions are patches or additions :
type Coords2D = [number, number]
type Coords3D = [number, number, number]
type Coords4D = [number, number, number, number]
type Coords = Coords2D | Coords3D | Coords4D
Apply a matrix to a vector (matrix multiplication with a vector)
NOTE : The result is not normalized (the 4th coordinate may not be 1). Call normalize()
on the result if you want to use it (as an optimization, you can chain matrix multiplications before normalizing though).
Normalize a vector x
. This function always returns a Coords4D
. If a Coords2D
or Coords3D
are passed, it returns the same vector with 4th coordinate set to 1 and 3rd to 0 if not provided.
Create a translation matrix for x. This deffers from the rematrix implementation because this one function handles all thes cases.
You can either pass an array (Coords
) as the only argument, either pass each coordinates as up to 4 arguments.
Retrieve the global matrix of the element
Set an element transform matrix so that its global matrix matches m
Compute the matrix to be assigned to the transform
CSS property of el
so that its global matrix matches m
Retrieve the current (raw) transform matrix of el
(from getComputedStyle
)
Set m
as the transform
CSS property matrix value
Compute a transition matrix to translate coordinates from the old space to the new space. See https://en.wikipedia.org/wiki/Change\_of\_basis (here, new and old are swapped because you generally want to express the new coordinate as a function of the old)
The matrices to pass to this function are the global matrice of the elements, that you can get from getGlobalMat()
This class is a helper to translate coordinates from an element to another.
Transition matrix from b to a why "ab" ? Because : X_a = T_ab X_b where X_a is the position expressed in basis A and X_b is the position expressed in basis B. This way, in the equation, a is near a and b is near b.
CoordTranslator.T_ab
inverted
The constructor accept matrices to be more general. m_a
and m_b
are global transformation matrices. They repectively represents the basis A and the basis B.
Shortcut that simply does :
return new CoordTranslator(
el_a ? getGlobalMat(el_a) : M.identity(),
el_b ? getGlobalMat(el_b) : M.identity()
)
From x_a
, expressed in basis A, compute the equivalent coordinates in basis B.
From x_b
, expressed in basis B, compute the equivalent coordinates in basis A.
To do a real FLIP animation, you would generally get the current position of the element (gm1 = getGlobalMat(el)
), move your element in the DOM to its finale location, and retrieve its (new) current location (m2 = getMat(el)
). Then compute the matrix for the original position (m1 = toLocal(el, gm1
).
Finally, pass to your favorite animation framework m1
and m2
ans the start and final value of your animation.
FAQs
A Library to manipulate element matrices and ease FLIP animations
The npm package quantpos receives a total of 0 weekly downloads. As such, quantpos popularity was classified as not popular.
We found that quantpos demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.