New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

math-cover

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-cover

Calculates the size and the position of a target to fit a container, adjusted to keep a focus point

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

math-cover

Calculates the size and the position of a target to fit a container, adjusted to keep a focus point

A mix of jquery-focuspoint and math-fit

Install

npm i math-cover

Examples

Without focus point

var cover = require('math-cover')

var target = {
  w: 200,
  h: 100
}
var parent = {
  w: 100,
  h: 200
}

// {left: -150, top: 0, width: 400, height: 200, scale: 2, position: '50% 50%'}
var obj = cover(target, parent)

With focus point

Params x and y are ratio of target.w and target.h and must be 0 <= ratio <= 1

var cover = require('math-cover')

var target = {
  w: 200,
  h: 100,
  x: .2,
  y: .2
}
var parent = {
  w: 100,
  h: 200
}

// {left: -30, top: 0, width: 400, height: 200, scale: 2, position: '10% 50%'}
var obj = cover(target, parent)

Demo

demo

npm i && npm start
KeydownAction
wrandom width
hrandom height
urandom width + height
irandom image
d or spacetoggle debug

Thanks

Mainly forked / inspired on jquery-focuspoint and math-fit

License

MIT

Keywords

math

FAQs

Package last updated on 18 Mar 2016

Did you know?

Socket

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.

Install

Related posts