Fix adding sticker in media editor
This commit is contained in:
parent
b68e731950
commit
697df7e946
3 changed files with 28 additions and 10 deletions
|
@ -56,6 +56,7 @@ import { Theme } from '../util/theme';
|
|||
import { ThemeType } from '../types/Util';
|
||||
import { arrow } from '../util/keyboard';
|
||||
import { canvasToBytes } from '../util/canvasToBytes';
|
||||
import { loadImage } from '../util/loadImage';
|
||||
import { getConversationSelector } from '../state/selectors/conversations';
|
||||
import { hydrateRanges } from '../types/BodyRange';
|
||||
import { useConfirmDiscard } from '../hooks/useConfirmDiscard';
|
||||
|
@ -1213,17 +1214,19 @@ export function MediaEditor({
|
|||
i18n={i18n}
|
||||
installedPacks={installedPacks}
|
||||
knownPacks={[]}
|
||||
onPickSticker={(_packId, _stickerId, src: string) => {
|
||||
onPickSticker={async (_packId, _stickerId, src: string) => {
|
||||
if (!fabricCanvas) {
|
||||
return;
|
||||
}
|
||||
|
||||
const img = await loadImage(src);
|
||||
|
||||
const STICKER_SIZE_RELATIVE_TO_CANVAS = 4;
|
||||
const size =
|
||||
Math.min(imageState.width, imageState.height) /
|
||||
STICKER_SIZE_RELATIVE_TO_CANVAS;
|
||||
|
||||
const sticker = new MediaEditorFabricSticker(src);
|
||||
const sticker = new MediaEditorFabricSticker(img);
|
||||
sticker.scaleToHeight(size);
|
||||
sticker.setPositionByOrigin(
|
||||
new fabric.Point(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue