| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" |
| 3 |
"http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd"> |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--> |
| 23 |
<!-- ====================================================================== --> |
| 24 |
<!-- Modification of a rect's x attribute repeatedly starting from an --> |
| 25 |
<!-- 'onclick' event handler. --> |
| 26 |
<!-- --> |
| 27 |
<!-- @author [email protected] --> |
| 28 |
<!-- @version $Id$ --> |
| 29 |
<!-- ====================================================================== --> |
| 30 |
|
| 31 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 32 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 33 |
<title><rect> x Animation in 'onclick'</title> |
| 34 |
|
| 35 |
<text x="50%" y="45" class="title"><rect> x Animation in 'onclick'</text> |
| 36 |
|
| 37 |
<script type="text/ecmascript"> |
| 38 |
var t, start, end, inc, cont, frac=0; |
| 39 |
|
| 40 |
function startAnim(evt, target, xStart, xEnd){ |
| 41 |
if (cont == 1) return; |
| 42 |
t = document.getElementById(target); |
| 43 |
start = xStart |
| 44 |
end = xEnd; |
| 45 |
cont = 1; |
| 46 |
cyclopse(); |
| 47 |
} |
| 48 |
|
| 49 |
function stopAnim(evt) { |
| 50 |
cont = 0; |
| 51 |
} |
| 52 |
|
| 53 |
function cyclopse() { |
| 54 |
t.setAttribute('x', (end-start)*frac/100+start); |
| 55 |
if (frac == 100) inc = -2; |
| 56 |
if (frac == 0) inc = 2; |
| 57 |
frac += inc; |
| 58 |
if (cont == 1) |
| 59 |
setTimeout('cyclopse()', 50); |
| 60 |
} |
| 61 |
</script> |
| 62 |
|
| 63 |
<g id="test-content"> |
| 64 |
<g transform="translate(75,125)"> |
| 65 |
<text class="legend" x="75" y="70">Position A</text> |
| 66 |
|
| 67 |
<rect id="originalPlaceShadowBorder" stroke="black" fill="none" |
| 68 |
x="32" y="77" width="86" height="46" /> |
| 69 |
|
| 70 |
<g> |
| 71 |
<circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/> |
| 72 |
<line x1="75" x2="75" y1="90" y2="110" style="stroke:black;fill:none" /> |
| 73 |
<line x1="65" x2="85" y1="100" y2="100" style="stroke:black;fill:none" /> |
| 74 |
</g> |
| 75 |
</g> |
| 76 |
|
| 77 |
<g transform="translate(225,125)"> |
| 78 |
<text class="legend" x="75" y="70">Position B</text> |
| 79 |
|
| 80 |
<rect id="targetPlaceShadowBorder" fill="lightBlue" stroke="black" |
| 81 |
x="32" y="77" width="86" height="46"/> |
| 82 |
|
| 83 |
<g > |
| 84 |
<circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/> |
| 85 |
<line x1="75" x2="75" y1="90" y2="110" style="stroke:black;fill:none" /> |
| 86 |
<line x1="65" x2="85" y1="100" y2="100" style="stroke:black;fill:none" /> |
| 87 |
</g> |
| 88 |
</g> |
| 89 |
|
| 90 |
<g id="play" onclick="startAnim(evt, 'targetRect', 110, 260)" |
| 91 |
stroke="black" fill="#DDD" transform="translate(160, 260)" > |
| 92 |
<rect x="0" y="0" width="50" height="40" rx="5" ry="5"/> |
| 93 |
<polygon fill="green" points="10,10 40,20 10,30"/> |
| 94 |
</g> |
| 95 |
|
| 96 |
<g id="play" onclick="stopAnim(evt)" |
| 97 |
stroke="black" fill="#DDD" transform="translate(240, 260)" > |
| 98 |
<rect x="0" y="0" width="50" height="40" rx="5" ry="5"/> |
| 99 |
<rect fill="yellow" x="10" y="10" width="10" height="20"/> |
| 100 |
<rect fill="yellow" x="30" y="10" width="10" height="20"/> |
| 101 |
</g> |
| 102 |
|
| 103 |
<rect id="targetRect" x="110" y="205" width="80" height="40" style="fill:red;fill-opacity:0.5" /> |
| 104 |
|
| 105 |
<text class="legend"> |
| 106 |
<tspan x="225" y="330">Click on Play button (green triangle) to start animation</tspan> |
| 107 |
<tspan x="225" y="345">Click on Pause button (yellow rects) to stop animation</tspan></text> |
| 108 |
</g> |
| 109 |
</svg> |