diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2016-01-28 16:30:12 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2016-01-28 16:30:12 +0100 |
commit | be83a8f382cf2fea98161bfd6d51719aacbf9aa9 (patch) | |
tree | 3fb02337f8d7d308ef7ca7818ecc3d3a6ee05d88 /afm-client/bower_components/tether/docs/3-Advanced | |
parent | 1a4ed39bf86b2115eb0f1387d1e988462b492776 (diff) |
Update JSON API
Diffstat (limited to 'afm-client/bower_components/tether/docs/3-Advanced')
-rw-r--r-- | afm-client/bower_components/tether/docs/3-Advanced/1-embedding_tether.md | 9 | ||||
-rw-r--r-- | afm-client/bower_components/tether/docs/3-Advanced/2-extending_tether.md | 54 |
2 files changed, 63 insertions, 0 deletions
diff --git a/afm-client/bower_components/tether/docs/3-Advanced/1-embedding_tether.md b/afm-client/bower_components/tether/docs/3-Advanced/1-embedding_tether.md new file mode 100644 index 0000000..f47be16 --- /dev/null +++ b/afm-client/bower_components/tether/docs/3-Advanced/1-embedding_tether.md @@ -0,0 +1,9 @@ +## Embedding Tether + +Tether is designed to be embeddable in other libraries. + +There is one thing you should think about doing to create an embedded Tether: + +- Set the `classPrefix` of the tethers you create. That prefix will replace `'tether'` in +all of the classes. You can also disable classes you don't intend on using with the `classes` +option. diff --git a/afm-client/bower_components/tether/docs/3-Advanced/2-extending_tether.md b/afm-client/bower_components/tether/docs/3-Advanced/2-extending_tether.md new file mode 100644 index 0000000..6a13e68 --- /dev/null +++ b/afm-client/bower_components/tether/docs/3-Advanced/2-extending_tether.md @@ -0,0 +1,54 @@ +Extending Tether +----- + +Tether has a module system which can be used to modify Tether's positioning, or just do something each time the Tether is moved. + +Tether has an array called `Tether.modules`, push onto it to add a module: + +```coffeescript +Tether.modules.push + position: ({top, left}) -> + top += 10 + + {top, left} +``` + +#### Position + +Your position function can either return a new object with `top` and `left`, `null`/`undefined` to leave the coordinates unchanged, or +`false` to cancel the positioning. + +The position function is passed an object with the following elements: + +```javascript +{ + left, // The element's new position, from the top left corner of the page + top, + targetAttachment, // The targetAttachment, with 'auto' resolved to an actual attachment + targetPos, // The coordinates of the target + attachment, // The attachment, as passed in the option + elementPos, // The coordinates of the element + offset, // The offset, after it's converted into pixels and the manual offset is added + targetOffset, // The attachment is converted into an offset and is included in these values + manualOffset, // The manual offset, in pixels + manualTargetOffset +} +``` + +It is called with the Tether instance as its context (`this`). + +#### Initialize + +Modules can also have an `initialize` function which will be called when a new tether is created. The initialize function +is also called with the Tether instance as its context. + +```coffeescript +Tether.modules.push + initialize: -> + console.log "New Tether Created!", @ +``` + +#### Examples + +[Constraints](https://github.com/HubSpot/tether/blob/master/coffee/constraint.coffee) and [shift](https://github.com/HubSpot/tether/blob/master/coffee/shift.coffee) are both implemented as modules. +[Mark Attachment](https://github.com/HubSpot/tether/blob/master/coffee/markAttachment.coffee) is used by the docs. |