Skip to content

Commit

Permalink
Make maximum scale configurable (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juice10 authored Sep 26, 2022
1 parent 3924aaf commit 6f63cf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
21 changes: 11 additions & 10 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,17 @@ new rrwebPlayer({

##### Options

| key | default | description |
| -------------- | ------------ | ------------------------------------------------------ |
| events | [] | the events for replaying |
| width | 1024 | the width of the replayer |
| height | 576 | the height of the replayer |
| autoPlay | true | whether to autoplay |
| speedOption | [1, 2, 4, 8] | speed options in UI |
| showController | true | whether to show the controller UI |
| tags | {} | customize the custom events style with a key-value map |
| ... | - | all the rrweb Replayer options will be bypassed |
| key | default | description |
| -------------- | ------------ | -------------------------------------------------------------------- |
| events | [] | the events for replaying |
| width | 1024 | the width of the replayer |
| height | 576 | the height of the replayer |
| maxScale | 1 | the maximum scale of the replayer (1 = 100%), set to 0 for unlimited |
| autoPlay | true | whether to autoplay |
| speedOption | [1, 2, 4, 8] | speed options in UI |
| showController | true | whether to show the controller UI |
| tags | {} | customize the custom events style with a key-value map |
| ... | - | all the rrweb Replayer options will be bypassed |

#### Events

Expand Down
5 changes: 4 additions & 1 deletion packages/rrweb-player/src/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
export let width = 1024;
export let height = 576;
export let maxScale = 1;
export let events: eventWithTime[] = [];
export let skipInactive = true;
export let autoPlay = true;
Expand Down Expand Up @@ -55,8 +56,10 @@
) => {
const widthScale = width / frameDimension.width;
const heightScale = height / frameDimension.height;
const scale = [widthScale, heightScale];
if (maxScale) scale.push(maxScale);
el.style.transform =
`scale(${Math.min(widthScale, heightScale, 1)})` +
`scale(${Math.min(...scale)})` +
'translate(-50%, -50%)';
};
Expand Down

0 comments on commit 6f63cf1

Please sign in to comment.