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