Opened 12 years ago

Last modified 9 years ago

#6783 open bug

ui.resizable ignored x axis instead of calculating with max difference — at Initial Version

Reported by: em Owned by:
Priority: minor Milestone: 2.0.0
Component: ui.resizable Version: 1.8.7
Keywords: Cc:
Blocked by: Blocking:

Description

Here's an example of my working replacement, since I couldn't use ui.resizable.

Notable difference is in this piece of code, which is the same as every kind of graphic editor out there.

var aspect = settings.aspect;

var diff_x = new_x - start_x; var diff_y = new_y - start_y;

if(diff_x < diff_y*aspect) {

diff_x = diff_y * aspect;

} else {

diff_y = diff_x / aspect;

}


(function($){

var $current = null;

var start_x = 0; var start_y = 0; var start_w = 0; var start_h = 0;

$.fn.myresizable = function(settings){

settings = $.extend( {}, $myresizable.defaults, settings );

$(window).mouseup(function() {

$current = null;

});

function update(new_x,new_y) {

if(!$current)

return;

var aspect = settings.aspect;

var diff_x = new_x - start_x; var diff_y = new_y - start_y;

if(diff_x < diff_y*aspect) {

diff_x = diff_y * aspect;

} else {

diff_y = diff_x / aspect;

}

var new_width = start_w + diff_x; var new_height = start_h + diff_y;

$current.width(new_width); $current.height(new_height);

if(settings.resize) {

settings.resize.apply($current, [new_width, new_height]);

}

}

$(window).mousemove(function(e) {

update(e.screenX, e.screenY);

});

$(window).bind('mousewheel',function(e) {

update(e.screenX, e.screenY); console.log($current);

});

this.find('.resizer').mousedown(function(e) {

var $resizer = $(this); $current = $resizer.parent(); $current.disableSelection();

start_x = e.screenX; start_y = e.screenY; start_w = $current.width(); start_h = $current.height();

settings.aspect = settings.aspect
(start_w/start_h);

});

return this;

};

})( jQuery );

Change History (0)

Note: See TracTickets for help on using tickets.