Accept function as child or pass raw position

Abierto
#414 0 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, react
Área
frontend

Línea de trabajo

No files, tests, or entry points are named. Begin by locating how react-draggable renders its child and passes position, style, and mouse/touch handlers; clarify whether the intended API is a function child, raw position data, or both, then add coverage for the chosen behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

It would be convenient if react-draggable accepted a function as a child. Instead of requiring the child be a <div /> or <svg /> and passing the appropriate props, a function would with called with the position. For example:

<Draggable>
{
  /* additional arguments could be onTouchStart, onMouseMove, etc. */
  (position, ...args) => {
    <div
      style={{
        transform=`translateX(${position.x}px) translateY(${position.y}px)`
      }}
      {...args}
    >
      Drag me!
    </div>
  }
}
</Draggable>

This would allow greater flexibility in how the child component can be structured.

Otherwise it is easy enough to pass along onMouse/onTouch events and the style prop - but if the child component needs to consume the position for reasons other than style, it must regex the values out of the style.transform string. A compromise could be always pass the raw position object as well.

My apologies if this has been brought up in the past; I couldn't find any other mention.

Lenguaje dominante
JavaScript
Estrellas
9.3k
Forks
1k
Merge medio
3 d 8 h
PR fusionados (30 d)
4

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de react-grid-layout/react-draggable

Todos los issues de react-grid-layout/react-draggable

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.