Hello,
I would like to know how can i override the Canvas function ‘createContainer()’ in order to add scrolling to the viewer.
I tried overriding it but i got the error canvas.getContainer() is not a function.
This is my code:
import * as _Canvas from 'diagram-js/lib/core/canvas.js';
export class CustomCanvas {
constructor() {
}
createContainer(options) {
options = _Canvas.assign({}, { width: '100%', height: '800px' }, options);
const container = options.container || document.body;
// create a <div> around the svg element with the respective size
// this way we can always get the correct container size
// (this is impossible for <svg> elements at the moment)
const parent = document.createElement('div');
parent.setAttribute('class', 'djs-container');
_Canvas.assign(parent.style, {
position: 'relative',
overflow: 'scroll',
width: _Canvas.ensurePx(options.width),
height: _Canvas.ensurePx(options.height)
});
container.appendChild(parent);
return parent;
}
}
This is my customCanvas file. And then this is the code to initialize the Viewer:
const viewer = new Viewer({
container: '#canvas',
additionalModules: [
{'canvas': ['type', CustomCanvas ]}
]
});
I am using Angular.
Any help will be appreciated.