Merged PR 785242: Add delay to image load to work around Bing issue.

Add delay to image load to work around Bing issue.
This commit is contained in:
Dongyu Zhao 2018-09-28 03:03:58 +00:00
Родитель 15b6faf413
Коммит 4b35a3b128
4 изменённых файлов: 61 добавлений и 48 удалений

23
dist/Views/CardElements/Image.js поставляемый
Просмотреть файл

@ -63,6 +63,18 @@ export class ImageView extends React.Component {
});
}
};
this.fetchImageSize = () => {
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
};
this.state = {
loaded: false,
width: 0,
@ -71,16 +83,7 @@ export class ImageView extends React.Component {
}
componentDidMount() {
this.mounted = true;
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
setTimeout(this.fetchImageSize, 500);
}
componentWillUnmount() {
this.mounted = false;

Просмотреть файл

@ -63,6 +63,18 @@ export class ImageView extends React.Component {
});
}
};
this.fetchImageSize = () => {
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
};
this.state = {
loaded: false,
width: 0,
@ -71,16 +83,7 @@ export class ImageView extends React.Component {
}
componentDidMount() {
this.mounted = true;
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
setTimeout(this.fetchImageSize, 500);
}
componentWillUnmount() {
this.mounted = false;

Просмотреть файл

@ -39,24 +39,7 @@ export class ImageView extends React.Component<IProps, IState> {
public componentDidMount() {
this.mounted = true;
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(
model.url,
size || model.size,
{ width: maxWidth, height: maxHeight },
this.onImageSize,
this.onImageSizeError
);
}
setTimeout(this.fetchImageSize, 500);
}
public componentWillUnmount() {
@ -167,6 +150,27 @@ export class ImageView extends React.Component<IProps, IState> {
}
}
private fetchImageSize = () => {
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(
model.url,
size || model.size,
{ width: maxWidth, height: maxHeight },
this.onImageSize,
this.onImageSizeError
);
}
}
private get flex() {
const { model, size } = this.props;

Просмотреть файл

@ -63,6 +63,18 @@ export class ImageView extends React.Component {
});
}
};
this.fetchImageSize = () => {
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
};
this.state = {
loaded: false,
width: 0,
@ -71,16 +83,7 @@ export class ImageView extends React.Component {
}
componentDidMount() {
this.mounted = true;
const { model, size, maxWidth, maxHeight } = this.props;
if (model) {
if (model.context) {
let handler = model.context.infoHandler;
if (handler) {
handler(`AdaptiveCard >> Start load img >> ${model.url}`);
}
}
ImageUtils.fetchSize(model.url, size || model.size, { width: maxWidth, height: maxHeight }, this.onImageSize, this.onImageSizeError);
}
setTimeout(this.fetchImageSize, 500);
}
componentWillUnmount() {
this.mounted = false;