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

"Shaky" text when typing each character (short documents) #47

Open
lebigot opened this issue May 20, 2023 · 5 comments
Open

"Shaky" text when typing each character (short documents) #47

lebigot opened this issue May 20, 2023 · 5 comments

Comments

@lebigot
Copy link

lebigot commented May 20, 2023

When a note is not very long (like when it starts empty) and is entered in a "tall" window, each typed character makes the whole not text "shake". This is not very convenient.

In case this matters:

  • Zen mode is activated (focus on the current line).
  • The focused line is quite near the top of the pane.

Thanks!

@lebigot
Copy link
Author

lebigot commented May 21, 2023

PS: It is as if Typewriter Scroll was hesitating between two positions on the screen: a first position where the text is shown for a very short time, and then the final position. Each time I press a key, the first position is used, and then the final position.

@TonyAtlas
Copy link

I have the same effect, but it appears on any note. When I activated the plugin, at first everything worked almost normally. These jumps also happened, but much less often. But then for some reason they also began to happen from every click. Although I did not change anything.

Reboot did not help.

OS: Windows 10
Obsidian 1.3.5.

@mattdaviscodes
Copy link

Same issue.

@fcFn
Copy link

fcFn commented Nov 7, 2023

This plugin works perfectly: https://github.com/davisriedel/obsidian-typewriter-mode

@Caffa
Copy link

Caffa commented Feb 25, 2024

@fcFn I found the other plugin to be really buggy. Utterly unusable.

This seems to be linked to a previously closed issue #6 but I checked my current plugin is up to date and the code changes for the onRefresh function are corrected according to this fix (Line 136).

I have also found the same problem of 'each character causes the window to go up and down' but my zen mode is deactivated and the document is rather long. This doesn't happen for all lines, but a shaky line remains shaky for the whole line. I think this may be due to how we divide the offsetHeight - how is it rounded?

function onRefresh(cm) {
    const halfWindowHeight = Math.ceil(cm.getWrapperElement().offsetHeight / 2);
    const linesEl = cm.getScrollerElement().querySelector('.CodeMirror-lines');
    linesEl.style.paddingTop = `${halfWindowHeight}px`;
    linesEl.style.paddingBottom = `${halfWindowHeight}px`; // Thanks @walulula!
    if (cm.getSelection().length === 0) {
        cm.execCommand("scrollSelectionToCenter");
    }
}

so I did this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants