lnreader icon indicating copy to clipboard operation
lnreader copied to clipboard

Page Reader

Open CD-Z opened this issue 1 year ago • 2 comments

Added an improved version of my Page Reader PR in the main branch. #733

Improvements:

  • pages instead of percent
  • working scrollbars
  • Chapter switch at the end or beginning of a chapter like a normal page
  • autoscroll to last position

Additional changes:

  • added change padding setting to reader
  • fixed scroll to top button in reader

CD-Z avatar Apr 03 '24 14:04 CD-Z

btw I recommend updating pageReader setting without re-rendering by using Reader.updateGengeralSettings (if possilbe)

Any changes in settings are listened by this code (WebviewReader.tsx), then it triggers to Webview without update state in React

    const mmkvListener = MMKVStorage.addOnValueChangedListener(key => {
      switch (key) {
        case CHAPTER_READER_SETTINGS:
          webViewRef.current?.injectJavaScript(
            `reader.updateReaderSettings(${MMKVStorage.getString(
              CHAPTER_READER_SETTINGS,
            )})`,
          );
          break;
        case CHAPTER_GENERAL_SETTINGS:
          webViewRef.current?.injectJavaScript(
            `reader.updateGeneralSettings(${MMKVStorage.getString(
              CHAPTER_GENERAL_SETTINGS,
            )})`,
          );
          break;
      }

nyagami avatar Apr 06 '24 02:04 nyagami

btw I recommend updating pageReader setting without re-rendering by using Reader.updateGengeralSettings (if possilbe)

Any changes in settings are listened by this code (WebviewReader.tsx), then it triggers to Webview without update state in React

    const mmkvListener = MMKVStorage.addOnValueChangedListener(key => {
      switch (key) {
        case CHAPTER_READER_SETTINGS:
          webViewRef.current?.injectJavaScript(
            `reader.updateReaderSettings(${MMKVStorage.getString(
              CHAPTER_READER_SETTINGS,
            )})`,
          );
          break;
        case CHAPTER_GENERAL_SETTINGS:
          webViewRef.current?.injectJavaScript(
            `reader.updateGeneralSettings(${MMKVStorage.getString(
              CHAPTER_GENERAL_SETTINGS,
            )})`,
          );
          break;
      }

I took a look at it and if I understand you correctly you suggest to not rerender the page when changing from the normal view to the page view.

If this is correct then I don't really see the reason, since it is not easy to change the behavior and would introduce issues that would have to be dealt with. For example the scroll position.

CD-Z avatar May 05 '24 00:05 CD-Z

@nyagami could you please take another look at this, I don't want to always solve the merge conflicts. It gets annoying

CD-Z avatar Jul 14 '24 09:07 CD-Z

Okay

nyagami avatar Jul 14 '24 09:07 nyagami