Giter VIP home page Giter VIP logo

Comments (8)

alyssaxuu avatar alyssaxuu commented on May 17, 2024

This is already a feature, you can use onSnap which gets triggered when a block can attach to another block, and use the parent parameter + the current block to determine on your end if the blocks can attach or not. Just return false to prevent the attachment.

Let me know if that helps.

from flowy.

imeneses avatar imeneses commented on May 17, 2024

Do you mean this function on the demo? function snapping(drag, first)

from flowy.

alyssaxuu avatar alyssaxuu commented on May 17, 2024

Do you mean this function on the demo? function snapping(drag, first)

Yes, exactly. Here is how it works.

from flowy.

imeneses avatar imeneses commented on May 17, 2024

I am having issues getting the value out of the parent block. parent.querySelector(".blockelemtype").value returns Uncaught TypeError: parent.querySelector is not a function

from flowy.

imeneses avatar imeneses commented on May 17, 2024

These are the only properties I get from parent, I can't access the value property
{"parent":-1,"childwidth":318,"id":0,"x":1158,"y":327,"width":318,"height":120}

from flowy.

alyssaxuu avatar alyssaxuu commented on May 17, 2024

Oh oops, this is clearly an oversight from my part as the parent property of the on snap method should return a DOM element and not the array. I've just fixed it, so now you can access the div to get the value.

from flowy.

imeneses avatar imeneses commented on May 17, 2024

Thank you so much! Worked perfectly :)

from flowy.

imeneses avatar imeneses commented on May 17, 2024

One more question, to filter what block can be the root block, the first one in the canvas, I should filter in flowy.endDrag or in the snapping function? If I do it in snapping it seems to attach it anyway. Thank you!

from flowy.

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.