Skip to content

Commit

Permalink
move func out of the class
Browse files Browse the repository at this point in the history
  • Loading branch information
michellewzhang committed May 30, 2024
1 parent a2aac2a commit 830d8f3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ function indicatesTouchDevice(
);
}

function getPointerId(
d: incrementalData | mousemoveData | mouseInteractionData,
): number {
const pointerId =
'pointerId' in d && typeof d.pointerId === 'number' ? d.pointerId : -1;
return pointerId;
}

export class Replayer {
public wrapper: HTMLDivElement;
public iframe: HTMLIFrameElement;
Expand Down Expand Up @@ -428,7 +436,7 @@ export class Replayer {
}
this.service.state.context.events.forEach((e: eventWithTime) => {
if (indicatesTouchDevice(e)) {
const pointerId = this.getPointerId(e.data);
const pointerId = getPointerId(e.data);
if (!this.pointers[pointerId]) {
this.createPointer(pointerId);
}
Expand All @@ -439,14 +447,6 @@ export class Replayer {
});
}

private getPointerId(
d: incrementalData | mousemoveData | mouseInteractionData,
): number {
const pointerId =
'pointerId' in d && typeof d.pointerId === 'number' ? d.pointerId : -1;
return pointerId;
}

private createPointer(pointerId: number) {
const newMouse = document.createElement('div');
newMouse.classList.add('replayer-mouse');
Expand Down Expand Up @@ -594,7 +594,7 @@ export class Replayer {
? this.config.unpackFn(rawEvent as string)
: (rawEvent as eventWithTime);
if (indicatesTouchDevice(event)) {
const pointerId = this.getPointerId(event.data);
const pointerId = getPointerId(event.data);
if (!this.pointers[pointerId]) {
this.createPointer(pointerId);
}
Expand Down Expand Up @@ -1140,7 +1140,7 @@ export class Replayer {
case IncrementalSource.Drag:
case IncrementalSource.TouchMove:
case IncrementalSource.MouseMove: {
const pointerId = this.getPointerId(d);
const pointerId = getPointerId(d);
if (!this.pointers[pointerId]) {
this.createPointer(pointerId);
}
Expand Down Expand Up @@ -1183,7 +1183,7 @@ export class Replayer {
break;
}
case IncrementalSource.MouseInteraction: {
const pointerId = this.getPointerId(d);
const pointerId = getPointerId(d);
if (!this.pointers[pointerId]) {
this.createPointer(pointerId);
}
Expand Down

0 comments on commit 830d8f3

Please sign in to comment.