Browse Source

Center image when zooming.

pull/105/head
Evan Theurer 11 years ago
parent
commit
c4c65f5393
  1. 35
      static/js/directives/buddypictureupload.js

35
static/js/directives/buddypictureupload.js

@ -199,32 +199,43 @@ define(['jquery', 'underscore', 'text!partials/buddypictureupload.html', 'bootst
var intervalNum = { var intervalNum = {
num: null num: null
}; };
var pxDefaultMovementSpeed = 5;
var incrementPx = function(num) { var incrementPx = function(num, pxToMove) {
return ((Number(num.match(/[\-0-9]+/)) + 5) + 'px'); if(pxToMove === undefined) {
pxToMove = pxDefaultMovementSpeed;
}
return ((Number(num.match(/[\-0-9]+/)) + pxToMove) + 'px');
}; };
var decrementPx = function(num) { var decrementPx = function(num, pxToMove) {
return ((Number(num.match(/[\-0-9]+/)) - 5) + 'px'); if(pxToMove === undefined) {
pxToMove = pxDefaultMovementSpeed;
}
return ((Number(num.match(/[\-0-9]+/)) - pxToMove) + 'px');
}; };
var moveImageUp = function() { var moveImageUp = function(pxMove) {
$scope.prevImage.style.top = decrementPx($scope.prevImage.style.top); $scope.prevImage.style.top = decrementPx($scope.prevImage.style.top, pxMove);
}; };
var moveImageDown = function() { var moveImageDown = function(pxMove) {
$scope.prevImage.style.top = incrementPx($scope.prevImage.style.top); $scope.prevImage.style.top = incrementPx($scope.prevImage.style.top, pxMove);
}; };
var moveImageLeft = function() { var moveImageLeft = function(pxMove) {
$scope.prevImage.style.left = decrementPx($scope.prevImage.style.left); $scope.prevImage.style.left = decrementPx($scope.prevImage.style.left, pxMove);
}; };
var moveImageRight = function() { var moveImageRight = function(pxMove) {
$scope.prevImage.style.left = incrementPx($scope.prevImage.style.left); $scope.prevImage.style.left = incrementPx($scope.prevImage.style.left, pxMove);
}; };
var makeImageLarger = function() { var makeImageLarger = function() {
$scope.prevImage.style.height = incrementPx($scope.prevImage.style.height); $scope.prevImage.style.height = incrementPx($scope.prevImage.style.height);
moveImageLeft(1);
$scope.prevImage.style.width = incrementPx($scope.prevImage.style.width); $scope.prevImage.style.width = incrementPx($scope.prevImage.style.width);
moveImageUp(2);
}; };
var makeImageSmaller = function() { var makeImageSmaller = function() {
$scope.prevImage.style.height = decrementPx($scope.prevImage.style.height); $scope.prevImage.style.height = decrementPx($scope.prevImage.style.height);
moveImageRight(1);
$scope.prevImage.style.width = decrementPx($scope.prevImage.style.width); $scope.prevImage.style.width = decrementPx($scope.prevImage.style.width);
moveImageDown(2);
}; };
var changeImage = function(evt) { var changeImage = function(evt) {
if (evt.data.intervalNum.num || !evt.data.action) { if (evt.data.intervalNum.num || !evt.data.action) {

Loading…
Cancel
Save