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

map-control

v0.0.10

Published

fabric封装,进行图片控制于与标记

Downloads

29

Readme

map-control

基于 vue2 封装 fabricjs 的组件

在线 demo

demo 地址

npm 包方式使用

安装依赖

npm install map-control

在 main.js 中注册

import mapControl from "map-control";
Vue.use(mapControl);

在 vue 文件中使用

<map-control></map-control>

复制源码使用

将项目中的 components/map-control 拷贝到 vue2 项目中

引入 map-control.vue 进行使用,其中的引入路径请根据实际情况调整

import MapControl from "./components/map-control/map-control.vue";
export default {
  components: { MapControl },
}

开发

环境 node 18.16.0

# 安装依赖
npm install

# 开发
npm run dev

# 打包
npm run build

# 发布
npm public

开发说明

本项目核心逻辑存在 components/map-control/modules 中

  • ElcCanvas 封装 fabricjs 与创建画布的主类
  • BaseElcNode 画布内节点的基类
  • BaseComponent 逻辑插件的基类
  • fabricUtils 一些工具方法
  • (各类继承 BaseElecNode 的子类,特征为 Elc 开头,例如:ElcImage)
  • (各类继承 BaseComponent 的逻辑插件,特征为 Component 结尾,例如:MovableComponent、MouseZoomComponent)

BaseElcNode

自定义的节点继承这个类后,在绘制完成后调用这个节点的 create 方法,将自定的内容渲染到画布中。所以自定义节点需要提供 getAllFNodes 方法,让 create 能够指导有多少个元素需要添加、添加到哪个图层上。

相关资料

tips

  • 使用 fabric.Group 设置分组后,便如法单独编辑该分组下的元素