/**
* Placer
* Places any element relative to any other element the way you define
*/

module.exports = place;

var css = require('mucss');

var win = window;

//default options
var defaults = {
	//source to align relatively to
	//element/{x,y}/[x,y]/
	relativeTo: window,

	//which side to palce element
	//t/r/b/l, 'center' ( === undefined),
	side: 'center',

	//intensity of alignment
	//left, center, right, top, bottom, 0..1
	align: 0.5,

	//selector/nodelist/node/[x,y]/window/function(el)
	avoid: undefined,

	//selector/nodelist/node/[x,y]/window/function(el)
	within: window
};

//set of position placers
var placeBySide = {
	center: function(placee, rect){
		var center = [(rect[2] + rect[0]) / 2, (rect[3] + rect[1]) / 2];
		var width = placee.offsetWidth;
		var height = placee.offsetHeight;
		css(placee, {
			top: (center[1] - height/2),
			left: (center[0] - width/2)
		});
	},

	left: function(el, rect){

	},

	right: function(el, rect){

	},

	top: function(el, rect){

	},

	bottom: function(el, rect){
		var width = el.offsetWidth;
		var height = el.offsetHeight;
		css(placee, {
			left: rect[0],
			top: rect[3]
		});
	}
};


//place element relative to the target on the side
function place(element, options){
	options = options || {};

	//get target rect to align
	var target = options.relativeTo || defaults.relativeTo;
	var targetRect;

	if (target === win) {
		targetRect = [0, 0, win.innerWidth, win.innerHeight];
	}
	else if (target instanceof Element) {
		var rect = target.getBoundingClientRect();
		targetRect = [rect.left, rect.top, rect.right, rect.bottom];
	}
	else if (typeof target === 'string'){
		var targetEl = document.querySelector(target);
		if (!targetEl) return false;
		// var rect;
	}

	//align according to the position
	var side = options.side || defaults.side;

	placeBySide[side](element, targetRect);
}
@@ -1146,10 +1146,15 @@
 %0A%0A%0A/
-/p
+**%0A * P
 lace
@@ -1185,18 +1185,18 @@
  target 
-on
+by
  the sid
@@ -1196,16 +1196,185 @@
 the side
+ & params passed.%0A *%0A * @param %7BElement%7D element An element to place%0A * @param %7Bobject%7D options Options object%0A *%0A * @return %7BElement%7D Placed element to chain calls%0A */%0A
 %0Afunctio
@@ -1608,16 +1608,74 @@
 Height%5D;
+%0A%0A%09%09//fix the position%0A%09%09element.style.position = 'fixed';
 %0A%09%7D%0A%09els
@@ -1726,37 +1726,26 @@
 t = 
-target.getBoundingClientRect(
+css.offsets(target
 );%0A%09
@@ -1805,16 +1805,160 @@
 bottom%5D;
+%0A%0A%09%09//set the position as of the target%0A%09%09if (css.isFixed(target)) element.style.position = 'fixed';%0A%09%09else element.style.position = 'absolute';
 %0A%09%7D%0A%09els
@@ -2087,16 +2087,25 @@
 r rect;%0A
+%09%09//TODO%0A
 %09%7D%0A%0A%09//a
@@ -2219,10 +2219,28 @@
 etRect);
+%0A%0A%09return element;
 %0A%7D

Add fixed detection