Skip to content

Commit e8aa4d1

Browse files
committed
Fix media sizing with CSS resets
1 parent 980b76e commit e8aa4d1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

cypress/integration/basic_spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ describe('Basic assertions', function () {
1616
cy.percySnapshot()
1717
})
1818

19+
it('keeps wide images correctly sized with global CSS reset rules', function () {
20+
cy.document().then((doc) => {
21+
const style = doc.createElement('style')
22+
style.textContent = 'img, video { max-width: 100%; }'
23+
doc.head.appendChild(style)
24+
})
25+
26+
cy.get('img').should('have.css', 'width', '1000px')
27+
assertCssNumberCloseTo('img', 'height', 523.546875)
28+
})
29+
1930
it('Display tall images and set the image and cropper with correct dimension', function () {
2031
cy.visit('/?img=/images/cat.jpeg')
2132
cy.get('img').should('have.css', 'width', '338.4375px')

src/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
.reactEasyCrop_Image,
1717
.reactEasyCrop_Video {
1818
will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
19+
max-width: unset; /* prevent global img/video reset rules from constraining the cropper media */
1920
}
2021

2122
.reactEasyCrop_Contain {

0 commit comments

Comments
 (0)