Articles in this section
Category / Section

How to Disable Snap to Lines in Syncfusion Angular Diagram for Precise Object Placement

2 mins read

The Syncfusion® Angular Diagram component features Snap to Lines functionality that helps in aligning diagram objects with gridlines during drag-and-drop actions. By default, this snapping behavior is available by injecting the SnappingService providers into your components. However, you can disable it to gain more precise control over the positioning of nodes and connectors, all while keeping the gridlines visible.

To enable smoother movement of diagram objects, you can adjust the snap settings in your diagram configuration by removing the SnapToLines constraint from the SnapConstraints. Here’s how you can do it:

import { DiagramModule, SnapConstraints, SnapSettingsModel, SnappingService } from '@syncfusion/ej2-angular-diagrams';

@Component({
  imports: [DiagramModule],
  providers: [SnappingService],
  selector: 'app-root',
  template: `<ejs-diagram width="100%" height="600px" [snapSettings]="snapSettings"> </ejs-diagram>`,
  standalone: true,
})

export class AppComponent {
  public snapSettings: SnapSettingsModel = {
    constraints: SnapConstraints.All & ~(
      SnapConstraints.SnapToHorizontalLines |
      SnapConstraints.SnapToVerticalLines |
      SnapConstraints.SnapToLines
    ),
  };
}

By adjusting these settings, users experience more flexible and precise interactions with nodes and connectors while maintaining gridlines.

Sample: Click Here

Conclusion
I hope you have learned how to disable Snap to Lines in the Diagram. You can refer to our Angular Diagram feature tour page to know about its other groundbreaking feature representations and documentation and how to quickly get started for configuration specifications. You can also explore our Angular Diagram example to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied