Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #604 from SuperViz/feat/change-mouse-props
Browse files Browse the repository at this point in the history
feat: add callbacks object in mouse props
  • Loading branch information
carlossantos74 authored Mar 15, 2024
2 parents 4555022 + a3771f2 commit 525df2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/components/presence-mouse/canvas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class PointersCanvas extends BaseComponent {
private divWrapper: HTMLElement;
private presences: Map<string, ParticipantMouse>;
private animateFrame: number;
private goToMouseCallback: PresenceMouseProps['onGoToPresence'];
private goToMouseCallback: PresenceMouseProps['callbacks']['onGoToPresence'];
private following: string;
private isPrivate: boolean;
private transformation: Transform = { translate: { x: 0, y: 0 }, scale: 1 };
Expand All @@ -32,7 +32,7 @@ export class PointersCanvas extends BaseComponent {
this.divWrapper = this.renderDivWrapper();
this.animateFrame = requestAnimationFrame(this.animate);

this.goToMouseCallback = options?.onGoToPresence;
this.goToMouseCallback = options?.callbacks?.onGoToPresence;
}

private get textColorValues(): number[] {
Expand Down Expand Up @@ -361,11 +361,11 @@ export class PointersCanvas extends BaseComponent {
};

/**
* @function transformPointer
* @function transform
* @description stores that information about which transformations should the pointers go through
* @param {Transform} transformation Which transformations to apply
*/
public transformPointer(transformation: Transform) {
public transform(transformation: Transform) {
this.transformation = transformation;
}
}
2 changes: 1 addition & 1 deletion src/components/presence-mouse/html/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ describe('MousePointers on HTML', () => {
'updatePresenceMouse',
);

presenceMouseComponent['transformPointer']({ translate: { x: 10, y: 10 }, scale: 1 });
presenceMouseComponent['transform']({ translate: { x: 10, y: 10 }, scale: 1 });

const event = {
currentTarget: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/presence-mouse/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class PointersHTML extends BaseComponent {
private transformation: Transform = { translate: { x: 0, y: 0 }, scale: 1 };

// callbacks
private goToPresenceCallback: PresenceMouseProps['onGoToPresence'];
private goToPresenceCallback: PresenceMouseProps['callbacks']['onGoToPresence'];

/**
* @function constructor
Expand All @@ -56,7 +56,7 @@ export class PointersHTML extends BaseComponent {

this.name = ComponentNames.PRESENCE;
this.containerTagname = this.container.tagName.toUpperCase();
this.goToPresenceCallback = options?.onGoToPresence;
this.goToPresenceCallback = options?.callbacks?.onGoToPresence;
}

// ---------- SETUP ----------
Expand Down Expand Up @@ -475,11 +475,11 @@ export class PointersHTML extends BaseComponent {

// ---------- REGULAR METHODS ----------
/**
* @function transformPointer
* @function transform
* @description stores that information about which transformations should the pointers go through
* @param {Transform} transformation Which transformations to apply
*/
public transformPointer(transformation: Transform) {
public transform(transformation: Transform) {
this.transformation = transformation;
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/presence-mouse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export interface Transform {
}

export interface PresenceMouseProps {
onGoToPresence?: (position: { x: number; y: number }) => void;
callbacks: {
onGoToPresence?: (position: { x: number; y: number }) => void;
};
}

export type Element = HTMLElement & SVGElement;
Expand Down

0 comments on commit 525df2d

Please sign in to comment.