Move Plotly Shadow DOM Hack to helper, refs plotly/plotly.js#1433
This commit is contained in:
parent
d6da5cedd8
commit
ef2249a58d
2 changed files with 15 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { withComponent, props } from 'skatejs';
|
import { withComponent, props } from 'skatejs';
|
||||||
import { colors } from '../lib/colors';
|
import { colors } from '../lib/colors';
|
||||||
import { parseValue } from '../lib//values';
|
import { parseValue } from '../lib/values';
|
||||||
|
import injectCss from '../lib/plotly-shadowdom';
|
||||||
|
|
||||||
const Component = withComponent();
|
const Component = withComponent();
|
||||||
|
|
||||||
|
@ -56,17 +57,7 @@ class LineChart extends Component {
|
||||||
root.removeChild(root.firstChild);
|
root.removeChild(root.firstChild);
|
||||||
}
|
}
|
||||||
root.appendChild(render());
|
root.appendChild(render());
|
||||||
|
injectCss(root);
|
||||||
// Hack for Shadow DOM compat
|
|
||||||
const styles = document.createElement('style');
|
|
||||||
styles.innerText = `
|
|
||||||
.js-plotly-plot .plotly .main-svg {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}`;
|
|
||||||
root.appendChild(styles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render({ data, shape, width, height }) {
|
render({ data, shape, width, height }) {
|
||||||
|
|
12
lib/plotly-shadowdom.js
Normal file
12
lib/plotly-shadowdom.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Hack for Shadow DOM compat
|
||||||
|
export default function injectCss(root) {
|
||||||
|
const styles = document.createElement('style');
|
||||||
|
styles.appendChild(document.createTextNode(`
|
||||||
|
.js-plotly-plot .plotly .main-svg {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}`));
|
||||||
|
root.appendChild(styles);
|
||||||
|
};
|
Loading…
Reference in a new issue