question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ellipse transformer event....??

See original GitHub issue

If you change the size, it will be greatly enlarged or reduced. Do you have anything to fix?

` import React from ‘react’; import { Ellipse, Circle, Transformer } from ‘react-konva’; import clamp from “clamp”;

      const CircleComponent = ({  shapeProps, tool, isSelected, onSelect, onChange, toolboxUse }) => {
        const shapeRef = React.useRef();
        const trRef = React.useRef();
      
        React.useEffect(() => {
          if (tool == "cursor" && isSelected && toolboxUse) {
            trRef.current.nodes([shapeRef.current]);
            trRef.current.getLayer().batchDraw();
          }
        }, [isSelected]);
      
        return (
          <React.Fragment>
            <Ellipse
              onClick={onSelect}
              onTap={onSelect}
              ref={shapeRef}
              strokeScaleEnabled={false}
              {...shapeProps}
              draggable={tool == "cursor" && toolboxUse}
              onDragEnd={(e) => {
                onChange({
                  ...shapeProps,
                  x: e.target.x(),
                  y: e.target.y(),
                });
              }}
              onTransformEnd={(e) => {
                const node = shapeRef.current;
      
                let radiusX = Math.floor(node.width() * node.scaleX() / 2);
                let radiusY = Math.floor(node.height() * node.scaleY() / 2);
      
                let param = {
                  fill: shapeProps.fill,
                  id: shapeProps.id,
                  key: shapeProps.key,
                  regId: shapeProps.regId,
                  scaleX: 1,
                  scaleY: 1,
                  stroke: shapeProps.stroke,
                  strokeWidth: shapeProps.strokeWidth,
                  tool: shapeProps.tool,
                  x: node.x(),
                  y: node.y(),
                  rotation : node.attrs.rotation,
                  radiusX : radiusX,
                  radiusY : radiusY,
                  width : node.width(),
                  height : node.height()
                };
      
                console.log(param);
                onChange(param);
              }}
            />
            {tool == "cursor" && isSelected && toolboxUse && (
              <Transformer
                ref={trRef}
                centeredScaling={true}
                boundBoxFunc={(oldBox, newBox) => {
                  console.log(oldBox);
                  console.log(newBox);
                  // if (newBox.width > 200) {
                  //   return oldBox;
                  // }
                  return newBox;
                }}
              />
            )}
          </React.Fragment>
        );
      };
      
      export default CircleComponent;

`

https://user-images.githubusercontent.com/36141397/108816214-1dab3c80-75f9-11eb-9715-af97bd01a8e2.mp4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lavrtoncommented, Feb 25, 2021

I see the issue.

width : node.width(),
height : node.height()

Do not specify width/height for an ellipse. It is a duplication from radiusX and radiusY. And looks like it produces conflict in attributes settings.

Fixed version: https://codesandbox.io/s/sleepy-cloud-7h8lh?file=/src/component/CircleComponent.js

1reaction
lavrtoncommented, Feb 24, 2021

Can you please make a small codesandbox demo?

Read more comments on GitHub >

github_iconTop Results From Across the Web

2DEllipseReplacer | FME - Safe Software
Replaces the geometry of the feature with a two-dimensional ellipse whose shape is set by the parameters, values or the values of existing...
Read more >
Class: Transformer - Konva
Transformer constructor. Transformer is a special type of group that allow you transform Konva primitives and shapes. Transforming tool is not changing ...
Read more >
ECLIPSE - Transformer Monitor | Advanced Power Technologies
The ECLIPSE transformer monitor optimizes transformer efficiency with patented technology that possesses a comprehensive set of features. Learn more today!
Read more >
Ellipse® APM Edge Minimize unscheduled downtime and ... - ABB
Over the life of a transformer, the asset will be subject to various conditional and environmental events from the power network.
Read more >
Ellipse APM 5.0 User Guide 5.1 - UserManual.wiki
Ellipse APM Supported Assets Ellipse APM contains out of the box models for the following asset types: n Oil filled Transformers n HV...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found