Passed
Push — master ( 78b380...a2100d )
by Rafael
01:41
created

src/controls/multi-slider/conversion.js   A

Size

Lines of Code 31

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 31
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B conversion.js ➔ ??? 0 12 5
1
export class Conversion {
2
3
	/**
4
	 * Convert Pixels to Ems.
5
	 *
6
	 * @since 1.2.7
7
	 * @return string ems;
8
	 */
9
	pxToEm( px, fontSize ) {
10
		var ems = 0;
11
12
		fontSize = fontSize ? parseInt( fontSize ) : 0;
13
		px = px ? parseInt( px ) : 0;
14
15
		if ( fontSize && px ) {
16
			ems = ( px / fontSize ).toFixed( 1 );
17
		}
18
19
		return ems;
20
	}
21
22
	pxToPercentage( px, $element ) {
23
		let contextWidth = $element.width();
24
		return ( px / contextWidth ) * 100;
25
	}
26
27
	percentageToPixel( percentage, $element ) {
28
		let contextWidth = $element.width();
29
		return contextWidth * ( percentage / 100 );
30
	}
31
}
32