0.13.2 • Published 7 years ago

vue-annotator v0.13.2

Weekly downloads
185
License
MIT
Repository
github
Last release
7 years ago

vue-annotator CircleCI

npm npm donate

Create annotation using SVG and HTML element.

Usage

For complete example see src/stories/*/*.vue

<v-annotator inertia
  :drawing="enableDrawingMode"
  @select="openDialog"
  :minSize="[50, 50]"
  :grid="[5, 5]"
  :multipleSelect="keyIsDown.Ctrl"
>

    <img draggable="false" src="background.png" />

    <rect slot="annotation" stroke="green" x="300" y="150" width="170" height="100" />
    <polygon slot="annotation" stroke="purple" points="200,10 250,190 160,210" />

    <rect slot="drawing" stroke="red" />

</v-annotator>
<style scoped>
@import '~vue-annotator/style.css';

/* Your beloved style */
</style>

Due to https://github.com/taye/interact.js/issues/623

In tsconfig.json

{
  compilerOptions: {
    skipLibCheck: true
  }
}

Now it should work fine

import { Vue, Component } from 'vue-property-decorator'
import VAnnotator from 'vue-annotator'

@Component({ components: { VAnnotator } })
export class MyCanvas extends Vue {
  /** Your beloved logic */
}

API References

Props

* : must be set if no background

ParametersDescriptionTypeMust SpecifyDefault value
widthwidth of drawing canvasNumber*optionalwidth of background
heightwidth of drawing canvasNumber*optionalheight of background
gridset grid for snapping. :grid="[w,h]" for setting width and height. :grid="w" for setting grid in squareArray[2] or Numberoptionalnull
min-sizeset minimum size of annotation. :minSize="[w,h]" for set minimum width and height of annotation size. :grid="w" for set minimum width and height of annotation size equal to wArray[2] or Numberoptionalfalse
drawingswitch to drawing modeBooleanoptionalfalse
inertiaenable inertia moment animation when interactingBooleanoptionalfalse
multiple-selectenable multiple selectBooleanoptionalfalse
mouse-selectrestrict select only for specific mouse buttonString of left|right|middleoptional
delete.syncdelete selected element when set to trueBooleanoptional

Slots

* : will error when more than 1 element to be provided

Method nameDescriptionAccepted Element
defaultbackground element of annotationAny HTML element
annotationannotation element (accept SVG element)<rect>, <ellipse>, <circle>, <polygon>, <path>, <foreignObject>
drawing*draw element via mouse click&drag<rect>, <ellipse>, <circle>

Events

Event nameDescriptionParameters
selectemit when element is click/selectelement: SVG.Element
select-leftemit when element is clicked with left mouse buttonelement: SVG.Element
select-middleemit when element is clicked with middle mouse buttonelement: SVG.Element
select-rightemit when element is clicked with right mouse buttonelement: SVG.Element
unselectemit when element is unselected (by clicking the background)element: SVG.Element
moveemit when element is movedelement: SVG.Element
move-endemit after the element is movedelement: SVG.Element
resizeemit when element is resizedelement: SVG.Element
resize-endemit after the element is resizedelement: SVG.Element
drawemit when drawing an elementelement: SVG.Element
draw-endemit when drawing element is finishelement: SVG.Element
draw-cancelemit when drawing element is canceled (via right click)
update:deleteemit when shape was successfully deleted

Tips: use element.node.isSameNode(this.$refs.myAnnotation) for identifying the element.

Style CSS

Vue-Annotator use svg.select.js

Class nameDescriptionNotes
.svg_select_boundingRectdefine style of rectangle in selected elementonly applicable on <rect>, <circle>, <ellipse>
.svg_select_pointsdefine style of edge circles in selected element

default style

.svg_select_points {
  stroke-width: 1;
  fill: black;
  stroke-dasharray: 10 10;
  stroke: black;
  stroke-opacity: 0.8;
  pointer-events: none; /* This ons is needed if you want to deselect or drag the shape*/
}

.svg_select_boundingRect {
  display: none;
}

Support

See CONTRIBUTING.md for contributing directly via:

License

MIT License

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.5

7 years ago

0.11.4

7 years ago

0.11.3

7 years ago

0.11.2

7 years ago

0.11.1

7 years ago

0.10.2

7 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago