default crop to unconstrained proportions

5 posts, 1 answers
  1. Brad
    Brad avatar
    20 posts
    Member since:
    Apr 2010

    Posted 23 Apr 2012 Link to this post

    Hello, 

    How can I change the default setting of the Crop tool from Constrained Proportions to Unconstrained Proportions.

    I see many threads about defining the size, ratio and disabling buttons for easy thumbnail creation, but I just need to change the default to Unconstrained. 
  2. Niko
    Admin
    Niko avatar
    387 posts

    Posted 24 Apr 2012 Link to this post

    Hello Brad,

    You can easily modify the widget dialog UI from the client-side. You can check the following forum post for a similar request - http://www.telerik.com/community/forums/aspnet-ajax/image-editor/cropping.aspx.
    Basically you could call the set_checked(false) to the constraint button of the crop box dialog. Here is a sample implementation:
    function modifyCommand (editor, args)
    {
        waitForCommand(editor, args.get_commandName(), function(widget) {
            widget._constraintBtn.set_checked(false);
        });
    }
      
    function waitForCommand(imageEditor, commandName, callback)
    {
        var timer = setInterval(function()
        {
            var widget = imageEditor.get_currentToolWidget();
            if(widget && widget.get_name() == commandName)
            {
                clearInterval(timer);
                callback(widget);
            }
        }, 200);
    }
    where modifyCommand is an event handler of the OnClientCommandExecuted.

    Hope this helps.

    All the best,
    Niko
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brad
    Brad avatar
    20 posts
    Member since:
    Apr 2010

    Posted 08 May 2012 Link to this post

    Hello Niko,

    I am unable to get this code to work on my site. Can you confirm that the code posted above works for you. Attached are screenshots of what happens for me.

    The code modifies the widget and changes the Constrain Proportions button to a broken link. But, dragging and dropping the Crop Selection still constrains the proportions. If I click the Constrain Proportions button with the mouse until it is a broken link, then the Crop Selection operates properly.

    Brad

  5. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 09 May 2012 Link to this post

    Hello Brad,

    Please, accept my apologies for the incomplete example that I was given you. There are two more things that should be done in order to the dialog to restrain the constraints on the crop box. Here is a more complete solution (for brevity I have skipped the declaration of the waitForCommand method):
    function modifyCommand(editor, args)
    {
        if(args.get_commandName() == "Crop")
            waitForCommand(editor, "Crop", function(widget) {
                widget._constraintBtn.set_checked(false);
                widget._setCropBoxRatio(null);
                widget._sizeRatio = null;
            });
    }

    Hope this helps.

    Kind regards,
    Niko
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Brad
    Brad avatar
    20 posts
    Member since:
    Apr 2010

    Posted 09 May 2012 Link to this post

    Thanks Niko, those extra statements worked.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017