如何获得事件缩放的值并从输入更改它
How I can get the values of the event zoom and change it from an input
我的情况是这样的:
我使用这个库:
http://fengyuanchen.github.io/cropper/我可以看到,我可以使用事件缩放来检索缩放图像的值。所以我想知道如何从一个像selectable这样的输入中获取并改变它
var $content = $(c_s),
$image = $(p_s),
$dataWidth = $(i_w_s),
$dataHeight = $(i_h_s),
$dataX = $(i_x_s),
$dataY = $(i_y_s),
options = {
autoCropArea: 1,
strict: true,
guides: true,
highlight: true,
dragCrop: false,
cropBoxMovable: false,
cropBoxResizable: false,
movable: true,
background: true,
minContainerWidth: 340,
minContainerHeight: 226,
minCanvasWidth: 340,
minCanvasHeight:226,
minCropBoxWidth: 340,
minCropBoxHeight:226,
aspectRatio: radio,
crop: function (data) {
$dataX.val(Math.round(data.x));
$dataY.val(Math.round(data.y));
$dataHeight.val(Math.round(data.height));
$dataWidth.val(Math.round(data.width));
}
};
$image.on({
'zoom.cropper': function (e) {
console.log(e.type, e.ratio);
}
}).cropper(options);
这是这个库的文档https://github.com/fengyuanchen/cropper zoomcropper
在代码的末尾,你可以看到我有一个console.log
来检查是否有什么,但在我的Firebug控制台什么也没有
文档
$().on('zoom.cropper', function (e) {
var maxRatio = 10;
var imageData = $(this).cropper('getImageData');
var currentRatio = imageData.width / imageData.naturalWidth;
// Zoom in
if (e.ratio > 0 && currentRatio > maxRatio) {
// Prevent zoom in
e.preventDefault();
// Fit the max zoom ratio
$(this).cropper('setCanvasData', {
width: imageData.naturalWidth * maxRatio
});
}
// Zoom out
// ...
});
代码$image.on({
'zoom.cropper': function (e) {
console.log(e.type, e.ratio);
}
}).cropper(options);
看区别…语法
应该是
$image.cropper(options);
$image.on('zoom.cropper', function (e) {
console.log("Here "+e);
})
相关文章:
- 如何从多个不同的html页面获得mongodb文档的用户输入
- 如何限制一个字段只接受4个数字字符作为输入,并获得'It’这是潜水警报
- 在Ionic中获得了未定义的输入值
- CKEditor如何获得对话框输入
- Javascript提示和警报输入一个数字,它将循环,您将输入数字以获得它的平均值
- 使用JSDOM,我想获得所有具有相同名称的输入标记
- 在使用onblur进行输入评估时,是否可以获得单击对象的元素id
- 如何在单击按钮时获得最后一个焦点文本框输入
- 如何获得设置超时以从输入中读取值
- 一种在javascript上获得具有两个输入(字符串)的散列键的方法
- 如何从html输入类型=“”中只获得Angular控制器变量中的时间值;时间”;
- 我正在尝试将javascript文本框的输入保存回服务器.我想从保存的弹出文本框中获得输入,以重命名文件夹
- 谷歌地图:如何在多选输入中获得城市+邮政编码+州+国家
- 如何创建一个javascript表,并从输入中获得计算结果作为表数据
- 如果所有输入都为真,如何获取多个输入并获得最终值
- 聚合物:无法从纸张输入元件获得输入
- 引导选项卡如何从选项卡输入值获得值基
- 比较JSON数组与用户输入并获得一个值
- 在jQuery中可以通过输入名称获得onclick值吗?
- 如何从c#生成的html输入中获得多个值