Skip to content

Instantly share code, notes, and snippets.

@travisdmathis
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save travisdmathis/573350025c4e96c82ae7 to your computer and use it in GitHub Desktop.

Select an option

Save travisdmathis/573350025c4e96c82ae7 to your computer and use it in GitHub Desktop.
function move (e){
var moveby = {
x: origin.x - e.clientX,
y: origin.y - e.clientY
};
if (movecontinue === true) {
start.x = start.x - moveby.x;
start.y = start.y - moveby.y;
//position by percentage conversion
width = $("#folder_image_picker_modal .folder_image").css('background-size').replace('% auto','');
percent_x = (start.x / $("#folder_image_picker_modal .folder_image").width() ) * 100;
percent_y = (start.y / $("#folder_image_picker_modal .folder_image").height() ) * 100;
$(this).css('background-position', percent_x + '% ' + percent_y + '%');
}
origin.x = e.clientX;
origin.y = e.clientY;
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment