css摇杆,nippleJS: nippleJS 是一个 JavaScript 库,用来创建虚拟摇杆触摸功能的接口...

dd5b47830710edcbc54b46b2e6a9879a.png

A vanilla virtual joystick for touch capable interfaces

nipplejs.svg

nipplejs.svg

Table Of Contents

Install

npm installnipplejs --save

Demo

Check out the demo here.

Usage

Import it the way you want into your project :

// CommonJS

var manager = require('nipplejs').create(options);

// AMD

define(['nipplejs'], function (nipplejs) {

var manager = nipplejs.create(options);

});

// Module

import nipplejs from 'nipplejs';

var manager = nipplejs.create(options);

c59e394e6c0d3a65ce71f254e2390a17.png NB

c59e394e6c0d3a65ce71f254e2390a17.png Your joystick's container has to have its CSS position property set, either absolute, relative, static, ....

Options

You can configure your joystick in different ways :

var options = {

zone: Element, // active zone

color: String,

size: Integer,

threshold: Float, // before triggering a directional event

fadeTime: Integer, // transition time

multitouch: Boolean,

maxNumberOfNipples: Number, // when multitouch, what is too many?

dataOnly: Boolean, // no dom element whatsoever

position: Object, // preset position for 'static' mode

mode: String, // 'dynamic', 'static' or 'semi'

restJoystick: Boolean|Object, // Re-center joystick on rest state

restOpacity: Number, // opacity when not 'dynamic' and rested

lockX: Boolean, // only move on the X axis

lockY: Boolean, // only move on the Y axis

catchDistance: Number, // distance to recycle previous joystick in

// 'semi' mode

shape: String, // 'circle' or 'square'

dynamicPage: Boolean, // Enable if the page has dynamically visible elements

follow: Boolean, // Makes the joystick follow the thumbstick

};

All options are optional

5c28a16a9afceb44a28ef09b6706d9f8.png.

options.zone defaults to 'body'

The dom element in which all your joysticks will be injected.

var options = {

zone: document.getElementById('zone_joystick'),

};

var manager = nipplejs.create(options);

This zone also serve as the mouse/touch events handler.

It represents the zone where all your joysticks will be active.

options.color default

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值