Skip to content
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

When I was using dnd-kit and react-slick, there were some issues with transform #1574

Open
hth520 opened this issue Dec 27, 2024 · 0 comments

Comments

@hth520
Copy link

hth520 commented Dec 27, 2024

Parent component:

<DndContext onDragStart={onDragStart} onDragEnd={onhandleDragEnd} onDragMove={onDragMove}>
            <SortableContext
              items={doctorList.map((i) => i.id)}
              strategy={horizontalListSortingStrategy}
            >
              <Slider beforeChange={handleBeforeChange} ref={sliderRef} {...settings}>
                {doctorList?.map((item, index) => (
                  <PractitionerItem
                    key={item.id}
                    data={item}
                    index={index}
                    afterPunch={afterPunch}
                  />
                ))}
              </Slider>
            </SortableContext>
          </DndContext>
      Chilren compoent:
              <div
      ref={setNodeRef}
      {...attributes}
      style={{
        ...(transform
          ? {
              transform: `translate3d(${transform.x}px, 0, 0)`,
            }
          : {}),
        transition,
        position: 'relative',
        zIndex: isDragging ? '999' : 'auto',
      }}
      className={styles.practitionerItem}
    >
      <Badge size="default" count={index + 1} offset={[-10, 10]} className={styles.badge}>
        <CustomAvatar
          {...listeners}
          style={{ cursor: 'grab' }}
          className={cx(styles.avatar, data?.isPunchIn ? styles.border : null)}
          name={data?.name}
          gender={data?.gender}
        />
      </Badge>
      </div>

动画

!!: I investigated and found that the transform calculation of the react-slick component was triggered when dragging the element, leading to conflicts. So I controlled the react-slick component to dynamically set the transform attribute by starting and ending functions, which seemed to be unable to solve this flickering problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant