
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
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(forceUpdate = false)
: Manually trigger remeasurement, usually not needed to call manually. If forceUpdate
is true, it will emit the event even if the value is the same as the previous valuecleanup()
: 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 the results of :empty
, :has
, ::last-child
or other pseudo-class selectorscleanup()
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 0 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.