aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-01-27 20:17:17 +0100
committerwout <wout@impinc.co.uk>2013-01-27 20:17:17 +0100
commitfe1747c86d0e562853752ac2b412ed33cd109c4f (patch)
treeec56684826ca2053ab78d8ef7a29f0f1f1f1f6ae /README.md
parentb72373cf2fc024714825da95c59879ce9cbb4521 (diff)
downloadsvg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.tar.gz
svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.zip
Added data() method
Diffstat (limited to 'README.md')
-rw-r--r--README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index e4dfa53..78facd8 100644
--- a/README.md
+++ b/README.md
@@ -649,6 +649,26 @@ SVG.off(window, 'click', click);
Available events are `click`, `dblclick`, `mousedown`, `mouseup`, `mouseover`, `mouseout`, `mousemove`, `touchstart`, `touchend`, `touchmove` and `touchcancel`.
+## Data
+The `data()` method allows you to bind arbitrary objects, strings and numbers to SVG elements:
+
+```javascript
+rect.data('key', { value: { data: 0.3 }});
+```
+
+Fetching the values is similar to the `attr()` method:
+
+```javascript
+rect.data('key');
+```
+
+Removing the data altogether:
+
+```javascript
+rect.data('key', null);
+```
+
+
## Extending functionality
Svg.js has a modular structure. It is very easy to add you own methods at different levels. Let's say we want to add a method to all shape types then we would add our method to SVG.Shape:
@@ -692,6 +712,7 @@ SVG.extend(SVG.Doc, {
});
```
+
## Plugins
Here are a few nice plugins that are available for svg.js: