You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the difference from tutorial to my project is that I'm using ngx-fabric-wrapper and he's not.
He calls fabric with: public canvas: fabric.Canvas;
both in services and canvas-component.
And I call the canvas with the ngx-canvas-wrapper: @ViewChild(FabricDirective) directiveRef?: FabricDirective;
I can't call it inside service, so I can't use event handlers and other services...
I'm trying to move mouse event handlers to a service and I can't make it work.
I'm trying to replicate "draw rectangle with mouse" following this tutorial/app:
https://codingsans.com/blog/fabricjs-tutorial#Rectangle_Ellipse
the example project from his website is here:
https://gitlab.com/Barna001/fabric.js-free-hand-drawing
the difference from tutorial to my project is that I'm using ngx-fabric-wrapper and he's not.
He calls fabric with:
public canvas: fabric.Canvas;
both in services and canvas-component.
And I call the canvas with the ngx-canvas-wrapper:
@ViewChild(FabricDirective) directiveRef?: FabricDirective;
I can't call it inside service, so I can't use event handlers and other services...
my template is:
`<div class="canvas-wrapper" #canvasWrapper>
`<canvas class="fabric" [fabric]="config">
and .ts ( You'll see the mouseDown and MouseMove comented because is what I'm trying to pass to the service!)
`import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, Input, AfterContentInit, NgZone } from '@angular/core';
import { fabric } from 'fabric';
import { FabricComponent, FabricDirective, FabricConfigInterface } from 'ngx-fabric-wrapper';
import { EventHandlerService } from 'src/app/workflows/services/event-handler.service';
import { faSearchLocation, faArrowsAlt, faInfo, faSquare } from '@fortawesome/free-solid-svg-icons';
import { Rect } from 'fabric/fabric-impl';
import {
Pointer,
CustomFabricRect,
DrawingThickness,
DrawingColours,
CustomFabricObject,
FabricObjectType
} from 'src/app/workflows/models/resources/workflows/canvas-models';
import { FabricShapeService } from 'src/app/workflows/services/fabric-shape.service';
import { Subscription } from 'rxjs';
@component({
selector: 'canvas-brick-config',
templateUrl: './canvas-brick-config.component.html',
styleUrls: ['./canvas-brick-config.component.scss']
})
export class CanvasBrickConfigComponent implements OnInit, AfterContentInit, AfterViewInit {
and the service:
`import { fabric } from 'fabric';
import { Injectable } from '@angular/core';
import { FabricDirective } from 'ngx-fabric-wrapper';
import { Pointer, CustomFabricRect, DrawingThickness, DrawingColours } from '../models/resources/workflows/canvas-models';
import { FabricShapeService } from './fabric-shape.service';
@Injectable()
export class EventHandlerService {
}`
How can I make the mouse event hanlders work inside the service? In other words: how can I handle the existing canvas on the "service"?
The text was updated successfully, but these errors were encountered: