GitHub地址

Install

NPM

npm install touch-robot
import touchRobot from 'touch-robot';

CDN

<script type="text/javascript" src="./dist/touch-robot.min.js"></script>

Usage

var robot = new touchRobot(dom);
robot.touchLeft();

API

方法(method)描述(description)
touchLeft左滑
touchRight右滑
touchTop上滑
touchBottom下滑
touchTo定点滑动,参数startX,startY,endX,endY
touchClick触碰点击

DEMO

jQuery-slide滑块验证码

操作步骤

step1
    浏览器切换到手机模式,将代码在控制台粘贴执行
step2
    var robot = new touchRobot(document.querySelector('#btn'));
    robot.touchTo(0,0,400,0);

swiper轮播

操作步骤

step1
    切换浏览地到手机模式,将代码在控制台粘贴执行
step2
    var robot = new touchRobot(document.querySelector('.swiper-container'))
    robot.touchLeft()

--------------

原创文章出自 木法传,如转载请注明本文链接:https://www.mofazhuan.com/748.html

--------------