Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A custom element for cropping a square image. Returns x, y, width, and height.

License

NotificationsYou must be signed in to change notification settings

github/image-crop-element

Repository files navigation

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-cropsrc="/avatar.jpg"></image-crop>

Rounded crop area

<image-cropsrc="/avatar.jpg"rounded></image-crop>

With loading state

<image-cropsrc="/avatar.jpg"><imgsrc="spinner.gif"alt=""data-loading-slot/></image-crop>

With autoupdate inputs

<image-cropsrc="/avatar.jpg"><inputtype="hidden"data-image-crop-input="x"name="x"><inputtype="hidden"data-image-crop-input="y"name="y"><inputtype="hidden"data-image-crop-input="width"name="width"><inputtype="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)})

CSS encapsulation

The elements HTML structure is initialized in aShadow DOM, so it is impossible to apply CSS to it. If you need to change the element's default style for any reason, you should open up a new issue (or a pull request!), describing your use case, and we'll work with you on solving the problem.

Browser support

Browsers without nativecustom element support require apolyfill. Legacy browsers require various other polyfills. Seeexamples/index.html for details.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

About

A custom element for cropping a square image. Returns x, y, width, and height.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

[8]ページ先頭

©2009-2025 Movatter.jp