我已经将宽度设置为100px,高度设置为100px。在调整可调整大小的div..?时,我需要获取ScaleX和ScaleY值。我使用Jquery-ui来调整大小。请先签入chrome。请帮帮我。提前谢谢。
$("#resize_div").resizable({
resize: function(){
node = $("#resize_div")[0];
var curTransform = new WebKitCSSMatrix(window.getComputedStyle(node).webkitTransform);
$("#scalex").text("Scale X: " + curTransform.a);
$("#scaley").text("Scale Y: " + curTransform.d);
}
});
我的Jsfiddle代码。!
发布于 2016-03-16 21:39:23
你能试试这个吗?
$("#resize_div").resizable({
resize: function(){
var width = $(this).width();
var height = $(this).height();
var scalax = width/height;
var scalay = height/width;
node = $("#resize_div")[0];
var curTransform = new WebKitCSSMatrix(window.getComputedStyle(node).webkitTransform);
$("#scalex").text("Scale X: " + scalax);
$("#scaley").text("Scale Y: " + scalay);
}
});
发布于 2016-03-17 13:27:56
我注意到,Scale-X值可以通过将当前宽度(调整大小时)除以初始宽度(在本例中,初始宽度为100px)得到。试试这个..。
$("#resize_div").resizable({
resize: function(){
var width = $(this).width();
var height = $(this).height();
var scalax = width/100;
var scalay = height/100;
$("#scalex").text("Scale X: " + scalax);
$("#scaley").text("Scale Y: " + scalay);
}
});
https://stackoverflow.com/questions/36037102
复制相似问题