Created
December 16, 2013 11:44
-
-
Save oswaldoacauan/7985808 to your computer and use it in GitHub Desktop.
JS - List of devices and his viewports to use with grunt-screenshot, snippet proudly "stolen" from yeoman generator-mobile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var devices = [ | |
{ | |
name: 'G1', | |
width: 320, | |
height: 480, | |
density: 1 | |
}, { | |
name: 'Nexus S', | |
width: 480, | |
height: 800, | |
density: 1.5 | |
}, { | |
name: 'Nexus 4', | |
width: 768, | |
height: 1280, | |
density: 2 | |
}, { | |
name: 'Nexus 7 Orig.', | |
width: 800, | |
height: 1280, | |
density: 1.33 | |
}, { | |
name: 'Nexus 7 2.0', | |
width: 1200, | |
height: 1920, | |
density: 2 | |
}, { | |
name: 'Xoom', | |
width: 800, | |
height: 1280, | |
density: 1 | |
}, { | |
name: 'Nexus 10', | |
width: 1600, | |
height: 2560, | |
density: 2 | |
}, { | |
name: 'iPhone 3GS', | |
width: 320, | |
height: 480, | |
density: 1 | |
}, { | |
name: 'iPhone 4 / 4S', | |
width: 640, | |
height: 960, | |
density: 2 | |
}, { | |
name: 'iPhone 5', | |
width: 640, | |
height: 1136, | |
density: 2 | |
}, { | |
name: 'iPad 1 & 2', | |
width: 768, | |
height: 1024, | |
density: 1 | |
}, { | |
name: 'iPad 3 & 4', | |
width: 1536, | |
height: 2048, | |
density: 2 | |
} | |
]; | |
var skipList = {}; | |
this.viewports = ''; | |
for(var i = 0; i < devices.length; i++) { | |
var device = devices[i]; | |
var width = Math.ceil(device.width / device.density); | |
var height = Math.ceil(device.height / device.density); | |
// Only width matters since screenshot is of full height | |
var identifier = width;// +'x'+height; | |
if(typeof skipList[identifier] !== 'undefined') { | |
continue; | |
} | |
skipList[identifier] = {}; | |
if(i !== 0) { | |
this.viewports += ','; | |
} | |
this.viewports += '\''+width+'x'+height+'\','; | |
this.viewports += '\''+height+'x'+width+'\''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment