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

327
Vistas
FabricJS: ¿cómo evitar dejar un objeto del objeto dado?

Pude evitar dejar objetos del lienzo, pero no pude evitar dejar objetos secundarios del objeto dado.

Traté de hacerlo de esta manera (vea el ejemplo de código a continuación) pero esto bloquea el objeto dejándolo en el mismo tamaño (ancho, alto) del objeto bloqueado pero posicionado absolutamente (arriba, izquierda). Necesito evitar dejar en las mismas coordenadas donde se coloca el objeto principal (ver la imagen adjunta).

Cualquier idea es bienvenida.

ingrese la descripción de la imagen aquí

 preventLeavingInsideBox(e: IEvent) { let activeObject = e.target; if ((activeObject.get('left') - (activeObject.get('width') * activeObject.get('scaleX') / 2) < 0)) activeObject.set('left', activeObject.get('width') * activeObject.get('scaleX') / 2); if ((activeObject.get('top') - (activeObject.get('height') * activeObject.get('scaleY') / 2) < 0)) activeObject.set('top', activeObject.get('height') * activeObject.get('scaleY') / 2); if (activeObject.get('left') + (activeObject.get('width') * activeObject.get('scaleX') / 2) > this.rect.width) { var positionX = this.rect.width - (activeObject.get('width') * activeObject.get('scaleX')) / 2; activeObject.set('left', positionX > this.rect.width / 2 ? positionX : this.rect.width / 2); } if (activeObject.get('top') + (activeObject.get('height') * activeObject.get('scaleY') / 2) > this.rect.height) { var positionY = this.rect.height - (activeObject.get('height') * activeObject.get('scaleY') / 2); activeObject.set('top', positionY > this.rect.height / 2 ? positionY : this.rect.height / 2); } //below just prevention for object from getting width or height greater than canvas width and height if (activeObject.get('width') * activeObject.get('scaleX') > this.rect.width) { activeObject.set('scaleX', this.rect.width / activeObject.get('width')); } if (activeObject.get('height') * activeObject.get('scaleY') > this.rect.height) { activeObject.set('scaleY', this.rect.height / activeObject.get('height')); } }
about 4 years ago · Juan Pablo Isaza
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