Skip to content

Commit

Permalink
#1872: fix issue with aspect ratio for chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
glefi committed Feb 21, 2019
1 parent 9b98b7e commit 378965f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions __tests__/src/components/CanvasThumbnail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ describe('CanvasThumbnail', () => {

it('renders properly', () => {
expect(wrapper.matchesElement(
<IntersectionObserver onChange={wrapper.instance().handleIntersection}>
<img alt="" />
</IntersectionObserver>,
<div>
<IntersectionObserver onChange={wrapper.instance().handleIntersection}>
<img alt="" />
</IntersectionObserver>
</div>,
)).toBe(true);
});

Expand Down
22 changes: 12 additions & 10 deletions src/components/CanvasThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ export default class CanvasThumbnail extends Component {
const { loaded, image } = this.state;
const imgStyle = { height, width: '100%', ...style };
return (
<IntersectionObserver onChange={this.handleIntersection}>
<img
alt=""
onClick={onClick}
onKeyPress={onClick}
role="presentation"
src={loaded && isValid ? image.src : CanvasThumbnail.defaultImgPlaceholder}
style={imgStyle}
/>
</IntersectionObserver>
<div>
<IntersectionObserver onChange={this.handleIntersection}>
<img
alt=""
onClick={onClick}
onKeyPress={onClick}
role="presentation"
src={loaded && isValid ? image.src : CanvasThumbnail.defaultImgPlaceholder}
style={imgStyle}
/>
</IntersectionObserver>
</div>
);
}
}
Expand Down

0 comments on commit 378965f

Please sign in to comment.