我将宽度设置为100px,高度设置为100px。我需要在调整可调整大小的div 大小时获取 ScaleX 和 ScaleY 值..?我已经使用Jquery-ui来调整大小。请先检查铬。请帮助我。提前谢谢。
$("#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 中的代码。!
你能试试这个吗?
$("#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);
}
});
我注意到,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);
}
});