File: svg-css-transition-compound.html

package info (click to toggle)
qtwebkit 2.3.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 290,116 kB
  • ctags: 272,544
  • sloc: cpp: 1,417,496; python: 85,048; ansic: 39,353; perl: 38,858; ruby: 10,313; objc: 9,505; xml: 8,679; asm: 3,864; yacc: 2,458; sh: 1,237; lex: 813; makefile: 592; java: 228; php: 79
file content (93 lines) | stat: -rw-r--r-- 2,314 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Transition of SVG elements</title>

<style type="text/css" media="screen">
  div {
    -webkit-box-sizing: border-box;
  }
  
  .column {
    margin: 10px;
    display: inline-block;
    vertical-align: top;
  }
  .container {
    position: relative;
    height: 200px;
    width: 200px;
    margin: 10px;
    background-color: silver;
    border: 1px solid black;
  }
  
  .box {
    position: absolute;
    top: 0;
    left: 0;
    height: 60px;
    width: 60px;
    border: 1px dotted black;
    -webkit-transform-origin: top left; /* to match SVG */
  }

  .final {
    border: 1px solid blue;
  }
  
  #target, #ref {
    -webkit-transition-property: -webkit-transform;
    -webkit-transition-duration: 1s;
  }   
</style>

<script type="text/javascript" charset="utf-8">
  var flag = true;
  
  function transition() {
    var svgElm = document.getElementById("target");
    var divElm = document.getElementById("ref");

    if (flag) {
      svgElm.style.webkitTransform = "translate(75px, 25px) scale(2) rotate(45deg)";
      divElm.style.webkitTransform = "translate(75px, 25px) scale(2) rotate(45deg)";
    }
    else {
      svgElm.style.webkitTransform = "translate(0px, 0px) scale(1) rotate(0deg)";
      divElm.style.webkitTransform = "translate(0px, 0px) scale(1) rotate(0deg)";
    }
    flag = !flag;
  }
</script>
</head>
<body>
  <h1>CSS Transition of "-webkit-trasform" property for SVG elements</h1>

  <p>The element below should transition when button is clicked</p> 
  <p>The SVG transition should be identical with the CSS one</p>

  <input type="button" value="Transition" onclick="transition()" />

  <div class="column">
    <h2>SVG compound</h2>
    <div class="container">
      <svg xmlns="http://www.w3.org/2000/svg" version="1.1"  
          viewBox="0 0 200 200" style="width:200px; height:200px;">
        <rect id="target" x="0" y="0" width="60" height="60" stroke="blue" fill="none">
        </rect>
      </svg>
    </div>

    <h2>CSS compound</h2>
    <div class="container">
      <div class="final box" id="ref">
      </div>
    </div>
  </div>

</body>
</html>