dime
module to measure dimensions
cross-browser JavaScript$ npm install dime
3.0)
API (Static methods
Fast simple top-level methods
dimewidthobject // get widthdimeheightobject // get heightdimewidthelement px // set widthdimeheightelement px // set height
Measurable objects
window
- DOM node:
document
or element - object with
.width
/.height
properties or methods
dimewidthscreen // => screen.widthdimewidthwidth:10 height:10 // => 10
Chain methods
ender)
jQueryish methods for compatible libs (such aswidth // get the width of the 1st elem in the setwidthvalue // set the width of all elems in the setheight // get the width of the 1st elem in the setheightvalue // set the width of all elems in the set
Integrated usage
widthwidthwidthwidth100
Standalone usage
dimefnwidthdimefnwidth
Standalone examples
It is only sensible to use these for setting dimensions—the statics are faster for gets.
dimefnwidth // same as dime.width(document)dimefnwidth
Version notes
3.x is leaner than previous releases
- 2.x device methods were removed because the native
screen
provides these. - 2.x viewport methods were removed in favor of
dime.width(window)
although those methods are available in verge. - In 3.x
dime
is a plain object—not a wrapper function.
Related modules
- verge: viewport utilities
Resources
MIT
License:Copyright (C) 2012 by Ryan Van Etten