UNPKG

626 BJavaScriptView Raw
1import window from '../window';
2
3let styfn = {};
4
5// gets what an em size corresponds to in pixels relative to a dom element
6styfn.getEmSizeInPixels = function(){
7 let px = this.containerCss( 'font-size' );
8
9 if( px != null ){
10 return parseFloat( px );
11 } else {
12 return 1; // for headless
13 }
14};
15
16// gets css property from the core container
17styfn.containerCss = function( propName ){
18 let cy = this._private.cy;
19 let domElement = cy.container();
20
21 if( window && domElement && window.getComputedStyle ){
22 return window.getComputedStyle( domElement ).getPropertyValue( propName );
23 }
24};
25
26export default styfn;