Skip to content

Added Scroll bar for bani reader#361

Draft
amitojsingh wants to merge 6 commits intodevfrom
303-bug-scroll-bar-is-missing
Draft

Added Scroll bar for bani reader#361
amitojsingh wants to merge 6 commits intodevfrom
303-bug-scroll-bar-is-missing

Conversation

@amitojsingh
Copy link
Collaborator

@amitojsingh amitojsingh commented Dec 17, 2025

Previously, Android and iOS relied on their native scrollbars. However, WebView doesn’t allow reliable customization of scrollbar colors, which affected readability. As Scrollbar is hidden in Dark mode.
To address this and improve the reading experience of the Bani, I implemented a custom scrollbar.

Before
IMG_1004

After Adding Scrollbar
Screenshot 2025-12-19 at 4 26 17 PM

- Added properties to WebView to hide vertical and horizontal scroll indicators for a cleaner interface.
- Implemented a minimal custom scrollbar in gutkaScript.js for improved user experience during scrolling, ensuring visibility on both Android and iOS.
- Updated gutkahtml.js to include styles for the new scrollbar, enhancing the overall aesthetic and functionality of the ReaderScreen.
@amitojsingh amitojsingh linked an issue Dec 17, 2025 that may be closed by this pull request
7 tasks
Copy link
Collaborator

@Gauravjeetsingh Gauravjeetsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly needs update with code indentation and variable names.

Also, I am curious why are we creating a custom scrollbar, can you please let me know the issue with the default scrollbar?

const p=Math.max(0,Math.min(1,(window.pageYOffset||0)/h));
const th=Math.max(30,(window.innerHeight/h)*window.innerHeight);
const t=sb.children[0];
if(t){t.style.height=th+"px";t.style.top=(p*(window.innerHeight-th))+"px";}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very congested and difficult to read. Can you please fix the indentation and use proper variable names, instead of single letter variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

scrollToPosition();
scrollToPosition();

// Minimal scrollbar - works on Android and iOS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add some explanation, on the purpose of this code, is this removing an existing div with id #sb and then adding another div with same id sb?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added as defensive logic to handle cases where the screen may load multiple times, preventing duplicate scrollbars from being created.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't add a condition that if this div exists, do not add another? Why do we need to remove and add?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

text-align:right
}
/* Minimal scrollbar */
#sb { position:fixed; right:0; top:0; width:6px; height:100vh; z-index:99999; pointer-events:none; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the indentation here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

- Improved the CSS formatting for the custom scrollbar in gutkahtml.js for better readability and maintainability.
- Enhanced the updateSB function in gutkaScript.js to improve the logic for displaying the scrollbar, ensuring it adapts correctly to the content height and window size.
- Cleaned up code formatting for consistency across both files.
- Renamed variables for clarity, changing 'sb' to 'scrollbar' to enhance code readability.
- Updated the updateSB function to updateScrollbar, improving the logic for scrollbar visibility and positioning.
- Enhanced the scrollFunc to utilize the new updateScrollbar function, ensuring consistent behavior during scroll events.
- Cleaned up code formatting for better maintainability.
@amitojsingh
Copy link
Collaborator Author

Updated the description.

@amitojsingh amitojsingh linked an issue Dec 22, 2025 that may be closed by this pull request
7 tasks
}
#sb-t {
position: absolute;
right: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should either be 0, or 1px, right? Is there a reason for it being 1 without the unit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

scrollbar.appendChild(scrollbarThumb);
document.body.appendChild(scrollbar);
setTimeout(updateScrollbar, 100);
window.addEventListener("resize", updateScrollbar);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everytime the window.onload fires, it adds a new resize listener without removing the previous one. Maybe store its reference somewhere, and use that to add a condition that if the listener already exists, remove it before adding a new one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- Updated the scrollbar CSS in gutkahtml.js to specify the unit for the right position, ensuring proper rendering.
- Added a resize listener in gutkaScript.js to improve scrollbar responsiveness, removing any existing listener before adding a new one for better performance.
- Cleaned up code formatting for consistency and maintainability across both files.
@amitojsingh amitojsingh marked this pull request as draft December 25, 2025 19:30
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.

[BUG] Changes after September update [BUG] Scroll bar is missing

2 participants