Skip to content

Instantly share code, notes, and snippets.

@MorkHub
Created October 2, 2016 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorkHub/5f1b2c5a1e9cedf921a67385210a3c0e to your computer and use it in GitHub Desktop.
Save MorkHub/5f1b2c5a1e9cedf921a67385210a3c0e to your computer and use it in GitHub Desktop.
$(window).resize(function(){
width = $(this).width();
map = $('div#map');
imgWidth = $('div#map img').width();
scale = width / imgWidth;
transform = 'translateY(-'+10/scale+'%) translateX(-'+10/scale+'%) scale('+scale+')';
map.css({
'width' : (100/scale)+'%',
'-webkit-transform' : transform,
'-moz-transform' : transform,
'-ms-transform' : transform,
'-o-transform' : transform,
'transform' : transform
});
console.log('div#map { width: %s%; transform: %s; }',(100/scale),transform);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment