openLaszlo仿Cooqy的照片视图效果

本文介绍了一种使用随机数生成器来实现元素动画效果的方法。通过JavaScript动态调整元素旋转角度,结合鼠标悬停与移出事件触发不同的动画效果,增强了用户交互体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<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) 
&gt;=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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值