-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waspello: Tilt cards when dragging #2413
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
I've added some comments to maybe improve it a bit :)
@@ -235,6 +235,10 @@ button.open-add-list { | |||
border-radius: 3px; | |||
} | |||
|
|||
.list--dragging { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add transitions to make this look smoother:
.list {
...
transition: transform 200ms ease-in-out;
}
.list--dragging {
transform: rotate(2deg);
}
.list--drop-animating {
transform: rotate(0deg);
}
I'd do the same for the .list-card
component.
Also, potential improvement in readability is to maybe declare CSS vars for the angle e.g. --list-rotate-angle: 2deg
and then use it var(--list-rotate-angle)
.
I've explained the --drop-animating class here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added suggested changes. I didn't extract the 2deg
to a separate variable as it is used only once (when dragging the whole list 4 degs are used), moving its definition to a different place could make the code harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. I still need to test the whole list dragging, but it won't work until #2414 is resolved and merged.
@@ -248,7 +248,7 @@ const List = ({ list, index, cards }) => { | |||
{...provided.draggableProps} | |||
{...provided.dragHandleProps} | |||
> | |||
<div className='list'> | |||
<div className={`list ${snapshot.isDragging && 'list--dragging'}`}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd implement a helper function for this e.g.
function getListClassName(snapshot) {
const classes = ['list']
if (snapshot.isDragging) {
classes.push('list--dragging')
}
if (snapshot.isDropAnimating) {
classes.push('list--drop-animating')
}
return classes.join(' ')
}
This way:
- There is no space after
list
iflist--dragging
is not present. - It's easier to compose multiple classes
You'll notice I used isDropAnimating
as well, this enables us to have a smooth start:
(no rotation) -> (rotation)
and a smooth end:
(rotation) -> (no rotation)
without.mov
with.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that classnames
npm package is included and used in other places. Should have used that 🤦
I'll update the code.
Description
This PR implements tilting while dragging for both full lists and individual cards. Fixes #338
Note:
React.StrictMode
. This is unrelated to this PR and is fixed in Waspello: Fix drag-and-drop and replace deprecated react-beautiful-dnd library #2414.Waspello.Tilt.Drag.mp4
Select what type of change this PR introduces:
Update Waspc ChangeLog and version if needed
If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:
Update example apps if needed
If you did code changes and added a new feature or modified an existing feature, make sure you satisfy the following:
waspc/examples/todoApp
as needed (updated modified feature or added new feature) and manually checked it works correctly.waspc/headless-test/examples/todoApp
and its e2e tests as needed (updated modified feature and its tests or added new feature and new tests for it).