Giter Club home page Giter Club logo

alloy_touch's Introduction

alloy_touch 使用文档

丝般顺滑的触摸运动方案

例子

https://github.com/AlloyTeam/AlloyTouch

API

var alloyTouch = new AlloyTouch({
    touch:"#wrapper",//反馈触摸的dom
    vertical: true,//不必需,默认是true代表监听竖直方向touch
    target: target, //运动的对象
    property: "translateY",  //被运动的属性
    min: 100, //不必需,运动属性的最小值
    max: 2000, //不必需,滚动属性的最大值
    sensitivity: 1,//不必需,触摸区域的灵敏度,默认值为1,可以为负数
    factor: 1,//不必需,表示触摸位移与被运动属性映射关系,默认值是1
    step: 45,//用于校正到step的整数倍
    bindSelf: false,
    maxSpeed: 2, //不必需,触摸反馈的最大速度限制 
    initialValue: 0,
    change:function(value){  }, 
    touchStart:function(evt, value){  },
    touchMove:function(evt, value){  },
    touchEnd:function(evt,value){  },
    tap:function(evt, value){  },
    pressMove:function(evt, value){  },
    animationEnd:function(value){  } //运动结束
})

通过对象的实例可以自行运动DOM:

alloyTouch.to(value, time, ease)
  • value是必填项
  • time是非必填项,默认值是600
  • ease是非必填项,默认值是先加速后减速的运动函数,CSS版本默认值是cubic-bezier(0.1, 0.57, 0.1, 1)

通过对象的实例可以自行停止DOM运动:

alloyTouch.stop()

注意

仓库里面有alloytouch.js和alloytouch.css.js,他们的区别如下:

alloytouch.js是使用 requestAnimationFrame 去运动,alloytouch.css.js使用transition去运动。后者性能更优~

默认下载下来用的是alloytouch.js,请自行修改

alloy_touch's People

Contributors

303182519 avatar

Watchers

James Cloos avatar MrFanggesun avatar lirunzi avatar April avatar Korbin avatar  avatar plcc avatar  avatar  avatar guoshengze 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.