jQuery JCrop-如何设置固定大小的选择区域? [英] JQuery JCrop - How to set a fixed size selection area?

查看:354
本文介绍了jQuery JCrop-如何设置固定大小的选择区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何在JCrop下修复选择框的大小.该文档提到了如何设置初始选择区域,但没有提到如何将其设置为固定大小.有谁知道我该如何解决这个问题.预先感谢.

I'm trying to figure out how to fix the selection box size under JCrop. The documentation mentions how to set an initial selection area but not how to make it fixed size. Does anybody knows how could I make it fixed. Thanks in advance.

http://deepliquid.com/content/Jcrop_Manual.html

推荐答案

您基本上是在寻找API部分.我自己广泛使用了此插件,因此我确切知道您要查找的内容:

You are basically looking for the API section. Having extensively used this plugin myself, I know exactly what you're looking for:

var api;
var cropWidth = 100;
var cropHeight = 100;

$(window).load(function() {

    // set default options
    var opt = {};

    // if height and width must be exact, dont allow resizing
    opt.allowResize = false;
    opt.allowSelect = false;

    // initialize jcrop
    api = $.Jcrop('#objectId', opt);

    // set the selection area [left, top, width, height]
    api.animateTo([0,0,cropWidth,cropHeight]);

    // you can also set selection area without the fancy animation
    api.setSelect([0,0,cropWidth,cropHeight]);

});

这篇关于jQuery JCrop-如何设置固定大小的选择区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆