Git Product home page Git Product logo

Comments (3)

Reklino avatar Reklino commented on July 28, 2024

Cool! It's been on my list to implement a resize increment feature so that snapping to a grid would be possible.

At first thought, it seems best to implement something like 'r-increment-x' and 'r-increment-y' so that you can snap to a grid vertically or horizontally without requiring both. Then from there, we'd just need to set up how it renders. I will work towards a solution for this in my spare time. That said, if you want to submit a pull request or fork the codepen, go for it :)

I tried to find the difference in the value of width, but each method seems to be reporting the same value to me, but I may have misunderstood. See this pen

from angular-resizable.

arcadeJHS avatar arcadeJHS commented on July 28, 2024

Hi, thx for your interest!
I implemented a first version on my project: a horizontal grid is now working and tested. But maybe could be improved!
Maybe two different properties are better, anyway I intended "rGrid" as an array of [x,y] positions.

Basically I modified the "dragging" function recalculating offset this way:

var gridX = scope.rGrid[0] || 1,
      gridY = scope.rGrid[1] || 1;

      offset = (axis == 'x') 
          ? Math.round(((w+offset) - w) / gridX) * gridX
          : Math.round(((h+offset) - h) / gridY) * gridY;

from angular-resizable.

arcadeJHS avatar arcadeJHS commented on July 28, 2024

I created a pull request to submit my code.
Mainly the snap to grid functionality, plus other minor changes, like the correction to width (the problem was on IE) and the original size value returned by updateInfo (to keep track of the size before resize).

from angular-resizable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.