import * as Utils from '../utils' ; import { Data } from './models' ; internal export function applyLayout ( data ) { data . target . attr ( 'unselectable' , 'on' ) . css ( { width : '' , height : '' , '-ms-user-select' : 'none' , '-moz-user-select' : 'none' , '-khtml-user-select' : 'none' , '-webkit-user-select' : 'none' , 'user-select' : 'none' } ) ; const size = data . responsive ? Utils . getComputedSize ( data ) : Utils . getOuterSize ( data ) ; const layout = Utils . getInnerLayout ( data . sizeMode , Utils . getInnerSize ( data ) , size ) ; data . target . css ( { width : size . width , height : size . height , position : 'relative' , overflow : 'hidden' } ) ; data . stage . css ( layout ) . hide ( ) ; if ( ! data . canvas ) { return ; } data . canvas . css ( layout ) . hide ( ) ; data . canvasRatio = data . canvasRatio || Utils . pixelRatio ( data . context ) ; if ( typeof layout . width === 'number' && typeof layout . height === 'number' ) { data . canvas [ 0 ] . width = ( ( layout . width as number ) * data . canvasRatio ) || size . width ; data . canvas [ 0 ] . height = ( ( layout . height as number ) * data . canvasRatio ) || size . height ; } else { data . canvas [ 0 ] . width = ( size . width * data . canvasRatio ) ; data . canvas [ 0 ] . height = ( size . height * data . canvasRatio ) ; } data . context . scale ( data . canvasRatio , data . canvasRatio ) ; }