Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Cross-browser JavaScript dimensions module
JavaScript
Branch: master
Failed to load latest commit information.
src 3.0.0: New leaner API
test 3.0.0: New leaner API
.gitignore 3.0.0: New leaner API
GruntFile.js 3.0.0: New leaner API
README.md 3.0.0: New leaner API
dime.js 3.0.0: New leaner API
dime.min.js 3.0.0: New leaner API
package.json Remove "nodes" tag.

README.md

dime

cross-browser JavaScript module to measure dimensions

$ npm install dime

API (3.0)

Static methods

Fast simple top-level methods

dime.width(object) // get width
dime.height(object) // get height
dime.width(element, px) // set width
dime.height(element, px) // set height

Measurable objects

  • window
  • DOM node: document or element
  • object with .width/.height properties or methods
dime.width(screen) // => screen.width
dime.width({width:10, height:10}) // => 10

Chain methods

jQueryish methods for compatible libs (such as ender)

.width() // get the width of the 1st elem in the set
.width(value) // set the width of all elems in the set
.height() // get the width of the 1st elem in the set
.height(value) // set the width of all elems in the set

Integrated usage

$(window).width()
$(document).width()
$(element).width()
$(element).width(100)

Standalone usage

dime.fn.width.call(stack)
dime.fn.width.call(stack, px)

Standalone examples

It is only sensible to use these for setting dimensions—the statics are faster for gets.

dime.fn.width.call([document]) // same as dime.width(document)
dime.fn.width.call(document.querySelectorAll('.example'), 100)

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

License: MIT

Copyright (C) 2012 by Ryan Van Etten

Something went wrong with that request. Please try again.