diff options
| author | Aur??lio A. Heckert <aurium@gmail.com> | 2009-04-27 05:06:46 +0000 |
|---|---|---|
| committer | aurium <aurium@users.sourceforge.net> | 2009-04-27 05:06:46 +0000 |
| commit | a2e35ed3e8497ce5e69a07fb013b66f18d164411 (patch) | |
| tree | da65d0b074d9b410315ead5e8d87eaa0c2c18ece /share/extensions/inkweb.js | |
| parent | BUG 367123: include zlib.h into jar.cpp (diff) | |
| download | inkscape-a2e35ed3e8497ce5e69a07fb013b66f18d164411.tar.gz inkscape-a2e35ed3e8497ce5e69a07fb013b66f18d164411.zip | |
starting a move method for InkWeb.
(bzr r7778)
Diffstat (limited to 'share/extensions/inkweb.js')
| -rw-r--r-- | share/extensions/inkweb.js | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/share/extensions/inkweb.js b/share/extensions/inkweb.js index 5cb48869f..2be2e9b2b 100644 --- a/share/extensions/inkweb.js +++ b/share/extensions/inkweb.js @@ -26,7 +26,7 @@ var InkWeb = { - version: 0.03, + version: 0.04, NS: { svg: "http://www.w3.org/2000/svg", @@ -123,3 +123,45 @@ InkWeb.setAtt = function (conf) { } } +InkWeb.moveElTo = function (startConf) { + if ( typeof(startConf) == "string" ) { + // startConf may be only a element Id, to timeout recursive calls. + var el = document.getElementById( startConf ); + } else { + if ( typeof(startConf.el) == "string" ) + startConf.from = document.getElementById( startConf.el ); + var el = startConf.el; + } + if ( ! el.inkWebMoving ) { + el.inkWebMoving = { + step: 0 + }; + } + var conf = el.inkWebMoving; + if ( conf.step == 0 ) { + conf.x = startConf.x; + conf.y = startConf.y; + // dur : duration of the animation in seconds + if ( startConf.dur ) { conf.dur = startConf.dur } + else { conf.dur = 1 } + // steps : animation steps in a second + if ( startConf.stepsBySec ) { conf.stepsBySec = startConf.stepsBySec } + else { conf.stepsBySec = 16 } + conf.sleep = Math.round( 1000 / conf.stepsBySec ); + conf.steps = conf.dur * conf.stepsBySec; + var startPos = el.getBBox(); + conf.xInc = ( conf.x - startPos.x ) / conf.steps; + conf.yInc = ( conf.y - startPos.y ) / conf.steps; + conf.transform = el.ownerSVGElement.createSVGTransform(); + el.transform.baseVal.appendItem(conf.transform); + } + if ( conf.step < conf.steps ) { + conf.step++; + conf.transform.matrix.e += conf.xInc; + conf.transform.matrix.f += conf.yInc; + conf.timeout = setTimeout( 'InkWeb.moveElTo("'+el.id+'")', conf.sleep ); + } else { + delete el.inkWebMoving; + } +} + |
