npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sprite-draggable

v0.1.21

Published

let sprite can draggable

Downloads

37

Readme

sprite-draggable

let sprite can draggable,让sprite对象拥有draggable的能力

运行demo

npm install

npm start

访问 http://localhost:9092 查看具体demo

安装sprite-draggable依赖

  npm install sprite-draggable --save

作为spritejs插件使用


  // draggable与droppable方法注册到BaseSprite上
  import { install } from 'sprite-draggable'
  spritejs.use(install);
  …

  let group = new Group();
  group.draggable();
  // group.draggable(false); group.draggable({destroy,true}) 取消注册drag

  group.dropabble()//注册drop事件

  // group.droppable(false) ;group.droppable({destroy:true}) 取消注册drop

  group.on('drag', (evt) => {
    console.log('drag')
  });

  group.on('drop', (evt) => {
    console.log('drop')
  });

  group.on('dragenter', (evt) => {
    console.log('dragenter')
  });

  group.on('dragleave', (evt) => {
    console.log('dragleave')
  });

  group.on('dragover', (evt) => {
    console.log('dragover')
  });

  let sprite = new Sprite();
  //表示在 [0,0] 与 [300,300] 这两点矩形之间拖动 [xmin,ymin,xmax,ymax],不设置表示不控制拖动范围
  sprite.draggable({dragRect:[0,0,300,300]})

  // 取消设置dragRect方法
  //sprite.draggable({dragRect:[0,0,300,300]})

  //表示拖动的范围大于坐标[0,0]
  //sprite.draggable({dragRect:[0,0]});

  /**拖动过程中,有三个事件 dragstart、drag、dragend**/
  sprite.on('dragstart',function(event){
    console.log('dragstart');
  });

  sprite.on('drag',function(event){
    console.log('drag');
  });

  sprite.on('dragend',function(event){
    console.log('dragend');
  });


  //取消元素拖动
  sprite.draggable(false);

作为方法使用


  import { draggable, droppable } from 'sprite-draggable'

  …

  let group = draggable(new Group());

  // draggable(group,false); draggable(group,{destroy,true}) 取消注册drag

  dropabble(group) //注册drop事件

  // dropabble(group,false) ;dropabble(group,{destroy:true}) 取消注册drop

  group.on('drag', (evt) => {
    console.log('drag')
  });

  group.on('drop', (evt) => {
    console.log('drop')
  });

  group.on('dragenter', (evt) => {
    console.log('dragenter')
  });

  group.on('dragleave', (evt) => {
    console.log('dragleave')
  });

  group.on('dragover', (evt) => {
    console.log('dragover')
  });

  let sprite = draggable(new Sprite());

  //表示在 [0,0] 与 [300,300] 这两点矩形之间拖动 [xmin,ymin,xmax,ymax],不设置表示不控制拖动范围
  draggable(sprite,{dragRect:[0,0,300,300]});
  //draggable(sprite,{dragRect:[]});

  //表示拖动的范围大于坐标[0,0]
  //draggable(sprite,{dragRect:[0,0]});

  /**拖动过程中,有三个事件 dragstart、drag、dragend**/
  sprite.on('dragstart',function(event){
    console.log('dragstart');
  });

  sprite.on('drag',function(event){
    console.log('drag');
  });

  sprite.on('dragend',function(event){
    console.log('dragend');
  });


  //取消元素拖动
  draggable(sprite,false);

事件列表:

| 事件 | 描述 | 其它 | |----------|-------------|------| | dragstart | 开始拖动对象 | | | drag | 正在拖动对象 | | | dragend | 停止拖动对象 | | | dragover | 一个draggable对象在另一个droppable对象上拖动 | | | dragenter | 一个draggable对象在进入一个droppable对象上 | draggable进入droppable判断点为draggable对象最小矩形的中心 | | dragleave | 一个draggable对象离开一个droppable对象上 | | | drop | 一个draggable对象放在一个droppable对象上 | |