image-crop-element

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

MIT License

Downloads
147.1K
Stars
180
Committers
9

Bot releases are visible (Hide)

image-crop-element - v5.1.0 Latest Release

Published by keithamus over 1 year ago

What's Changed

Full Changelog: https://github.com/github/image-crop-element/compare/v5.0.0...v5.1.0

image-crop-element -

Published by koddsson over 3 years ago

The HTML structure for the component and its basic CSS is now in a Shadow DOM. We've added a rounded attribute for a circle mask in the crop area. https://github.com/github/image-crop-element/pull/38

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM

image-crop-element -

Published by koddsson over 3 years ago

  • Fix visible edge of crop area (#36)
    • Thank you @simonw!

https://github.com/github/image-crop-element/compare/v4.1.0...v4.1.1

image-crop-element -

Published by koddsson almost 4 years ago

image-crop-element -

Published by keithamus almost 4 years ago

This release refactors the project to use TypeScript, while also dropping the UMD build. https://github.com/github/image-crop-element/pull/29

BREAKING CHANGES

  • The UMD build has been dropped. Projects will need to migrate to the Native ES Module build instead.
image-crop-element - v3.0.8

Published by keithamus over 4 years ago

  • fix(types): use correct type expression (#28)

https://github.com/github/image-crop-element/compare/v3.0.7...v3.0.8

image-crop-element -

Published by koddsson over 4 years ago

  • Add type to HTMLElementTagNameMap in typescript declaration file (#26)

https://github.com/github/image-crop-element/compare/v3.0.6...v3.0.7

image-crop-element -

Published by keithamus about 5 years ago

  • types(ts): add window declaration 97fbc4c
  • Bump eslint-utils from 1.3.1 to 1.4.2 303e61f

https://github.com/github/image-crop-element/compare/v3.0.4...v3.0.5

image-crop-element -

Published by koddsson about 5 years ago

  • Merge pull request #20 from github/add-typescript-definition-file 173b0f7
  • loaded is not a nullable field c676605
  • use union type for nullable types 45d293e
  • Merge branch 'master' into add-typescript-definition-file ee39326
  • add typescript definition file 0b79c40

https://github.com/github/image-crop-element/compare/v3.0.3...v3.0.4

image-crop-element - 3.0.4

Published by koddsson about 5 years ago

<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
image-crop-element -

Published by koddsson about 5 years ago

  • Merge pull request #23 from github/publish-to-gpr-as-well 0267bac
  • publish to GPR as a postpublish step b9191e0

https://github.com/github/image-crop-element/compare/v3.0.2...v3.0.3

image-crop-element - 3.0.3

Published by koddsson about 5 years ago

<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
image-crop-element -

Published by koddsson about 5 years ago

  • Merge pull request #22 from github/dependabot/npm_and_yarn/lodash-4.17.15 4435ccc
  • Bump lodash from 4.17.11 to 4.17.15 c80aa01
  • Merge pull request #21 from notlmn/fix-examples 8809470
  • Add in suggestions, drop polyfill.html e87d30d
  • Fix links in example files ada1549

https://github.com/github/image-crop-element/compare/v3.0.1...v3.0.2

image-crop-element -

Published by koddsson over 5 years ago

  • Merge pull request #19 from github/update-deps 2f072ef
  • update eslint, eslint-plugin-github and flow-bin manually to latest versiosn 7f5361c
  • run npm update dadbefe

https://github.com/github/image-crop-element/compare/v3.0.0...v3.0.1