ACT resp code

//  ACT resp
//  returns proper responsive value
/* ======================================= v 0.1.0
 @ values		array/object	if array, it is transformed to object
   ======================================= */
function ACTresp( values, resolutions ){
	if ( ! values ) return;
	resolutions = resolutions || {
		wide    : 1920,
		desktop : 1600,
		laptop  : 1280,
		tablet  : 960,
		mobile  : 640
	}

	if ( $.isArray( values ) ) {
		let tmp = {}
		tmp.wide    = values[0];
		tmp.desktop = values[1] || tmp.wide;
		tmp.laptop  = values[2] || tmp.desktop;
		tmp.tablet  = values[3] || tmp.laptop;
		tmp.mobile  = values[4] || tmp.tablet;
	}
	
	let result = tmp.wide
	
	$.each(resolutions, function(key, val){
		
		if ( $(window).width() <= val ) result = tmp[ key ]
		
	})

	
	return result;
}


ACTreveal();

Leave a Reply

Your email address will not be published. Required fields are marked *