Skip to content

Commit

Permalink
Fix gray border on image for alt with no src bug on lightbox (#12379)
Browse files Browse the repository at this point in the history
* Fix safari gray border bug on lightbox

* Add special case for iOS

* Actually this bug applies to most mobile browsers and desktop safari

* Set image source properly, initialize height width to zero
  • Loading branch information
cathyxz committed Dec 9, 2017
1 parent 4ab32dc commit cf53b4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extensions/amp-lightbox-viewer/0.1/amp-lightbox-viewer.js
Expand Up @@ -29,6 +29,7 @@ import {toggle, setStyle} from '../../../src/style';
import {getData, listen} from '../../../src/event-helper';
import {LightboxManager} from './service/lightbox-manager-impl';
import {layoutRectFromDomRect} from '../../../src/layout-rect';
import {elementByTag} from '../../../src/dom';
import * as st from '../../../src/style';
import * as tr from '../../../src/transition';
import {SwipeYRecognizer} from '../../../src/gesture-recognizers';
Expand Down Expand Up @@ -220,7 +221,7 @@ export class AmpLightboxViewer extends AMP.BaseElement {
container.classList.add('i-amphtml-image-lightbox-container');
const imageViewer = new ImageViewer(this, this.win,
this.loadPromise.bind(this));
imageViewer.init(element);
imageViewer.init(element, elementByTag(element, 'img'));
container.appendChild(imageViewer.getElement());
slide = container;
metadata.imageViewer = imageViewer;
Expand Down
7 changes: 7 additions & 0 deletions src/image-viewer.js
Expand Up @@ -241,6 +241,13 @@ export class ImageViewer {
// It will be updated later.
this.image_.setAttribute('src', sourceImage.src);
}

st.setStyles(this.image_, {
top: st.px(0),
left: st.px(0),
width: st.px(0),
height: st.px(0),
});
}

/**
Expand Down

0 comments on commit cf53b4e

Please sign in to comment.