Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-box-model

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-box-model - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

4

package.json
{
"name": "css-box-model",
"version": "0.0.11",
"version": "0.0.12",
"description": "Returns the css box model for a HTMLElement",

@@ -33,3 +33,3 @@ "author": "Alex Reardon <alexreardon@gmail.com>",

"babel-preset-flow": "^6.23.0",
"flow-bin": "^0.69.0",
"flow-bin": "^0.70.0",
"jest": "^22.4.3",

@@ -36,0 +36,0 @@ "prettier": "1.12.0",

# CSS box model 📦
> Get the [CSS Box Model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model) for a [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
> Get detailed [CSS Box Model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model) information about a [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)

@@ -152,1 +152,66 @@ This library is useful for when you need to obtain detailed positioning information about an element. Any time you are using [`Element.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) you might want to consider using `css-box-model` instead to get more detailed information.

```
### `createBox`
> `({ borderBox, margin, border, padding }: CreateBoxArgs) => BoxModel`
Allows you to create a `BoxModel` by passing in a `Rect` like shape and optionally your own `margin`, `border` and or `padding`.
```js
type CreateBoxArgs = {|
borderBox: AnyRectType,
margin?: Spacing,
border?: Spacing,
padding?: Spacing,
|};
```
```js
const borderBox: Spacing = {
top: 10,
right: 100,
left: 20,
bottom: 80,
};
const padding: Spacing = {
top: 10,
right: 20,
left: 20,
bottom: 10,
};
const box: BoxModel = createBox({ borderBox, padding });
```
### `getRect`
> `(spacing: AnyRectType) => Rect`
Given any `Rect` like shape, return a `Rect`
```js
const spacing: Spacing = {
top: 0,
right: 100,
bottom: 50,
left: 50,
};
const rect: Rect = getRect(spacing);
console.log(rect);
/*
{
top: 0,
right: 100,
bottom: 50,
left: 50,
width: 100,
height: 50,
x: 0,
y: 0,
center: { x: 50, y: 50 },
}
*/
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc