Bug Tracker

Modify

Ticket #2748 (closed enhancement: fixed)

Opened 5 years ago

Last modified 5 years ago

Resizable: snap to grid

Reported by: telega Owned by: braeker
Priority: minor Milestone: 1.2.4
Component: ui Version: 1.2.3
Keywords: Cc:
Blocking: Blocked by:

Description

Hi

I found that snap to grid functionality, similar to the Draggable "grid" can be easily added to current Resizable implementation. The change is only 2 lines of code: 1) The first line - add grid option to the list of default options:

    //Prepare the passed options
    this.options = $.extend({
      ...
      grid: [1, 1]
    }, options);

2) The second line - calculate width/height change value using grid option - modify change() method, right after the line, where "val" is calculated:

      var change = function(a,b) {
        ...
        var val = ...
        val = val - val % o.grid[isth ? 0 : 1];

I've implemented this feature because I need it for my project. Maybe others find it useful too.

Regards, telega

Change History

comment:1 Changed 5 years ago by paul

  • Owner changed from paul to braeker

comment:2 Changed 5 years ago by braeker

  • Status changed from new to closed
  • Resolution set to fixed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.