Alloytouch-Transformjs 让创建 CSS 动画变得更简单
安装
你可以运行下面的代码在线安装:
npm install css3transform
API
Transform(domElement, [notPerspective]);
使用
Transform(domElement);//or Transform(domElement, true);
//set "translateX", "translateY", "translateZ", "scaleX", "scaleY",
//"scaleZ", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "originX", "originY", "originZ"
domElement.translateX = 100;
domElement.scaleX = 0.5;
domElement.originX = 0.5;
//get "translateX", "translateY", "translateZ", "scaleX", "scaleY", "scaleZ",
//"rotateX", "rotateY", "rotateZ", "skewX", "skewY", "originX", "originY", "originZ"
//console.log(domElement.translateX )
Omi 版本
import Omi from 'omi';
import OmiTransform from '../../omi-transform.js';
OmiTransform.init();
class App extends Omi.Component {
constructor(data) {
super(data);
}
installed(){
setInterval(function(){
this.refs.test.rotateZ += 0.1;
}.bind(this));
}
render() {
return `
<div omi-transform class="test" ref="test" rotateZ="45" translateX="100" >
omi-transform
</div>
`;
}
style(){
return `
.test{
font-size: 20px;
border: 1px solid red;
width: 150px;
font-size
min-height: 150px;
text-align: center;
line-height:150px;
}
`;
}
}
Omi.render(new App(),"#container");
React 版本
//set "translateX", "translateY", "translateZ", "scaleX", "scaleY", "scaleZ", "rotateX",
//"rotateY", "rotateZ", "skewX", "skewY", "originX", "originY", "originZ"
render() {
return (
<Transform
translateX={100}
scaleX={0.5}
originX={0.5}>
<div>sth</div>
</Transform>
);
}
// you can also use other porps, such as "className" or "style"
render() {
return (
<Transform
translateX={100}
className="ani"
style={{width: '100px', background: 'red'}}
<div>sth</div>
</Transform>
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论