Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How do i avoid UI delay in drag and drop app using RxJS

https://codesandbox.io/s/pedantic-roentgen-s514z?file=/src/index.js

import "./styles.css";
import { fromEvent } from "rxjs";
import { switchMap, takeUntil } from "rxjs/operators";

let el = document.getElementById("box0");

const mousedown$ = fromEvent(el, "mousedown");
const mousemove$ = fromEvent(document, "mousemove");
const mouseup$ = fromEvent(document, "mouseup");

const drag$ = mousedown$.pipe(
  switchMap(() => mousemove$.pipe(takeUntil(mouseup$)))
);

drag$.subscribe((e) => {
  console.log(e);
  el.style.left = `${e.clientX}px`;
  el.style.top = `${e.clientY}px`;
});

Noticing some delay visually in the drag and drop effect in the UI. Is there any feedback on the way i'm using reactive extensions that might be causing this?

drag delay

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is nothing wrong with the way you use Rx on this example. If you want to boost the performance just remove console.log and maybe use CSS translate property for square movement.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda