Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix viewport overflow issues #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import * as React from 'react';
export interface FrameProps {
offset: number;
width: number;
height: number;
}

export const Frame: React.FunctionComponent<FrameProps> = (props) => {
return (
<svg x={props.offset * props.width}>
<svg x={props.offset * props.width} width={props.width} viewBox={`0 0 ${props.width} ${props.height}`}>
<use xlinkHref="#a"/>
{props.children}
</svg>
Expand Down
4 changes: 2 additions & 2 deletions src/Word.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Word: React.FunctionComponent<WordProps> = props => {
height={props.theme.fontSize * props.theme.lineHeight}
inverse={props.inverse}
width={props.children.length > 0 ? props.children.length : 0}
x={props.x * props.theme.fontSize * 0.6}
x={props.x}
y={props.y - props.theme.fontSize}
/>
)}
Expand All @@ -39,7 +39,7 @@ export const Word: React.FunctionComponent<WordProps> = props => {
inverse={props.inverse}
theme={props.theme}
underline={props.underline}
x={props.x * props.theme.fontSize * 0.6}
x={props.x}
y={props.y}
>
{props.children}
Expand Down
2 changes: 1 addition & 1 deletion src/load-cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function loadCast(input: string, options: LoadOptions = {}): Cast {
const { width, height, idle, fps } = options;
return load(input, {
width,
height: height ? height + 1 : undefined,
height,
idle: idle ? idle / 1000 : undefined,
fps
});
Expand Down
1 change: 0 additions & 1 deletion src/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export function render(
paddingY={paddingY}
decorations={decorations}
cursor={cursor}
height={options.height}
/>
);
}
10 changes: 4 additions & 6 deletions src/svg-term.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface SvgTermProps {
theme: Theme;
paddingX: number;
paddingY: number;
height?: number;
decorations: boolean;
from?: number;
to?: number;
Expand All @@ -35,7 +34,6 @@ export const SvgTerm: React.FunctionComponent<SvgTermProps> = props => {
const data = toViewModel({
cast: props.cast,
cursor: props.cursor,
height: props.height,
theme: props.theme,
from: from(bound),
to: to(bound)
Expand All @@ -44,14 +42,14 @@ export const SvgTerm: React.FunctionComponent<SvgTermProps> = props => {
return (
<Window
decorations={props.decorations}
width={data.width}
width={data.displayWidth}
height={data.displayHeight}
background={props.theme.background}
paddingX={props.paddingX}
paddingY={props.paddingY}
>
<Document
width={data.width}
width={data.displayWidth}
height={data.displayHeight}
x={props.decorations ? 15 + props.paddingX : props.paddingX}
y={props.decorations ? 50 + props.paddingY : props.paddingY}
Expand All @@ -69,7 +67,7 @@ export const SvgTerm: React.FunctionComponent<SvgTermProps> = props => {
theme={props.theme}
/>
<Background
width={data.width}
width={data.displayWidth}
height={data.displayHeight}
fill={props.theme.background}
/>
Expand All @@ -81,7 +79,7 @@ export const SvgTerm: React.FunctionComponent<SvgTermProps> = props => {
>
{data.frames.map((frame: any, index: number) => {
return (
<Frame key={frame.stamp} offset={index} width={data.width}>
<Frame key={frame.stamp} offset={index} width={data.displayWidth} height={data.displayHeight}>
{frame.cursor.visible && (
<use
xlinkHref="#b"
Expand Down
4 changes: 1 addition & 3 deletions src/to-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface ViewModelOptions {
from: number;
to: number;
theme: Theme;
height?: number;
}

export interface ViewModel {
Expand Down Expand Up @@ -51,7 +50,6 @@ export function toViewModel(options: ViewModelOptions): ViewModel {
.map(([stamp]) => stamp - from);
const fontSize = theme.fontSize;
const lineHeight = theme.lineHeight;
const height = typeof options.height === 'number' ? options.height : cast.height;

const frames = loadedFrames
.filter(([stamp]) => stamp >= from && stamp <= to)
Expand Down Expand Up @@ -108,7 +106,7 @@ export function toViewModel(options: ViewModelOptions): ViewModel {
width: cast.width,
displayWidth: cast.width,
height: cast.height,
displayHeight: height * fontSize * lineHeight,
displayHeight: cast.height * fontSize * lineHeight,
duration: to - from,
registry,
stamps,
Expand Down