<canvas width="800" height="600">
<dataset name="ds_photo" src="/photo.xml"/>
<script>
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number) >=50?rand(number):Math.ceil(rnd()*number);
};
</script>
<alert name="myalert">
a
</alert>
<view x="140" name="main">
<view name="imagelist" datapath="ds_photo:/items/item/@url"
width="135" height="135" stretches="both" x="0" y="10" onclick="showThis(this)" onmouseover="rotate()" onmouseout="rotateback()">
<attribute name="rotationratio"/>
<method name="applyData" args="imageId">
var image = "" + imageId;
this.setSource(image);
</method>
<method name="rotate">
this.rotationratio = this.rot.to;
//Debug.write(this.rotationratio);
this.animate('rotation','0','500');
</method>
<method name="rotateback">
this.animate('rotation',this.rotationratio,'500');
</method>
<method name="showThis" args="that">
canvas.showDetail.setVisible(true);
</method>
<animator name="rot" attribute="rotation" to="${rand(50)}" duration="100" relative="false" />
</view>
<simplelayout axis="x" spacing="100"/>
</view>
<window name="showDetail" width="400" height="300" oninit="${this.setVisible(false)}">
</window>
</canvas>
本文介绍了一种使用随机数生成器来实现元素动画效果的方法。通过JavaScript动态调整元素旋转角度,结合鼠标悬停与移出事件触发不同的动画效果,增强了用户交互体验。
188

被折叠的 条评论
为什么被折叠?



