如何创建停靠面板?我正在使用示例https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/dockingpanel/ 中的代码,它应该继承并覆盖所需的方法。
SimplePanel = function(parentContainer, id, title, content, x, y)
{
this.content = content;
Autodesk.Viewing.UI.DockingPanel.call(this, parentContainer, id, '');
// Auto-fit to the content and don't allow resize. Position at the coordinates given.
//
this.container.style.height = "auto";
this.container.style.width = "auto";
this.container.style.resize = "none";
this.container.style.left = x + "px";
this.container.style.top = y + "px";
};
SimplePanel.prototype = Object.create(Autodesk.Viewing.UI.DockingPanel.prototype);
SimplePanel.prototype.constructor = SimplePanel;
SimplePanel.prototype.initialize = function()
{
// Override DockingPanel initialize() to:
// - create a standard title bar
// - click anywhere on the panel to move
// - create a close element at the bottom right
//
this.title = this.createTitleBar(this.titleLabel || this.container.id);
this.container.appendChild(this.title);
this.container.appendChild(this.content);
this.initializeMoveHandlers(this.container);
this.closer = document.createElement("div");
this.closer.className = "simplePanelClose";
this.closer.textContent = "Close";
this.initializeCloseHandler(this.closer);
this.container.appendChild(this.closer);
};
在此之后,我调用创建的简单面板:
var parent = document.getElementsByClassName('adsk-viewing-viewer')[0];
var panel = SimplePanel(parent, 'panel1', 'panel1');
它返回错误:“未捕获的 TypeError:this.setVisible 不是 DockingPanel 的函数 (viewer3D.js?v=2.11:34343)”
似乎从
Autodesk.Viewing.UI.DockingPanel.call(this, parentContainer, id, '');
至
var DockingPanel = function (parentContainer, id, title, options) {
并在里面崩溃。
在查看器停靠面板功能“this”内部似乎指的是窗口元素。也许它应该是别的东西?例如,当查看器创建搜索窗口时,它似乎指的是某个 div。