Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Dec 11, 2024
1 parent fcef217 commit 7eb0880
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
11 changes: 6 additions & 5 deletions js/src/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* @file Gui
* @author Alexander Rose <[email protected]>
*/
var NGL = require('ngl');
var UI = require('./ui/ui.js').UI;
var signals = require("./lib/signals.min.js");

// NOTE: This file is a modified version of the original file
import * as NGL from 'ngl';
import { UI } from './ui/ui.js';
import signals from './lib/signals.min.js';

HTMLElement.prototype.getBoundingClientRect = (function () {
// workaround for ie11 behavior with disconnected dom nodes
Expand Down Expand Up @@ -139,7 +140,7 @@ NGL.Preferences.prototype = {

// Stage

class StageWidget{
export class StageWidget{
constructor(view){
// view: NGLView of NGLModel
var el
Expand Down Expand Up @@ -268,7 +269,7 @@ class StageWidget{

var w = ew - sw + 'px'

stage.viewer.container.style.width = w
stage.viewer.container.style.width = w
stage.handleResize()
}

Expand Down
9 changes: 6 additions & 3 deletions js/src/stage_manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as NGL from "ngl";
import { NGLView } from "./widget_ngl";
import * as $ from "jquery";
import { WidgetView } from "@jupyter-widgets/base";

export class StageManager {
stage: NGL.Stage;
Expand All @@ -10,7 +11,7 @@ export class StageManager {
this.view = view;
}

createStage() {
async createStage() {
var stage_params = {
...this.view.model.get("_ngl_full_stage_parameters")
};
Expand All @@ -37,10 +38,12 @@ export class StageManager {
);
if (this.view.embedHandler.isEmbeded()) {
console.log("Embed mode for NGLView");
this.view.handleEmbed();
this.view.embedHandler.handleEmbed();
} else {
this.view.requestUpdateStageParameters();
if (this.view.model.views.length == 1) {
const viewsDict = await this.view.model.views;
const views = await Promise.all(Object.values(viewsDict));
if (views.length === 1) {
this.view.serialize_camera_orientation();
} else {
this.view.set_camera_orientation(this.view.model.get("_camera_orientation"));
Expand Down
3 changes: 2 additions & 1 deletion js/src/ui_manager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StageWidget } from "./gui";
import { StageManager } from "./stage_manager";
import { NGLView } from "./widget_ngl";
import * as NGL from 'ngl';
Expand Down Expand Up @@ -76,6 +77,6 @@ export class UIManager {
}

createNglGUI() {
this.view.stage_widget = new StageManager(this.view);
this.view.stage_widget = new StageWidget(this.view);
}
}
2 changes: 1 addition & 1 deletion js/src/widget_ngl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class NGLView extends widgets.DOMWidgetView {
$container: any;
ngl_view_id: string;
uuid: string;
stage_widget: typeof StageWidget;
stage_widget: StageWidget;
_ngl_focused: number;
comp_uuids: string[];
_synced_model_ids: string[];
Expand Down

0 comments on commit 7eb0880

Please sign in to comment.