2.8.8 • Published 1 year ago

vue-advanced-cropper v2.8.8

Weekly downloads
10,644
License
MIT
Repository
github
Last release
1 year ago

:fire: HEADS UP! You're currently looking at the branch for Vue 3. If you're looking for the branch for Vue 2, please check out master branch.


Vue Advanced Cropper is the advanced library that gives you opportunity to create your own croppers suited for any website design. It means that you are able to change not only the cropper appearance, you area able to customize its behavior also.

Features:

  • full mobile / desktop support
  • support all three main types of croppers right out of the box
  • support both canvas and coordinates modes, minimum and maximum aspect ratios, custom size restrictions
  • zoom, rotate, resize image
  • auto-zoom, transitions

npm.io

The codesandbox for mobile / desktop examples above.

Install

Vue 3.0

npm install --save vue-advanced-cropper@next
yarn add vue-advanced-cropper@next

Vue 2.0

npm install --save vue-advanced-cropper@vue-2
yarn add vue-advanced-cropper@vue-2

If you would to use CDN read the corresponding documentation section

Usage

import Vue from 'vue'
import { Cropper } from 'vue-advanced-cropper'
import 'vue-advanced-cropper/dist/style.css';

new Vue({
  el: '#app',
  data: {
    img: 'https://images.pexels.com/photos/226746/pexels-photo-226746.jpeg'
  },
  methods: {
    change({coordinates, canvas}) {
      console.log(coordinates, canvas)
    }
  },
  components: {
    Cropper
  }
})
<div id="app">
  <cropper
    class="cropper"
    :src="img"
    :stencil-props="{
      aspectRatio: 10/12
    }"
    @change="change"
  ></cropper>
</div>
/*
  Maybe you need to set the limits for the cropper sizes or its container sizes
  otherwise a cropping image will try to fill all available space
*/
.cropper {
  height: 600px;
  background: #DDD;
}

Cropper

PropTypeDescriptionDefault
srcStringThe cropping image (link / base64)
stencilComponentString, ObjectThe stencil componentRectangleStencil
stencilPropsObjectThe props for the stencil component{}
classStringThe optional class for the root cropper block
imageClassStringThe optional class for the cropping image
boundariesClassStringThe optional class for the area.
backgroundClassStringThe optional class for the background under the image
autoZoomBooleanEnable / disable transitionsfalse
transitionsBooleanEnable / disable auto zoomtrue
stencilSizeObjectThe size of the stencil in pixels
debounceString, NumberThe time before change event will be emitted after changes (ms)500
canvasBooleanThe flag that indicates if canvas should be usedtrue
minWidthString, NumberThe minimum width of the stencil (percents)
minHeightString, NumberThe minimum height of the stencil (percents)
maxWidthString, NumberThe maximum width of the stencil (percents)
maxHeightString, NumberThe maximum height of the stencil (percents)
checkOrientationBooleanCheck if EXIF orientation should be checkedtrue
resizeImageBoolean, ObjectThe options for the image resizing (details)true
moveImageBoolean, ObjectThe options for the image moving (details)true
imageRestrictionStringSet restrictions for image position ('fill-area' 'fit-area', 'stencil', 'none')'fill-area'
defaultSizeObject, FunctionThe function that returns the default size of the stencil or objectcore.defaultSize
defaultPositionObject, FunctionThe function that returns the default position of the stencil or objectcore.defaultPosition
defaultBoundariesString, FunctionThe function that determines the boundaries size or string ('fill', 'fit')'fill'
sizeRestrictionsAlgorithmFunctionThe function that returns the restrictions object
EventDescription
changeInvoked on changing of a stencil position / size, after mounting the component and on an image changing
readyInvoked on success of an image loading
errorInvoked on error of an image loading

RectangleStencil

PropTypeDescriptionDefault
aspectRatioNumberThe aspect ratio
minAspectRatioNumberThe minimum aspect ratio
maxAspectRatioNumberThe maximum aspect ratio
classStringThe class for root block of the stencil component
previewClassStringThe class for the preview component
movingClassStringThe class applied when user drag the stencil
resizingClassStringThe class applied when user resize the stencil
boundingBoxClassStringThe class for the bounding box component
handlerComponentString,ObjectThe handler component
handlersObjectThe object of handlers that should be visible or hidden.
handlersClassesObjectThe object of custom handler classes
handlersWrappersClassesObjectThe object of custom handler wrapper classes
lineComponentString,ObjectThe handler component
linesObjectThe object of lines that should be visible or hidden.
linesClassesObjectThe object of custom line classes
linesWrappersClassesObjectThe object of custom line wrapper classes

License

The source code of this library is licensed under MIT, the documentation and photos are belong to their respective owners.

1.11.6

1 year ago

2.8.7

1 year ago

2.8.8

1 year ago

1.11.4

2 years ago

1.11.5

2 years ago

2.8.5

2 years ago

2.8.6

2 years ago

1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

2.8.3

2 years ago

2.8.2

2 years ago

1.11.0

2 years ago

2.8.1

2 years ago

2.8.0

2 years ago

2.7.1

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

2.7.0

2 years ago

2.6.3

3 years ago

1.8.2

3 years ago

2.6.2

3 years ago

1.8.1

3 years ago

2.6.1

3 years ago

1.8.0

3 years ago

2.6.0

3 years ago

1.7.0

3 years ago

2.5.0

3 years ago

1.6.0

3 years ago

2.4.0

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

2.3.0

3 years ago

2.3.1

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

2.2.1

3 years ago

1.3.2

3 years ago

2.2.0

3 years ago

2.0.4

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.5

3 years ago

2.1.1

3 years ago

1.2.4

3 years ago

2.1.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.20.1

3 years ago

0.20.0

3 years ago

0.19.3

3 years ago

0.19.2

3 years ago

0.19.1

3 years ago

0.19.0

3 years ago

0.18.1

3 years ago

0.18.0

3 years ago

0.17.9

3 years ago

0.17.8

3 years ago

0.17.7

3 years ago

0.17.6

4 years ago

0.17.5

4 years ago

0.17.4

4 years ago

0.17.3

4 years ago

0.17.2

4 years ago

0.17.0

4 years ago

0.17.1

4 years ago

0.16.10

4 years ago

0.16.9

4 years ago

0.16.8

4 years ago

0.16.7

4 years ago

0.16.6

4 years ago

0.16.5

4 years ago

0.16.4

4 years ago

0.16.3

4 years ago

0.16.2

4 years ago

0.16.1

4 years ago

0.16.0

4 years ago

0.15.3

4 years ago

0.15.2

4 years ago

0.15.1

4 years ago

0.15.0

4 years ago

0.14.1

4 years ago

0.14.0

4 years ago

0.13.2

4 years ago

0.13.1

4 years ago

0.13.0

5 years ago

0.12.6

5 years ago

0.12.5

5 years ago

0.12.4

5 years ago

0.12.3

5 years ago

0.12.2

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.0

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago