Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightbox controls should be actually hidden and not hidden by setting opacity to 0 #13042

Merged
merged 3 commits into from Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions extensions/amp-lightbox-viewer/0.1/amp-lightbox-viewer.css
Expand Up @@ -60,10 +60,6 @@
z-index: 2;
}

.i-amphtml-lbv-top-bar.hide {
opacity: 0;
}

.i-amphtml-lbv-top-bar.fullscreen .i-amphtml-lbv-top-bar-top-gradient {
position: absolute !important;
left: 0 !important;
Expand Down Expand Up @@ -99,10 +95,6 @@
padding-top: 50px !important;
}

.i-amphtml-lbv-desc-box.hide {
opacity: 0;
}

.i-amphtml-lbv-desc-text {
padding: 20px;
position: relative !important;
Expand Down
62 changes: 21 additions & 41 deletions extensions/amp-lightbox-viewer/0.1/amp-lightbox-viewer.js
Expand Up @@ -339,25 +339,7 @@ export class AmpLightboxViewer extends AMP.BaseElement {
// text area is a div that does not contain descendant elements.
this.descriptionTextArea_./*OK*/innerText = descText;
if (!descText) {
this.descriptionBox_.classList.add('hide');
}
}

/**
* Toggle description box if it has text content
* @param {boolean=} opt_display
* @private
*/
toggleDescriptionBox_(opt_display) {
this.updateDescriptionBox_();
dev().assert(this.descriptionBox_);
if (opt_display == undefined) {
opt_display = this.descriptionBox_.classList.contains('hide');
}
if (this.descriptionBox_.textContent) {
this.descriptionBox_.classList.toggle('hide', !opt_display);
} else {
this.descriptionBox_.classList.add('hide');
toggle(dev().assertElement(this.descriptionBox_), false);
}
}

Expand All @@ -366,6 +348,7 @@ export class AmpLightboxViewer extends AMP.BaseElement {
* @private
*/
toggleDescriptionOverflow_() {
// TODO: if there is nothing to expand into, don't shim.
if (this.descriptionBox_.classList.contains('standard')) {
const measureBeforeExpandingDescTextArea = state => {
state.prevDescTextAreaHeight =
Expand Down Expand Up @@ -444,19 +427,6 @@ export class AmpLightboxViewer extends AMP.BaseElement {
});
}

/**
* Toggle lightbox top bar
* @param {boolean=} opt_display
* @private
*/
toggleTopBar_(opt_display) {
dev().assert(this.topBar_);
if (opt_display == undefined) {
opt_display = this.topBar_.classList.contains('hide');
}
this.topBar_.classList.toggle('hide', !opt_display);
}

/**
* Builds the top bar containing buttons and appends them to the container.
* @private
Expand Down Expand Up @@ -505,18 +475,30 @@ export class AmpLightboxViewer extends AMP.BaseElement {
this.topBar_.appendChild(button);
}

/**
* Toggle description box if it has text content
* @param {boolean} display
* @private
*/
toggleDescriptionBox_(display) {
this.updateDescriptionBox_();
toggle(dev().assertElement(this.descriptionBox_), display);
}

/**
* Toggle lightbox controls including topbar and description.
* @private
*/
toggleControls_() {
if (this.controlsMode_ == LightboxControlsModes.CONTROLS_HIDDEN) {
this.toggleDescriptionBox_(/* opt_display */true);
this.toggleTopBar_(/* opt_display */true);
toggle(dev().assertElement(this.topBar_), true);
if (!this.container_.hasAttribute('gallery-view')) {
this.toggleDescriptionBox_(true);
}
this.controlsMode_ = LightboxControlsModes.CONTROLS_DISPLAYED;
} else {
this.toggleDescriptionBox_(/* opt_display */false);
this.toggleTopBar_(/* opt_display */false);
this.toggleDescriptionBox_(false);
toggle(dev().assertElement(this.topBar_), false);
this.controlsMode_ = LightboxControlsModes.CONTROLS_HIDDEN;
}
}
Expand Down Expand Up @@ -867,9 +849,6 @@ export class AmpLightboxViewer extends AMP.BaseElement {
this.cleanupEventListeners_();

this.vsync_.mutate(() => {
// Reset the state of the description box
this.descriptionBox_.classList.remove('hide');

// If there's gallery, set gallery to display none
this.container_.removeAttribute('gallery-view');

Expand Down Expand Up @@ -921,7 +900,7 @@ export class AmpLightboxViewer extends AMP.BaseElement {
this.container_.setAttribute('gallery-view', '');
this.topBar_.classList.add('fullscreen');
toggle(dev().assertElement(this.carousel_), false);
this.toggleDescriptionBox_(false);
toggle(dev().assertElement(this.descriptionBox_), false);
}

/**
Expand All @@ -934,7 +913,8 @@ export class AmpLightboxViewer extends AMP.BaseElement {
this.topBar_.classList.remove('fullscreen');
}
toggle(dev().assertElement(this.carousel_), true);
this.toggleDescriptionBox_(true);
this.updateDescriptionBox_();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this.updatedesciptionBox_ need to be called when this.descriptionBox_ is toggled? It could be good defensive practice to create one method that calls both of them so no one risks forgetting to call this.updatedesciptionBox_ when toggling it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I'll bring that function back.

toggle(dev().assertElement(this.descriptionBox_), true);
}

/**
Expand Down