Skip to content

Draft: Keep scroll position steady on input change#13

Draft
rad4day wants to merge 2 commits into
masterfrom
feature/scrollposition
Draft

Draft: Keep scroll position steady on input change#13
rad4day wants to merge 2 commits into
masterfrom
feature/scrollposition

Conversation

@rad4day

@rad4day rad4day commented Mar 24, 2023

Copy link
Copy Markdown
Owner

This will add a config option as well as a button in the GUI to disable the automatic scrolling to the top on change.

Currently work in progress. This code really needs a refactoring.

This feature was requested by @Hosseingsd in the discussions for #12.

@rad4day

rad4day commented Mar 24, 2023

Copy link
Copy Markdown
Owner Author

If you want to test this build and provide feedback, there is a build available here
Download the *-external.ankiaddon file and install the addon from file in the addon manager.

@Hosseingsd

Hosseingsd commented Mar 24, 2023

Copy link
Copy Markdown

If you want to test this build and provide feedback, there is a build available here Download the .ankiaddon file and install the addon from file in the addon manager.

error

I removed the previously installed Editor Live Preview addon and tried again with editor-preview.ankiaddon file, but I encountered the same error.

@Hosseingsd

Copy link
Copy Markdown

There is 3 state (and i don't know if all are feasible):

  1. the current state which jumps to the beginning (as I showed you in the video) and I think this state is annoying.
  2. the second state that keeps the scroll position steady until we intentionally scroll
  3. the third state checks where the blinking cursor is, and puts the corresponding line of the preview pane at the exact same level as the line where the blinking cursor is located.

I guess the second stated is more feasible but it will be great if there is a toggle between the second and third state in the config options.

the third state is the actual LIVE preview: supposing you put the preview pane side by side with the edit/add window(left or right), whenever you click on any line in the text and start typing, if the corresponding line in the preview pane adjusts its horizontal level to that line you are typing in, you won't have any frustration noticing changes.

@rad4day

rad4day commented Mar 24, 2023

Copy link
Copy Markdown
Owner Author

removed the previously installed Editor Live Preview addon and tried again with editor-preview.ankiaddon file, but I encountered the same error.

Should work now. Use the -external file.
I was unaware that addons outside ankiweb need an extra manifest file.

Currently, there are still some artifacts from the reloading where the preview pane blinks on update.

Please also be aware that the debug builds will not update automatically when a new release on ankiweb is published.


the third state checks where the blinking cursor is, and puts the corresponding line of the preview pane at the exact same level as the line where the blinking cursor is located.

Currently, I don't know how I would implement this and don't intend on doing so.
Most cards shouldn't be long enough for options two and three to make much of a difference.

@Hosseingsd

Hosseingsd commented Mar 25, 2023

Copy link
Copy Markdown

Should work now. Use the -external file. I was unaware that addons outside ankiweb need an extra manifest file.

it jumps to the top again!

also disabled all other addons to make sure that this jump is not caused by them
also restarted Anki after each time toggled the scroll locking

No matter whether using the lock icon or config options, it does not work and it jumps again.

@Hosseingsd

Hosseingsd commented Mar 28, 2023

Copy link
Copy Markdown

today I noticed that the cursor does not jump UP! It actually jumps to the horizontal line (between front field and back field)
This means any change in the back field causes it to jump up and any change in the front field causes it to jump down. any change in any field causes it to jump to that horizontal line.
bug

If I delete just id=answer attribute form inside the <hr id=answer> element, the problem will solve!

hr

I don't even know what this id=answer is for! Do you have any idea?

ps: The problem is caused by the exactly id=answer attribute and not just any attribute; I tried the attributes like color, size, width, and align, and none of them causes any problem of refreshing or jumping.

@rad4day

rad4day commented Mar 28, 2023

Copy link
Copy Markdown
Owner Author

The funny thing is, for me it always did that and on the current build it explicitly doesn't do this but holds the current scroll position. (Also it doesn't scroll downward when I continue writing more text)

I suspect that there is some javascript in the anki client that scrolls to the id=answer field and clashes with the javascript I am injecting to keep the scroll position.

In another run I had fighting between those 2 postions ...

That needs some further investigation in the anki code.

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

Successfully merging this pull request may close these issues.

2 participants