Giter Club home page Giter Club logo

dime's Introduction

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

dime's People

Contributors

ryanve avatar

Stargazers

 avatar Param Siddharth avatar  avatar Adrienne L. Travis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.