@ebay/ebayui-core
Version:
Collection of core eBay components; considered to be the building blocks for all composite structures, pages & apps.
24 lines (23 loc) • 682 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class Avatar {
onCreate(input) {
this.state = {
imagePlacement: input.knownAspectRatio &&
(input.knownAspectRatio < 3 / 4 ||
input.knownAspectRatio > 4 / 3)
? "fit"
: "cover",
};
}
handleImageLoad(_event, el) {
const aspectRatio = el.naturalWidth / el.naturalHeight;
if (aspectRatio < 3 / 4 || aspectRatio > 4 / 3) {
this.state.imagePlacement = "fit";
}
else {
this.state.imagePlacement = "cover";
}
}
}
module.exports = Avatar;