Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
vue-croppa
Advanced tools
A simple straightforward customizable image cropper for vue.js.
<croppa v-model="myCroppa"
:width="400"
:height="400"
:canvas-color="'default'"
:placeholder="'Choose an image'"
:placeholder-font-size="0"
:placeholder-color="'default'"
:input-accept="'image/*'"
:file-size-limit="0"
:quality="2"
:zoom-speed="3"
:disabled="false"
:disable-click-to-choose="false"
:disable-drag-to-move="false"
:disable-scroll-to-zoom="false"
:prevent-white-space="false"
:reverse-zooming-gesture="false"
:show-remove-button="true"
:remove-button-color="'red'"
:remove-button-size="0"
@init="handleCroppaInit"
@file-choose="handleCroppaFileChoose"
@file-size-exceed="handleCroppaFileSizeExceed"
@move="handleCroppaMove"
@zoom="handleCroppaZoom"></croppa>
NOTE: This is an almost-full-use example. Usually you don't need to specify so many props to customize it, because they all have default values. Most simply, you can even do:
<croppa v-model="myCroppa"></croppa>
this.myCroppa.reset()
this.myCroppa.zoomIn()
alert(this.myCroppa.generateDataUrl())
Using build tools:
npm install --save vue-croppa
import Vue from 'vue'
import Croppa from 'vue-croppa'
Vue.use(Croppa)
// If your build tool supports css module
import 'vue-croppa/dist/vue-croppa.css'
Not using build tools:
<link href="https://unpkg.com/vue-croppa/dist/vue-croppa.min.css" rel="stylesheet" type="text/css">
<script src="https://unpkg.com/vue-croppa/dist/vue-croppa.min.js"></script>
Vue.use(Croppa)
<croppa v-model="myCroppa"></croppa>
A two-way binding prop. It syncs an object from within the croppa component with a data in parent. We can use this object to invoke useful methods (Check out "Methods" section).
object
null
Display width of the preview container.
number
200
val > 0
Display height of the preview container.
number
200
val > 0
Placeholder text of the preview container. It shows up when there is no image.
string
'Choose an image'
Placeholder text color.
CanvasRenderingContext2D.fillStyle
accepts.'#606060'
Placeholder text font size in pixel. When set to 0
, the font size will be ajust automatically so that the whole placehoder only takes up 2/3 of the container's width.
number
0
Initial background color and white space color if there is an image.
CanvasRenderingContext2D.fillStyle
accepts.'#e6e6e6'
Specifies how many times larger the actual image is than the container's display size.
number
2
Specifies how fast the zoom is reacting to scroll gestures. Default to level 3.
number
3
val > 0
Limits the types of files that users can choose.
accept
attribute of HTML input
element takes.'image/*'
Limits the byte size of file that users can choose. If set to 0
, then no limit.
number
0
Disables user interaction.
boolean
false
Disables the default "click to choose an image" user interaction. You can instead trigger the file chooser window programmatically by invoking chooseFile()
method.
boolean
false
Disables the default "drag to move" user interaction. You can instead move the image programmatically by invoking moveUpwards()
/ moveDownwards()
/ moveLeftwards()
/ moveRightwards()
methods.
boolean
false
Disables the default "scroll to zoom" user interaction. You can instead zoom the image programmatically by invoking zoomIn()
/ zoomOut()
methods.
boolean
false
Reverses the zoom-in/zoom-out direction when scrolling.
boolean
false
Prevents revealing background white space when moving or zooming the image.
boolean
false
Specifies whether to show the built-in remove-button. You can change the button's color and size using the following two props. If you still find it ugly, hide it and use the reset()
method to implement your own trigger.
boolean
false
Changes the default color of the remove-button. Accepts any css color format.
string
'red'
Specifies the remove-button's width and height (they are equal). If set to 0
, then it use the default size.
number
<img>
node as a named slot initial
. For example:<croppa v-model="myCroppa">
<img slot="initial" :src="initialImageUrl" />
</croppa>
{ width, height }
describing the real image size (preview size * quality
)Promise
wrapping around generateBlob()
, so that you can use async/await
syntax instead of a callback to get blob data, it's simpler.const blob = await this.myCroppa.promisedBlob()
croppa
is a croppa object to invoke methods - same as what v-model
binds.file
is a file object - same as what getChosenFile()
returns.file
is a file object - same as what getChosenFile()
returns.FAQs
A simple straightforward customizable lightweight mobile-friendly image cropper for Vue 2.0.
The npm package vue-croppa receives a total of 5,602 weekly downloads. As such, vue-croppa popularity was classified as popular.
We found that vue-croppa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.