message positioning for svgs
This commit is contained in:
parent
2d0292fea5
commit
a9fdf8f1b2
6 changed files with 172 additions and 104 deletions
33
src/components/messageView/message/calcPosition.ts
Normal file
33
src/components/messageView/message/calcPosition.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import {computed} from "vue";
|
||||
|
||||
// Size of "side-gutters" of message window.
|
||||
const margin = 20;
|
||||
const messagePadding = 15;
|
||||
const firstChildMargin = 45;
|
||||
|
||||
|
||||
function calcXPosition(messageWidth: number, windowWidth: number, modifier: string) {
|
||||
let offset = margin;
|
||||
|
||||
if (modifier == "sf") {
|
||||
offset = windowWidth - messageWidth - margin;
|
||||
}
|
||||
|
||||
return offset
|
||||
}
|
||||
|
||||
function calcMessagePosition(modifier: string, messageWidth: number,
|
||||
windowWidth: number, anchorPosition: any) {
|
||||
|
||||
const X = calcXPosition(messageWidth, windowWidth, modifier);
|
||||
|
||||
// Depends on if first child.
|
||||
let Y = firstChildMargin;
|
||||
if (anchorPosition != "none") {
|
||||
Y = anchorPosition + messagePadding;
|
||||
}
|
||||
|
||||
return `translate(${X} ${Y})`;
|
||||
}
|
||||
|
||||
export default calcMessagePosition;
|
||||
Loading…
Reference in a new issue