diff options
author | wout <wout@impinc.co.uk> | 2013-07-02 14:36:09 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-07-02 14:36:09 +0100 |
commit | c30c718d904dc35bd99595ab37d5bb8cac796570 (patch) | |
tree | 58774563c7cc8393e21774fae98dc730115efca2 /README.md | |
parent | f492d5d57790e4f3606a3370b1e676a38a9fd7a9 (diff) | |
download | svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.tar.gz svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.zip |
Added memory module
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -1142,6 +1142,51 @@ rect.data('key', 'value', true) ``` +## Memory + +### Remember +Storing data in-memory is very much like setting attributes: + +```javascript +rect.remember('oldBBox', rect.bbox()) +``` + +Multiple values can also be remembered at once: + +```javascript +rect.remember({ + oldFill: rect.attr('fill') +, oldStroke: rect.attr('stroke') +}) +``` + +To retrieve a memory + +```javascript +rect.remember('oldBBox') +``` + + +### Forget +Erasing a single memory: + +```javascript +rect.forget('oldBBox') +``` + +Or erasing multiple memories at once: + + +```javascript +rect.forget('oldFill', 'oldStroke') +``` + +And finally, just erasing the whole memory: + +```javascript +rect.forget() +``` + ## 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: |