Git Product home page Git Product logo

Comments (5)

langscot avatar langscot commented on June 15, 2024

Your code sandbox link is corrupted, it says "something went wrong". Can you share another one?

from svelte-konva.

lavrton avatar lavrton commented on June 15, 2024

Updated. Same link https://codesandbox.io/s/festive-germain-1js7yj?file=/App.svelte

from svelte-konva.

TeyKey1 avatar TeyKey1 commented on June 15, 2024

Ordering within each is kind of a pain point in svelte-konva currently as it can be done in many ways but not all possibilities lead to the desired results. I currently opted to let the user do the layering using the Konva-native layering functionality without recalculating layering on changes manually within each blocks (like vue-konva does for example).

So the problem you face would be solved with the following code:

let handleDragStart = e => {
	// save drag element:
	dragItemId = e.detail.target.id();

	// move current element to the top:
	const item = list.find(i => i.id === dragItemId);

	item.handle.moveToTop(); // Use Konva native way of layering
};

And in the template section add bind:handle={item.handle} to the Star component to get access to the Konva node.

I'm not sure how straightforward it would be in svelte to add a similar functionality akin to vue-konva to order the components within an each block automatically. It would certainly make it more straightforward for end-users to grasp svelte-konva if they come from vue-konva for example. Certainly something I'll look into.

from svelte-konva.

lavrton avatar lavrton commented on June 15, 2024

I think it must follow the order that I have in the template. It is predicable and allows writing in app in a "svelte" and declarative way. If possible, a user should use as less Konva API directly as possible.

from svelte-konva.

TeyKey1 avatar TeyKey1 commented on June 15, 2024

After some more tinkering, this is not possible to achieve in a sound way in Svelte right now. I have created an issue in Svelte about this (sveltejs/svelte#8547) so we might get the required functionality to make this work in the future. For now, we have to rely on the Konva-native way of ordering for such use cases. I'll keep this issue open to track any progress on Svelte side which might make such a functionality possible. I've also written an extensive doc page in the old svelte-konva docs about this, and will port the important bits to the Konva page to avoid too much confusion about this.

from svelte-konva.

Related Issues (3)

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.