summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-07-02 14:36:09 +0100
committerwout <wout@impinc.co.uk>2013-07-02 14:36:09 +0100
commitc30c718d904dc35bd99595ab37d5bb8cac796570 (patch)
tree58774563c7cc8393e21774fae98dc730115efca2 /README.md
parentf492d5d57790e4f3606a3370b1e676a38a9fd7a9 (diff)
downloadsvg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.tar.gz
svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.zip
Added memory module
Diffstat (limited to 'README.md')
-rw-r--r--README.md45
1 files changed, 45 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8ad8ebd..a8c1a27 100644
--- a/README.md
+++ b/README.md
@@ -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: