Releases: github/image-crop-element
Releases · github/image-crop-element
v5.1.0
What's Changed
- Add a release action by @koddsson in #40
- Update dependencies by @koddsson in #42
- move AOR to primer by @keithamus in #43
- upgrade to new web component standards by @keithamus in #46
Full Changelog: v5.0.0...v5.1.0
5.0.0
v4.1.1
v4.1.0
v4.0.0
v3.0.8
v3.0.7
v3.0.5
v3.0.4
3.0.4
<image-crop-element>
This loads an image and creates a crop area that user can modify. An event is fired with x, y, width, and height as the crop area changes.
Installation
$ npm install --save @github/image-crop-element
Usage
Plain
<image-crop src="/avatar.jpg"></image-crop>
With loading state
<image-crop src="/avatar.jpg">
<img src="spinner.gif" alt="" data-loading-slot>
</image-crop>
With autoupdate inputs
<image-crop src="/avatar.jpg">
<input type="hidden" data-image-crop-input="x" name="x">
<input type="hidden" data-image-crop-input="y" name="y">
<input type="hidden" data-image-crop-input="width" name="width">
<input type="hidden" data-image-crop-input="height" name="height">
</image-crop>
Listen to the change event
document.addEventListener('image-crop-change', function (event){
console.log(
'Crop area changed.',
event.detail.x,
event.detail.y,
event.detail.width,
event.detail.height
)
})
Browser support
Browsers without native custom element support require a polyfill. Legacy browsers require various other polyfills. See examples/index.html
for details.
- Chrome
- Firefox
- Safari
- Microsoft Edge