hongkhanh / cropbox

A lightweight and simple JavaScript, Jquery, YUI plugin to crop your avatar
http://hongkhanh.github.io/cropbox/
MIT License
266 stars 99 forks source link

background-position reset on zoom #5

Open daveshapiro opened 9 years ago

daveshapiro commented 9 years ago

Move an image away from origin and then attempt to zoom. The image snaps back to origin.

hongkhanh commented 9 years ago

Hi, currently, the zoom always from center as use for only avatar crop. If you want to use with large image, you can replace setBackground function with the following:

        setBackground = function()
        {
            var w =  parseInt(obj.image.width)*obj.ratio;
            var h =  parseInt(obj.image.height)*obj.ratio;

            //var pw = (el.width() - w) / 2;
            //var ph = (el.height() - h) / 2;

            el.css({
                'background-image': 'url(' + obj.image.src + ')',
                'background-size': w +'px ' + h + 'px',
               //'background-position': pw + 'px ' + ph + 'px',
                'background-position': 'px ' + 'px',
                'background-repeat': 'no-repeat'});
        },

I will add an option for zoom function as params later.

Cheers,

daveshapiro commented 9 years ago

That's still no good... The provided alternative will expand/shrink from the top-left. Expected behavior is:

hongkhanh commented 9 years ago

Actually, the logic is simple. You can customize background position as you expected. I will update the plugin soon when I have free time, Cheers

On Fri, Nov 7, 2014 at 9:20 PM, daveshapiro notifications@github.com wrote:

That's still no good... The provided alternative will expand/shrink from the top-left. Expected behavior is:

  • When zooming using mouse, use mouse cursor as center point
  • When zooming using +/- buttons, use center of stage as center point

— Reply to this email directly or view it on GitHub https://github.com/hongkhanh/cropbox/issues/5#issuecomment-62150448.

darro87 commented 9 years ago

Desperately need this feature as well. Any update on when it should be expected?

Alino commented 8 years ago

+1