Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlong committed Oct 12, 2024
1 parent 893dc58 commit f86cc4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import Split from 'split-grid';
import store, { Store } from '../store';
import Editor from './editor';
import Modals from './modals';
import Toolbar from './toolbar';
import Preview from './preview';
import Toolbar from './toolbar';

const main = async () => {
// load preferences
Expand Down
11 changes: 4 additions & 7 deletions src/components/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { auto } from 'manate/react';
import React, { useEffect } from 'react';
import $ from 'jquery';

const Preview = auto(() => {
useEffect(() => {
// scroll past end
$('article#preview').css(
'padding-bottom',
$('#left-panel').height() -
parseInt($('article#preview').css('line-height'), 10) +
'px',
);
const preview = document.querySelector('#preview') as HTMLElement;
const leftPanel = document.querySelector('#left-panel') as HTMLElement;
const lineHeight = parseInt(getComputedStyle(preview).lineHeight, 10);
preview.style.paddingBottom = `${leftPanel.offsetHeight - lineHeight}px`;

// todo: precisely set the timing
setTimeout(() => {
Expand Down

0 comments on commit f86cc4b

Please sign in to comment.