diff options
author | wout <wout@impinc.co.uk> | 2013-01-27 20:17:17 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-27 20:17:17 +0100 |
commit | fe1747c86d0e562853752ac2b412ed33cd109c4f (patch) | |
tree | ec56684826ca2053ab78d8ef7a29f0f1f1f1f6ae /README.md | |
parent | b72373cf2fc024714825da95c59879ce9cbb4521 (diff) | |
download | svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.tar.gz svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.zip |
Added data() method
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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: |