1e41f4b71Sopenharmony_ci# animateTransform 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci> **说明:** 5e41f4b71Sopenharmony_ci> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_citransform动效,支持的组件范围: 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci<circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, <rect>, <text> 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## 权限列表 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci无 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## 子组件 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci不支持。 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci## 属性 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci支持animate属性和以下表格中的属性。 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| 名称 | 类型 | 默认值 | 必填 | 描述 | 27e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 28e41f4b71Sopenharmony_ci| type | [translate \| scale \| rotate \| skewX \| skewY] | - | 是 | 设置transform动画的类型 | 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci## 示例 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci```html 34e41f4b71Sopenharmony_ci<!-- xxx.hml --> 35e41f4b71Sopenharmony_ci<div class="container"> 36e41f4b71Sopenharmony_ci <div class="back_container"> 37e41f4b71Sopenharmony_ci <svg> 38e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="red"> 39e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 120 140" to="360 360 420" dur="3s" repeatCount="indefinite"></animateTransform> 40e41f4b71Sopenharmony_ci </polygon> 41e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="red"> 42e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animateTransform> 43e41f4b71Sopenharmony_ci </polygon> 44e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="green"> 45e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="scale" from="1" to="2" dur="3s" repeatCount="indefinite"></animateTransform> 46e41f4b71Sopenharmony_ci </polygon> 47e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="green"> 48e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="scale" from="1 1" to="2 4" dur="3s" repeatCount="indefinite"></animateTransform> 49e41f4b71Sopenharmony_ci </polygon> 50e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="#D2691E"> 51e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewX" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform> 52e41f4b71Sopenharmony_ci </polygon> 53e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="#D2691E"> 54e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewY" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform> 55e41f4b71Sopenharmony_ci </polygon> 56e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="#D2691E"> 57e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewX" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform> 58e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewY" from="10" to="100" dur="3s" repeatCount="indefinite"></animateTransform> 59e41f4b71Sopenharmony_ci </polygon> 60e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="blue"> 61e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" dur="3s" repeatCount="indefinite"></animateTransform> 62e41f4b71Sopenharmony_ci </polygon> 63e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="blue"> 64e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0 0" to="0 300" dur="3s" repeatCount="indefinite"></animateTransform> 65e41f4b71Sopenharmony_ci </polygon> 66e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="blue"> 67e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0 0" to="300 300" dur="3s" repeatCount="indefinite"></animateTransform> 68e41f4b71Sopenharmony_ci </polygon> 69e41f4b71Sopenharmony_ci </svg> 70e41f4b71Sopenharmony_ci </div> 71e41f4b71Sopenharmony_ci</div> 72e41f4b71Sopenharmony_ci``` 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci```css 75e41f4b71Sopenharmony_ci/* xxx.css */ 76e41f4b71Sopenharmony_ci.container { 77e41f4b71Sopenharmony_ci flex-direction: column; 78e41f4b71Sopenharmony_ci justify-content: flex-start; 79e41f4b71Sopenharmony_ci align-items: flex-start; 80e41f4b71Sopenharmony_ci background-color: #f8f8ff; 81e41f4b71Sopenharmony_ci} 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci.back_container { 84e41f4b71Sopenharmony_ci flex-direction: row; 85e41f4b71Sopenharmony_ci justify-content: flex-start; 86e41f4b71Sopenharmony_ci align-items: flex-start; 87e41f4b71Sopenharmony_ci height: 1000px; 88e41f4b71Sopenharmony_ci width: 1080px; 89e41f4b71Sopenharmony_ci} 90e41f4b71Sopenharmony_ci``` 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci动画叠加 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci```html 100e41f4b71Sopenharmony_ci<!-- xxx.hml --> 101e41f4b71Sopenharmony_ci<div class="container"> 102e41f4b71Sopenharmony_ci <div class="back_container"> 103e41f4b71Sopenharmony_ci <svg> 104e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="black"> 105e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0; 106e41f4b71Sopenharmony_ci 600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform> 107e41f4b71Sopenharmony_ci </polygon> 108e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="green"> 109e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0; 110e41f4b71Sopenharmony_ci 600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform> 111e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="rotate" values="0; 5; 0; 10" keyTimes="0; 112e41f4b71Sopenharmony_ci 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform> 113e41f4b71Sopenharmony_ci </polygon> 114e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="blue"> 115e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0; 116e41f4b71Sopenharmony_ci 600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform> 117e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="scale" values="1; 1.2; 1; 1.2" 118e41f4b71Sopenharmony_ci keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform> 119e41f4b71Sopenharmony_ci </polygon> 120e41f4b71Sopenharmony_ci <polygon points="60,30 90,90 30,90" fill="red"> 121e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" values="0 0; 200 200; 400 0; 122e41f4b71Sopenharmony_ci 600 200" keyTimes="0; 0.4; 0.8;1.0" dur="3s" repeatCount="indefinite"></animateTransform> 123e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="scale" values="1; 1.2; 1; 1.2" 124e41f4b71Sopenharmony_ci keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform> 125e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="skewX" values="0; 10; 0; 10" 126e41f4b71Sopenharmony_ci keyTimes="0; 0.4; 0.8; 1.0" dur="3s" repeatCount="indefinite"></animateTransform> 127e41f4b71Sopenharmony_ci </polygon> 128e41f4b71Sopenharmony_ci </svg> 129e41f4b71Sopenharmony_ci </div> 130e41f4b71Sopenharmony_ci</div> 131e41f4b71Sopenharmony_ci``` 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci```css 135e41f4b71Sopenharmony_ci/* xxx.css */ 136e41f4b71Sopenharmony_ci.container { 137e41f4b71Sopenharmony_ci flex-direction: column; 138e41f4b71Sopenharmony_ci justify-content: flex-start; 139e41f4b71Sopenharmony_ci align-items: flex-start; 140e41f4b71Sopenharmony_ci background-color: #f8f8ff; 141e41f4b71Sopenharmony_ci} 142e41f4b71Sopenharmony_ci.back_container { 143e41f4b71Sopenharmony_ci flex-direction: row; 144e41f4b71Sopenharmony_ci justify-content: flex-start; 145e41f4b71Sopenharmony_ci align-items: flex-start; 146e41f4b71Sopenharmony_ci height: 1000px; 147e41f4b71Sopenharmony_ci width: 1080px; 148e41f4b71Sopenharmony_ci} 149e41f4b71Sopenharmony_ci``` 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci涉及组件示例 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci```html 159e41f4b71Sopenharmony_ci<!-- xxx.hml --> 160e41f4b71Sopenharmony_ci<div class="container"> 161e41f4b71Sopenharmony_ci <div class="back_container"> 162e41f4b71Sopenharmony_ci <svg> 163e41f4b71Sopenharmony_ci <svg fill="white" width="600" height="600" viewBox="0 0 50 50"> 164e41f4b71Sopenharmony_ci <path stroke="black" fill="none" stroke-linejoin="miter" stroke-miterlimit="1" id="p2" 165e41f4b71Sopenharmony_ci d="M1,19 l7,-3 l7,3 m2,0 l3.5,-3 l3.5 ,3 m2,0 l2 ,-3 l2 ,3 m2,0 l0.75,-3 l0.75,3 m2,0 l0.5 ,-3 l0.5,3"> 166e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="25" 167e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 168e41f4b71Sopenharmony_ci </path> 169e41f4b71Sopenharmony_ci </svg> 170e41f4b71Sopenharmony_ci <polygon points="60,20 90,80 30,80" fill="black"> 171e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 172e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 173e41f4b71Sopenharmony_ci </polygon> 174e41f4b71Sopenharmony_ci <circle cx="60" cy="130" r="40" stroke-width="4" fill="white" stroke="blue"> 175e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 176e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 177e41f4b71Sopenharmony_ci </circle> 178e41f4b71Sopenharmony_ci <line x1="10" x2="300" y1="280" y2="280" stroke-width="10" stroke="black" stroke-linecap="square"> 179e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 180e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 181e41f4b71Sopenharmony_ci </line> 182e41f4b71Sopenharmony_ci <polyline points="10,380 50,335 50,385 100,310" fill="white" stroke="black"> 183e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 184e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 185e41f4b71Sopenharmony_ci </polyline> 186e41f4b71Sopenharmony_ci <ellipse cx="100" cy="450" rx="70" ry="50" fill="blue"> 187e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 188e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 189e41f4b71Sopenharmony_ci </ellipse> 190e41f4b71Sopenharmony_ci <rect width="100" height="100" x="50" y="540" stroke-width="10" stroke="red" rx="10" ry="10" 191e41f4b71Sopenharmony_ci stroke-dasharray="5 3" stroke-dashoffset="3"> 192e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 193e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 194e41f4b71Sopenharmony_ci </rect> 195e41f4b71Sopenharmony_ci <text x="20" y="700" fill="#D2691E" font-size="40"> 196e41f4b71Sopenharmony_ci animate-transform 197e41f4b71Sopenharmony_ci <animateTransform attributeName="transform" attributeType="XML" type="translate" from="0" to="300" 198e41f4b71Sopenharmony_ci dur="3s" repeatCount="indefinite"></animateTransform> 199e41f4b71Sopenharmony_ci </text> 200e41f4b71Sopenharmony_ci </svg> 201e41f4b71Sopenharmony_ci </div> 202e41f4b71Sopenharmony_ci</div> 203e41f4b71Sopenharmony_ci``` 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci```css 207e41f4b71Sopenharmony_ci/* xxx.css */ 208e41f4b71Sopenharmony_ci.container { 209e41f4b71Sopenharmony_ci flex-direction: column; 210e41f4b71Sopenharmony_ci justify-content: flex-start; 211e41f4b71Sopenharmony_ci align-items: flex-start; 212e41f4b71Sopenharmony_ci background-color: #f8f8ff; 213e41f4b71Sopenharmony_ci} 214e41f4b71Sopenharmony_ci.back_container { 215e41f4b71Sopenharmony_ci flex-direction: row; 216e41f4b71Sopenharmony_ci justify-content: flex-start; 217e41f4b71Sopenharmony_ci align-items: flex-start; 218e41f4b71Sopenharmony_ci height: 1000px; 219e41f4b71Sopenharmony_ci width: 1080px; 220e41f4b71Sopenharmony_ci} 221e41f4b71Sopenharmony_ci``` 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci 226