Page MenuHomeWickedGov Phorge

bracketedPixelRatio.js
No OneTemporary

Size
699 B
Referenced Files
None
Subscribers
None

bracketedPixelRatio.js

/**
* @module bracketedPixelRatio
* @private
*/
/**
* Normalizes a user's device pixel ratio to either 1, 1.5, or 2.
*
* This is important when the server resizes images on the fly in order to
* reduce the work it has to do for device pixel ratios that deviate from a
* set of common ratios.
*
* Adapted from mediawiki/core /resources/src/jquery/jquery.hidpi.js
*
* @param {number} [dpr=window.devicePixelRatio]
* @return {number} The bracketed device pixel ratio
*/
export default function ( dpr = window.devicePixelRatio ) {
if ( !dpr ) {
// Probably legacy browser so assume 1
return 1;
}
if ( dpr > 1.5 ) {
return 2;
}
if ( dpr > 1 ) {
return 1.5;
}
return 1;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 3, 04:48 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
12/f4/567b76621822f95f3cf6e0a1fc56
Default Alt Text
bracketedPixelRatio.js (699 B)

Event Timeline