
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
css-surveyor
Advanced tools
English | δΈζ
Easily calculate pixel values for CSS length expressions
npm i css-surveyor
import { CssSurveyor } from 'css-surveyor'
const surveyor = new CssSurveyor()
surveyor.widthExpr = '100%'
surveyor.heightExpr = 'calc(100vh - 50px)'
console.log(surveyor.width, surveyor.height)
surveyor.events.on('widthChanged', w => console.log('Width updated to:', w))
surveyor.events.on('heightChanged', h => console.log('Height updated to:', h))
// Call cleanup method to release resources when no longer in use
surveyor.cleanup()
new CssSurveyor(connectTo?: HTMLElement | string | null)
connectTo
: Optional parameter specifying the element to connect to. Subsequent size calculations will be based on this element.
document.querySelector
to find the elementdocument.body
connect
method laterconnect(elemOrSelector?: HTMLElement | string)
: Connect to the specified element. Same as constructor parameter but cannot be nulldisconnect()
: Disconnect from the current elementremeasure()
: Manually trigger remeasurement, usually not needed to call manuallycleanup()
: Call this function when no longer in use. It will disconnect and clear all event listenerswidthExpr?: string
: Get or set the width expressionheightExpr?: string
: Get or set the height expressionwidth: number
: Get the currently measured widthheight: number
: Get the currently measured heightconnected?: HTMLElement
: Get the currently connected elementevents
: Event emitter for subscribing to widthChanged
and heightChanged
events. Refer to mittdiv
element for measurements, which won't affect page layout but may impact :empty
pseudo-class selector resultscleanup()
method when monitoring is no longer needed to release resourceswidthExpr
and heightExpr
expressions because CSS percentage values may reference either width or height. So if the expression you want to calculate doesn't include percentage values, it doesn't matter which one you useFAQs
Easily calculate pixel values for CSS length expressions
The npm package css-surveyor receives a total of 6 weekly downloads. As such, css-surveyor popularity was classified as not popular.
We found that css-surveyor 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.