• js 实现弹力球效果


    1.html代码:

    <div id='imgid'>
        <img src="img/5.png">
    </div>

    2.js代码:

    imgobj=document.getElementById('imgid');
    //可视区域的高(视口高-图片所占的高度)
    screenHeight=document.documentElement.clientHeight;
    imgHeight=158;/*imgobj.clientHeight*/
    diffHeight=screenHeight-imgHeight;

    //可视区域的宽(视口宽-图片所占的宽度)
    screenWidth=document.documentElement.clientWidth;
    imgWidth=162;/*imgobj.clientWidth*/
    diffWidth=screenWidth-imgWidth;

    ys=0;
    yv=100;

    xs=0;
    xv=100;

    setInterval(function(){
    //y轴坐标
    ys+=yv;
    if (ys>=diffHeight) {
    ys=diffHeight;
    yv=-yv;
    }
    if (ys<=0) {
    yv=-yv;
    }
    imgobj.style.top=ys+'px';
    //x轴坐标
    xs+=xv;
    if (xs>=diffWidth) {
    xs=diffWidth;
    xv=-xv;
    }
    if (xs<=0) {
    xv=-xv;
    }
    imgobj.style.left=xs+'px';

    },100);

  • 相关阅读:
    C#Redis哈希Hashes
    C#Redis集合set
    C#Redis列表List
    C#Redis字符串
    入门redis
    C#/Net代码精简优化技巧
    单点登录在asp.net中的简单实现
    sql注入
    数据库sql优化
    常常忘记但是很重要的sql语句
  • 原文地址:https://www.cnblogs.com/jervy/p/9469122.html
Copyright © 2020-2023  润新知