Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
this.postMessageListener = ({ data: { go, size } }) => {
if (go) {
this.go(go);
}
if (size) {
this.resizeListener();
}
};
window.addEventListener('message', this.postMessageListener, false);
// listen for changes that might change the size of the window
window.addEventListener('resize', this.resizeListener, false);
window.addEventListener('scroll', this.resizeListener, false);
this.performanceObserver = new PerformanceObserver(list => {
if (list.getEntries().find(item => item.initiatorType.match(/(css|img)/))) {
this.resizeListener();
}
});
this.performanceObserver.observe({ entryTypes: ['resource'] });
// pass the rendered window size up to parent
this.resizeListener();
}
componentWillUnmount() {
import {window} from 'global';
import Jupyter from 'base/js/namespace';
// Frontend error handling
window.addEventListener('error', event => {
const msgId = Jupyter.notebook.kernel.last_msg_id;
const cell = Jupyter.notebook.get_msg_cell(msgId);
if (cell) {
const {error} = event;
cell.output_area.append_output({
output_type: 'error',
ename: error.name,
evalue: error.message,
traceback: ['Javascript Error', error.stack],
});
cell.output_area.element
.find('.output_subarea.output_error')
.css({'background-color': '#ff9999'});
}
});
window.parent.postMessage(
{ size: document.documentElement.getBoundingClientRect() },
document.location.origin
);
};
this.postMessageListener = ({ data: { go, size } }) => {
if (go) {
this.go(go);
}
if (size) {
this.resizeListener();
}
};
window.addEventListener('message', this.postMessageListener, false);
// listen for changes that might change the size of the window
window.addEventListener('resize', this.resizeListener, false);
window.addEventListener('scroll', this.resizeListener, false);
this.performanceObserver = new PerformanceObserver(list => {
if (list.getEntries().find(item => item.initiatorType.match(/(css|img)/))) {
this.resizeListener();
}
});
this.performanceObserver.observe({ entryTypes: ['resource'] });
// pass the rendered window size up to parent
this.resizeListener();
}
componentWillUnmount() {
componentDidMount() {
this.onResize();
this.debouncedResize = debounce((...args) => this.onResize(...args), 50);
window.addEventListener('resize', this.debouncedResize);
}
startDragging(boundName, { clientX }) {
this.setState({ currentlyDragging: boundName, prevX: clientX });
const mouseMoveHandler = (...args) => this.onMouseMove(...args);
const mouseUpHandler = () => {
this.stopDragging();
window.removeEventListener('mouseup', mouseUpHandler);
window.removeEventListener('mousemove', mouseMoveHandler);
};
window.addEventListener('mouseup', mouseUpHandler);
window.addEventListener('mousemove', mouseMoveHandler);
}
startDragging(boundName, { clientX }) {
this.setState({ currentlyDragging: boundName, prevX: clientX });
const mouseMoveHandler = (...args) => this.onMouseMove(...args);
const mouseUpHandler = () => {
this.stopDragging();
window.removeEventListener('mouseup', mouseUpHandler);
window.removeEventListener('mousemove', mouseMoveHandler);
};
window.addEventListener('mouseup', mouseUpHandler);
window.addEventListener('mousemove', mouseMoveHandler);
}
componentDidMount() {
window.addEventListener('resize', this._handleResize.bind(this));
this._handleResize();
}
componentDidMount() {
this.postMessageListener = ({ source, data: { size } }) => {
if (size && this.elements.iframe && this.elements.iframe.contentWindow === source) {
this.setState({ height: size.height });
}
};
if (this.props.publisher) {
this.props.publisher.listen((command, ...args) => {
if (command === 'zoom') {
this.setState({ zoom: this.state.zoom + args[0] });
}
});
}
window.addEventListener('message', this.postMessageListener, false);
}
componentWillUnmount() {
componentDidMount() {
window.addEventListener('resize', this.resize);
this.resize();
}
componentDidMount() {
window.addEventListener('resize', this.throttledUpdatePreviewPanelState);
}