Coder Social home page Coder Social logo

buddhamoni001 / vue-advanced-cropper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from advanced-cropper/vue-advanced-cropper

0.0 0.0 0.0 35.73 MB

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design

Home Page: https://norserium.github.io/vue-advanced-cropper/

License: Other

JavaScript 2.81% Vue 64.83% SCSS 5.35% Stylus 0.48% TypeScript 26.52%

vue-advanced-cropper's Introduction

Vue Advanced Cropper logo


Downloads Version
Documentation / Examples / Sandbox


๐Ÿ”ฅ HEADS UP! You're currently looking at the branch for Vue 2. If you're looking for the branch for Vue 3, please check out vue-next 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

The codesandbox for mobile / desktop examples above.

Install

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

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

Prop Type Description Default
src String The cropping image (link / base64)
stencilComponent String, Object The stencil component RectangleStencil
stencilProps Object The props for the stencil component {}
class String The optional class for the root cropper block
imageClass String The optional class for the cropping image
boundariesClass String The optional class for the area.
backgroundClass String The optional class for the background under the image
autoZoom Boolean Enable / disable transitions false
transitions Boolean Enable / disable auto zoom true
stencilSize Object The size of the stencil in pixels
debounce String, Number The time before change event will be emitted after changes (ms) 500
canvas Boolean The flag that indicates if canvas should be used true
minWidth String, Number The minimum width of the stencil (percents)
minHeight String, Number The minimum height of the stencil (percents)
maxWidth String, Number The maximum width of the stencil (percents)
maxHeight String, Number The maximum height of the stencil (percents)
checkOrientation Boolean Check if EXIF orientation should be checked true
resizeImage Boolean, Object The options for the image resizing (details) true
moveImage Boolean, Object The options for the image moving (details) true
imageRestriction String Set restrictions for image position ('fill-area' 'fit-area', 'stencil', 'none') 'fill-area'
defaultSize Object, Function The function that returns the default size of the stencil or object core.defaultSize
defaultPosition Object, Function The function that returns the default position of the stencil or object core.defaultPosition
defaultBoundaries String, Function The function that determines the boundaries size or string ('fill', 'fit') 'fill'
sizeRestrictionsAlgorithm Function The function that returns the restrictions object
Event Description
change Invoked on changing of a stencil position / size, after mounting the component and on an image changing
ready Invoked on success of an image loading
error Invoked on error of an image loading

RectangleStencil

Prop Type Description Default
aspectRatio Number The aspect ratio
minAspectRatio Number The minimum aspect ratio
maxAspectRatio Number The maximum aspect ratio
class String The class for root block of the stencil component
previewClass String The class for the preview component
movingClass String The class applied when user drag the stencil
resizingClass String The class applied when user resize the stencil
boundingBoxClass String The class for the bounding box component
handlerComponent String,Object The handler component
handlers Object The object of handlers that should be visible or hidden.
handlersClasses Object The object of custom handler classes
handlersWrappersClasses Object The object of custom handler wrapper classes
lineComponent String,Object The handler component
lines Object The object of lines that should be visible or hidden.
linesClasses Object The object of custom line classes
linesWrappersClasses Object The 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.

vue-advanced-cropper's People

Contributors

norserium avatar andrew-d-moore avatar pnutmath avatar mathix420 avatar dishantsethi avatar mattrmurphy avatar totakoko avatar singlebyted avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.