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

[Feature]: Unexpected space when adding a Dashed Line in Fabric.js 6.3.0 #10150

Open
4 tasks done
yashChapaniOB opened this issue Sep 13, 2024 · 0 comments
Open
4 tasks done

Comments

@yashChapaniOB
Copy link

yashChapaniOB commented Sep 13, 2024

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have searched and referenced existing issues, feature requests and discussions
  • I am filing a FEATURE request.

Description

When adding a Dashed Line object to the canvas using Fabric.js 6.3.0, an unexpected space appears around the line. This behavior was not present in Fabric.js 5.3.0, where lines rendered correctly without extra space.

Current Behavior

When adding a solid line, the same spacing issue shows, but this issue resolves with the stokeLineCap property set. Sqare, this is resolved in the solid line, but when this same property is applied to the dashed line, then the dashed line does not work; it shows a solid line, so my issue is which property to add to remove padding from the dashed line shown in the image. I want to remove extra spacing in the dashed line like the solid line.

image

Perfect work on the Solid Line

image

Current State

var option = {};
      option['objectCaching'] = true;
      option['isLocked'] = false;
      option['element_type'] = "basicShape";
      
 const shadow = new Shadow({
      affectStroke: false,
      blur: 0,
      color: '#000000ff',
      offsetX: 0,
      offsetY: 0,
});

var line = new Line([10, 10, 200, 10], {
                      borderColor: '#0069FF',
                      borderScaleFactor: 1.5,
                      id: this.randomId(),
                      centeredScaling: false,
                      centeredRotation: true,
                      shadow: shadow,
                      cornerSize: 15,
                      lockScalingFlip: true,
                      cornerColor: '#0069FF',
                      cornerStyle: 'circle',
                      isLocked: false,
                      visible: true,
                      stroke: "#000000",
                      strokeDashArray: [10, 5],
                      clipPath: undefined,
                      excludeFromExport: false,
                      strokeWidth: 10,
                      strokeLineCap: 'butt',
                      transparentCorners: false,
                      _controlsVisibility: {
                          tl: false,
                          tr: false,
                          br: false,
                          bl: false,
                          ml: true,
                          mt: false,
                          mr: true,
                          mb: false,
                          mtr: true
                      },
                      type: 'line',
                      element_type: 'basicShape',
                      ...option
                  })

                  // Set the line position and scale it
                  line.set('top', 100)
                  line.set('left', 100)

                     canvas.add(line)
                 canvas.renderAll()
                  


### Additional Context

_No response_
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