An Element positioning system inspired by SICP's "Propagation of Constraints".
Quick Start
npm installpython -mSimpleHTTPServer
Browse the /examples
directory.
Feature Overview
Constrain properties of an element.
/* Classes are supported */
Interface with JavaScript.
// assign variablesengine;// add user defined functionsengine;engine;
Declare rules inline.
Rule Attributes
left
right
top
bottom
width
height
center-x
center-y
center-in
relative-to
align-x
align-y
size
watch
Element Attributes
uz-rect
uz-style
Special Rects
viewport
body
document
These can be used like any other rect in the system.
Note: user's can create custom rects by extending the Rect
class
.
Setup
The Engine
class
is how the user interacts with the system.
;// assign variables and attach functionsengine.initialize/* options */;
By default, the engine will walk the entire DOM and mount Elements which have an
uz-rect
or uz-style
attribute. This behaviour is configured via an options object passed
into the Engine#initialize
method.
Default Engine Options:
Manually managing Element life-cycle
Element life-cycles can be manually managed using the Engine#mount
and Engine#unmount
methods.
// start managing the element.engine.mountelement;// stop managing the element.engine.unmountelement;
Pre-Compiling
This is still a work in progress.
A cache of all source to compiled rules is kept during runtime. If you export this data, and initialize uzi with it, the parser doesn't need to be sent to the client.
Export:
;
Import:
;
Angular Integration
Angular integration lets you use functions and variables from the $scope
in your rules.
Debugging:
The simplest way to debug is to use the System
class
.
window.system = engine.getSystem;
The System#toString()
method will show all relationships. toString
takes an
optional string parameters which is used to filter the resulting lines.
There is also a System#$
property which uses a Proxy
to provide access to
the underlying variables with support for tab completion.