Comments (5)
I'll fill in some more things from the discussion with @balazsbajorics here, and then separately comment on @Rheeseyb your (super helpful) notes.
The core issue is precisely that dragging gives you two things that are mutually incompatible:
-
I feel like I'm control of this thing. It doesn't suddenly stop moving (because it's in a flex context) or "go away" (because I'm dragging over a component that supports props.children but doesn't render them by default)
-
I know what would happen when I let go. If drop this here, it won't end up exactly here, but somewhere else (because it's a flex context, or a flow context). If I drop this there, it won't show up at all (because the component swallows its children). And if I drop this over there, it will transform weirdly.
(1) is direct manipulation, (2) is instant feedback. For design tools, they often go hand in hand, because very few situations will manipulate, transform, hide, or swallow things you're dragging. For us, they diverge - especially with components and styles-that-apply-to-children (transforms, opacity).
However, the solution is on one level quite straightforward, and pretty much what we did previously: show a placeholder and extra controls for (2), show the real element for (1), and after letting go use an animation to make the two converge. -- In theory we could do it the other way 'round (a placeholder that follows the mouse, the real thing moving in and out of containers. We previously didn't do this because (IIRC) of perf concerns.
And: it doesn't need to be perfect. In particular, one of the two does not need to be real or realistic, or even fast - as long as the other is. E.g. Previously we made the placeholder a pink rectangle - almost a "shadow" of the real element - and that worked well because the real element tracked the mouse with very high speed (fueled by our tears of rage, I'm sure you remember / have suppressed this :).
from utopia.
(I'm on the phone with Malte)
Spike 1 for a possible solution would be to make sure that we can make a "screenshot" of the dragged element, and only the dragged element (do not include things that are visually below it or over it etc).
from utopia.
I was just having a look at this to see how simple that proposal would be, and I think this is a bigger problem than that proposal would solve.
So the underlying issue here is that sometimes we don't want the rendered controls to map 1-to-1 with the outcome, and sometimes in those cases we also want the rendered controls to include a version of the thing being updated. So some example cases:
- Dragging an element that is in a flex container (no change of parent) - the controls should stick to the mouse, but we should show the result of the drag too. In this case having a placeholder rendered in the final location worked nicely. Having a snapshot of the element as part of those controls (and also applying the result in real time to the actual element) means you'll see the element twice, with overlapping occurring in a lot of cases. If we adjusted the opacity that might help, but then what if the thing being dragged already has partial opacity?
- Dragging an element to re-parent it into a container that changes the layout - very similar situation to the above, but if the re-parent were to trigger the element to disappear completely then having the semi-transparent snapshot in the controls would certainly make it clearer what is happening here
- Dragging to move (or even resize) an element that has some transforms applied to it - as much as it will be painful to create the controls for this (though we did find a library that would help before), you'd probably want the controls to reflect that transform (something that is being partially wrestled with in #91 ). In this case it feels like you wouldn't want to see the placeholder result or the snapshot in the controls?
IMO what we had in legacy partially solved the first two (I'd say we should also adjust the opacity of the dragged thing if the result doesn't match the controls 1-to-1), but not the second. Is this worth further discussion before someone undertakes that spike?
from utopia.
I have a branch with this partially solved (feature/drag-controls-stick-to-cursor
), but this requires further experimentation, so I'm going to move this to Triage so we can address this together with other experiments we want to run around canvas controls
from utopia.
Change of plan. I have opened a PR to cover the work from that branch. We will re-address the remaining issues as part of an upcoming process of experimenting with various canvas controls.
from utopia.
Related Issues (20)
- Border Control Still Unreliable HOT 1
- Cannot set padding in the product detail page of hydrogen-may
- Sample store: Elements disappearing during canvas interaction HOT 3
- Cartouches improvements
- Content is blinking in the hydrogen-may project HOT 3
- Improvements to Lists in the navigator
- Inspector: standardise the Section and Subsection and Folder
- Re-export the default navigator icons to all have the same size
- Inspector: Use relevant icons for the Row / Column component inspector HOT 1
- Color picker is not showing up
- the Layout component in hydrogen-may shows up with the wrong size, until it is focused, then its displayed size changes HOT 2
- Clicking the “Play with Utopia” button on utopia.app results in a 404
- When inserting a new page, we should scroll the canvas so we’re at the top left
- Create a mini-arrow to show by the mouse pointer when a distant element is selected
- Inspector inputs should only use single letters or icons for the internal label
- Wrong color swatch size
- When showing children in the inspector, strip unnecessary spaces
- Code editor is v slow to update after canvas selection changes, and canvas edits
- For the simple component picker, enable keyboard navigation
- Resizing any pane (left, right, code editor) to zero should hide it and reset the size to default HOT 2
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 utopia.