obsidian-remember-cursor-position
obsidian-remember-cursor-position copied to clipboard
Is it possible to support remember cursor location on the mobile
It would be great to be able to support this on Obsidian Mobile. This is especially useful for long notes like inbox notes.
I find the reason Obsidian Mobile doesn't work. Every time I change the file (through file explorer), the return value of getScroll() is not 0.
I verified that if I comment the if (scroll === 0) line, remember-cursor-position will work at mobile. Here is my commit
I'd like to find a more elegant solution. @dy-sh , what is the meaning of getScroll()? I don't find any useful documents. In the code comment, you mentioned "if note opened by link like link, do not scroll it", but then why at mobile, the return value is always non-zero (even when I switch by file explorer.
Or @dy-sh , do you mind I add a fix to turn off the if (scroll === 0) when detecting Obsidian is running on Mobile?
Thanks for your research and changes. It will be great if you make Pull request with a fix.
A check was added in the case when a note is opened by a link that contains a #header. In this case, scrolling is not necessary. I haven't tested on mobile. Please, check how the plugin behaves on PC and mobile after your changes when you open a link that contains #header.
thanks @dy-sh . Now I understand the meaning of the check. Will work on a solution and come back later.
@dy-sh , I further debug the code and I don't understand why check if (scroll === 0) is enough to detect "whether a note is opened by a link that contains a #header". Is it a bug or my misunderstanding?
Let's consider a scenario:
- MD file a.md has a header "# first" at the 1st line.
- User scrolls a.md to the last line and place the cursor
- MD file b.md has a link
[[a#first]]
When users follow the [[a#first]], they want to go to 1st line of a.md. However, since scroll == 0, remember-cursor-position will scroll to the last line.