Comments (5)
Your code sandbox link is corrupted, it says "something went wrong". Can you share another one?
from svelte-konva.
Updated. Same link https://codesandbox.io/s/festive-germain-1js7yj?file=/App.svelte
from svelte-konva.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-konva.