Comparing version 0.0.2 to 0.0.3
30
index.js
var mucss = require('mucss'); | ||
var m = require('mumath'); | ||
/** | ||
@@ -80,9 +80,14 @@ * @module | ||
//get relativeTo & parent rectangles | ||
var parent = placee.offsetParent || win; | ||
var parent = placee.offsetParent; | ||
var parentRect = css.offsets(parent); | ||
var parentPaddings = css.paddings(parent); | ||
var parentBorders = css.borders(parent); | ||
//correct parentRect | ||
if (parent === doc.body || parent === root && getComputedStyle(parent).position === 'static') { | ||
parentRect.left = 0; | ||
} | ||
//desirable absolute left | ||
var desirableAbsLeft = placerRect.left + placerRect.width*align - placeeWidth*align; | ||
var desirableLeft = desirableAbsLeft - parentRect.left - placeeMargins.left - parentPaddings.left; | ||
var desirableLeft = placerRect.left + placerRect.width*align - placeeWidth*align + parentBorders.left - parentRect.left - placeeMargins.left - parentPaddings.left; | ||
@@ -108,9 +113,14 @@ css(placee, { | ||
//get relativeTo & parent rectangles | ||
var parent = placee.offsetParent || win; | ||
var parent = placee.offsetParent ; | ||
var parentRect = css.offsets(parent); | ||
var parentPaddings = css.paddings(parent); | ||
var parentBorders = css.borders(parent); | ||
//correct parentRect | ||
if (parent === doc.body || parent === root && getComputedStyle(parent).position === 'static') { | ||
parentRect.top = 0; | ||
} | ||
//desirable absolute top | ||
var desirableAbsTop = placerRect.top + placerRect.height*align - placeeHeight*align; | ||
var desirableTop = desirableAbsTop - parentRect.top - placeeMargins.top - parentPaddings.top; | ||
var desirableTop = placerRect.top + placerRect.height*align - placeeHeight*align + parentBorders.top - parentRect.top - placeeMargins.top - parentPaddings.top; | ||
@@ -129,4 +139,2 @@ css(placee, { | ||
function numerify(value){ | ||
if (!value) return 0; | ||
if (typeof value === 'string') { | ||
@@ -145,6 +153,6 @@ //else parse single-value | ||
} | ||
return parseFloat(value); | ||
} | ||
var num = parseFloat(value); | ||
return num !== undefined ? num : 0.5; | ||
return value; | ||
} |
{ | ||
"name": "aligner", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Align DOM elements", | ||
@@ -22,3 +22,6 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/dfcreative/aligner" | ||
"homepage": "https://github.com/dfcreative/aligner", | ||
"dependencies": { | ||
"mumath": "~0.2.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6672
115
1
+ Addedmumath@~0.2.0
+ Addedmumath@0.2.4(transitive)