Skip to content

Commit

Permalink
Don't add controls which is missing hide function.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyblasta committed Dec 7, 2022
1 parent aa4d133 commit e6f9d74
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,12 @@ const Viewer = function Viewer(targetOption, options = {}) {
const addControl = function addControl(control) {
if (control.onAdd && control.dispatch) {
if (control.options.hideWhenEmbedded && isEmbedded(this.getTarget())) {
if (!['sharemap', 'link', 'about', 'print', 'draganddrop'].includes(control.name)) {
this.addComponent(control);
}
if(typeof control.hide === 'function') {
// Exclude these controls in the array since they can't be hidden and the solution is to not add them. If the control hasn't a hide method don't add the control.
if (!['sharemap', 'link', 'about', 'print', 'draganddrop'].includes(control.name)) {
this.addComponent(control);
}
control.hide();
} else {
// If there is no hide function on control, try hide the components instead.
control.getComponents().forEach((comp) => {
if (document.getElementById(comp.getId()) !== null) {
document.getElementById(comp.getId()).classList.add("hidden");
}
});
}
} else {
this.addComponent(control);
Expand Down

0 comments on commit e6f9d74

Please sign in to comment.