Skip to content

Commit

Permalink
Fixed element colorbar display
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Dec 15, 2023
1 parent 7380f08 commit 9cae3ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions src/map/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,6 @@ export class PropertiesMap {
throw Error(message);
}

this._options = new MapOptions(
this._root,
currentProperties,
(rect) => this.positionSettingsModal(rect),
config.settings
);
this._colorReset = this._options.getModalElement<HTMLButtonElement>('map-color-reset');

this._connectSettings();

// By default, position the modal for settings on top of the plot,
// centered horizontally
this.positionSettingsModal = (rect: DOMRect) => {
Expand All @@ -314,6 +304,16 @@ export class PropertiesMap {
};
};

this._options = new MapOptions(
this._root,
currentProperties,
(rect) => this.positionSettingsModal(rect),
config.settings
);
this._colorReset = this._options.getModalElement<HTMLButtonElement>('map-color-reset');

this._connectSettings();

this._createPlot();

// This is done last as the plot needs to be created to obtain its
Expand Down
32 changes: 16 additions & 16 deletions src/structure/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ export class MoleculeViewer {
noPropsStyle,
];

// By default, position the modal for settings on top of the viewer,
// centered horizontally
this.positionSettingsModal = (rect: DOMRect) => {
const rootRect = this._root.getBoundingClientRect();
return {
left: rootRect.left - rect.width + 500,
top: rootRect.top + 20,
};
};

this._options = new StructureOptions(
this._root,
(rect) => this.positionSettingsModal(rect),
Expand All @@ -272,16 +282,6 @@ export class MoleculeViewer {
this._connectOptions();
this._trajectoryOptions = this._options.getModalElement('trajectory-settings-group');

// By default, position the modal for settings on top of the viewer,
// centered horizontally
this.positionSettingsModal = (rect: DOMRect) => {
const rootRect = this._root.getBoundingClientRect();
return {
left: rootRect.left + rootRect.width / 2, // - rect.width / 2,
top: rootRect.top + 20,
};
};

// Hack to reverse the scroll direction of 3dmol to match that of Plotly
// The wheel event is captured on the parent of the canvas, modified
// and then dispatched on the canvas.
Expand Down Expand Up @@ -1749,7 +1749,7 @@ export class MoleculeViewer {

return {
min: this._viewer.addLabel(
fixedWidthFloat(min)+"-",
fixedWidthFloat(min) + '-',
this._colorBarLabelsSpec({
x: viewerWidth - (horizontalShift + width - 5),
y: viewerHeight - (titleHeight + 8),
Expand All @@ -1758,7 +1758,7 @@ export class MoleculeViewer {
})
),
mid: this._viewer.addLabel(
fixedWidthFloat(mid)+"-",
fixedWidthFloat(mid) + '-',
this._colorBarLabelsSpec({
x: viewerWidth - (horizontalShift + width - 5),
y: viewerHeight - (titleHeight + height / 2),
Expand All @@ -1767,7 +1767,7 @@ export class MoleculeViewer {
})
),
max: this._viewer.addLabel(
fixedWidthFloat(max)+"-",
fixedWidthFloat(max) + '-',
this._colorBarLabelsSpec({
x: viewerWidth - (horizontalShift + width - 5),
y: viewerHeight - (titleHeight + height - 8),
Expand Down Expand Up @@ -1836,9 +1836,9 @@ export class MoleculeViewer {

private _updateColorBar() {
this._deleteColorBar();
// if (this._options.color.property.value !== 'element') {
this._colorBar = this._addColorBar();
// }
if (this._options.color.property.value !== 'element') {
this._colorBar = this._addColorBar();
}
}
}

Expand Down

0 comments on commit 9cae3ab

Please sign in to comment.