Coder Social home page Coder Social logo

fruitgame's Introduction

1、简易运动框架: 简易的运动框架可以用来控制长宽高、位置、透明度,结合定时器可以实现简单的动画。 http://www.mamicode.com/info-detail-1612909.html 参考网址

2、获取元素的样式: 因为obj.style.xx,但是这个方法只能获取行内样式 所以运用currentStyle(IE)方法和getComputedStyle方法

定义一个获取元素样式的通用函数:

function getStyle(obj,attr){ return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr]; };

3、doMove(obj,attr,dir,target,endFn)

obj是要进行操作的对象

attr是要操作的属性

dir是要改变元素属性的速度(在一段时间内改变多少)

target属性改变的目标值

endFn是回调函数

首先,我们先要判断dir的正负,如果元素现在的属性值要是小于目标值则attr为正,否则为负数

注意:用getStyle()函数返回的是字符串,所以要用parseInt转换为数字

fruitgame's People

Contributors

faye0211 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.