如何使对接面板可调整大小?如何在对接面板中创建滚动容器?
我已经扩展了对接面板与简单的面板在这个答案How to create a Docking Panel。所以最理想的方法就是知道怎么做
SimplePanel.prototype.initialize = function()或者在创建对接面板的某个地方。
发布于 2017-01-13 17:23:44
我更喜欢扩展机制,这样您就可以定义自包含的JavaScript文件。下面是一个例子。现在是style.resize="auto"代码行,以及如何使用其他元素(例如,充满其他元素的DIV )来实现appendChild。有了这个分机,只需调用viewer.loadExtension().
AutodeskNamespace('Autodesk.ADN.Viewing.Extension');
Autodesk.ADN.Viewing.Extension.MyExtension = function (viewer, options) {
Autodesk.Viewing.Extension.call(this, viewer, options);
var _self = this;
///////////////////////////////////////////////////////////////////////////
// load callback
///////////////////////////////////////////////////////////////////////////
_self.load = function () {
// need to access geometry? wait until is loaded
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
createDockPanel();
});
return true;
};
var _dockPanel;
function createDockPanel() {
_dockPanel = new Autodesk.Viewing.UI.DockingPanel(viewer.container, 'ecom', 'Cart');
_dockPanel.container.style.top = "10px";
_dockPanel.container.style.left = "10px";
_dockPanel.container.style.width = "auto";
_dockPanel.container.style.height = "auto";
_dockPanel.container.style.resize = "auto";
_dockPanel.container.appendChild(document.getElementById(‘someOtherElement’)); // for instance, a DIV
_dockPanel.setVisible(true);
}
///////////////////////////////////////////////////////////////////////////
// unload callback
///////////////////////////////////////////////////////////////////////////
_self.unload = function () {
_dockPanel.setVisible(false)
return true;
};
};
Autodesk.ADN.Viewing.Extension.MyExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
Autodesk.ADN.Viewing.Extension.MyExtension.prototype.constructor = Autodesk.ADN.Viewing.Extension.MyExtension;
Autodesk.Viewing.theExtensionManager.registerExtension('Autodesk.ADN.Viewing.Extension.MyExtension', Autodesk.ADN.Viewing.Extension.MyExtension);https://stackoverflow.com/questions/41614717
复制相似问题