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

deformation

v1.1.2

Published

自由拖动组件

Downloads

13

Readme

自由拖动缩放组件.

展示

特点

  • 没有依赖包
  • 可以拖动 位置 和 大小
  • 可以设定大小调整范围
  • 可以限制元素只能在父组件内拖动
  • 可以自定义网格
  • 可以限制元素只能水平 或 竖直拖动

实例


安装 及 使用

$ npm install --save deformation

注册组件

import Vue from 'vue'
import deformation from 'deformation'

Vue.component('Deformation', deformation)

使用组件

<template>
  <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;">
    <Deformation :w="100" :h="100" v-on:dragging="onDrag" v-on:resizing="onResize" :parent="true">
      <p>Hello! I'm a flexible component. You can drag me around and you can resize me.<br>
      X: {{ x }} / Y: {{ y }} - Width: {{ width }} / Height: {{ height }}</p>
    </Deformation>
  </div>
</template>

<script>
import Deformation from 'deformation'

export default {
  data: function () {
    return {
      width: 0,
      height: 0,
      x: 0,
      y: 0
    }
  },
  components: {
    Deformation
  },
  methods: {
    onResize: function (x, y, width, height) {
      this.x = x
      this.y = y
      this.width = width
      this.height = height
    },
    onDrag: function (x, y) {
      this.x = x
      this.y = y
    }
  }
}
</script>

参数

draggable

类型: BooleanNumber 必要性: false 默认值: true

定义组件是否可以拖动.

| 参数值      | 效果         | | ----------- |:-------------:| |true | 组件可以在x轴,y轴方向自由拖动 | |false | 组件无法拖动 | |0 | 组件无法拖动 | |1 | 组件可以在x轴,y轴方向自由拖动 | |2 | 组件可以在x轴方向自由拖动 | |3 | 组件可以在y轴方向自由拖动 |

<Deformation :draggable="false">

resizable

类型: BooleanNumber 必要性: false 默认值: true

定义组件是否可以调整大小.

| 参数值      | 效果         | | ----------- |:-------------:| |true | 组件可以在x轴,y轴方向调整大小 | |false | 组件无法拖动 | |0 | 组件无法拖动 | |1 | 组件可以在x轴,y轴方向调整大小 | |2 | 组件可以在x轴方向调整大小 | |3 | 组件可以在y轴方向调整大小 |

<Deformation :resizable="false">

w

类型: Number 必要性: false 默认值: 200

定义组件的初始宽度.

<Deformation :w="200">

h

类型: Number 必要性: false 默认值: 200

定义组件的初始高度.

<Deformation :h="200">

minw

类型: Number 必要性: false 默认值: 50

定义组件的最小宽度.

<Deformation :minw="50">

minh

类型: Number 必要性: false 默认值: 50

定义组件的最小高度.

<Deformation :minh="50">

x

类型: Number 必要性: false 默认值: 0

定义组件初始横轴坐标.

<Deformation :x="0">

y

类型: Number 必要性: false 默认值: 0

定义组件初始纵轴坐标.

<Deformation :y="0">

grid

类型: Array 必要性: false 默认值: [1,1]

定义组件网格.

<Deformation :grid="[1,1]">

restrain

类型: Number 必要性: false 默认值: 0

约束元素宽高只能是restrain的倍数.

<Deformation :restrain="100">

parent

类型: Boolean 必要性: false 默认值: false

限制元素只能在父元素内拖动

<Deformation :parent="true">

Events

activated

必要性: false Parameters: -

组件被初始化事件.

<Deformation @activated="onActivated">

deactivated

必要性: false Parameters: -

组件被销毁事件.

<Deformation @deactivated="onDeactivated">

resizing

必要性: false Parameters:

  • left 组件 X 轴坐标
  • top 组件 Y 轴坐标
  • width 组件宽度
  • height 组件高度

组件大小改变事件.

<Deformation @resizing="onResizing">

resizestop

必要性: false Parameters:

  • left 组件 X 轴坐标
  • top 组件 Y 轴坐标
  • width 组件宽度
  • height 组件高度

组件大小改变结束事件.

<Deformation @resizestop="onResizstop">

dragging

必要性: false Parameters:

  • left 组件 X 轴坐标
  • top 组件 Y 轴坐标

组件拖动事件.

<Deformation @dragging="onDragging">

dragstop

必要性: false Parameters:

  • left 组件 X 轴坐标
  • top 组件 Y 轴坐标

组件拖动结束事件.

keydown

必要性: false Parameters:

  • event 键值

按键事件.

<Deformation @dragstop="onDragstop">