Skip to content

Commit 17af5b3

Browse files
committed
chore: upgrade rt-smooth-scroll to version 1.4.0
- Updated the version in package.json from 1.3.0 to 1.4.0. - Refactored index.min.js to include new features and optimizations. - Enhanced anchor link conversion logic to return the count of converted links. - Added logging for anchor conversion and instance creation. - Implemented auto-resize observers for instances to handle DOM changes. - Improved error handling and logging for script loading and scroll triggers.
1 parent ea15d46 commit 17af5b3

5 files changed

Lines changed: 164 additions & 48 deletions

File tree

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
- A clean global API under `window.rtSmoothScroll`
1515
- **Smart Scroll-To actions** with indexed selectors and dynamic offsets
1616
- **Automatic Anchor Link Conversion** (hijack native links for smooth scrolling)
17+
- **Automatic DOM Resize Detection** (uses `ResizeObserver` to update scroll height on dynamic content changes)
1718
- **Scroll-To Completion Hooks** (run actions/functions after a scroll-to completes)
1819
- Per-instance configuration via HTML attributes
19-
- Console logs showing each instance’s final resolved config
20+
- **Debug Mode** with helpful console logs for development
2021

2122
**Lenis (GitHub):** https://github.com/darkroomengineering/lenis
2223

@@ -34,7 +35,7 @@
3435
- [6. Anchor Link Conversion](#6-anchor-link-conversion)
3536
- [7. Multiple Instances](#7-multiple-instances)
3637
- [8. Global API](#8-global-api)
37-
- [9. Console Logging](#9-console-logging)
38+
- [9. Console Logging & Debugging](#9-console-logging--debugging)
3839
- [10. Troubleshooting](#10-troubleshooting)
3940
- [11. License](#11-license)
4041

@@ -45,13 +46,14 @@
4546
### 1.1 CDN (jsDelivr)
4647

4748
```html
48-
<script src="https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js"></script>
49+
<script src="[https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js](https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js)"></script>
4950
```
5051

5152
### 1.2 npm
5253

5354
```bash
5455
npm install @rethink-js/rt-smooth-scroll
56+
5557
```
5658

5759
Then bundle or load `dist/index.min.js` as appropriate for your build setup.
@@ -70,7 +72,7 @@ Add the script to your page. With no configuration provided, `rt-smooth-scroll`
7072
Example:
7173

7274
```html
73-
<script src="https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js"></script>
75+
<script src="[https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js](https://cdn.jsdelivr.net/npm/@rethink-js/rt-smooth-scroll@latest/dist/index.min.js)"></script>
7476
```
7577

7678
> Note: If you do not set any `rt-smooth-scroll-*` config attributes, the root instance uses **Lenis defaults**.
@@ -108,6 +110,7 @@ Place on `<html>` or `<body>` to configure defaults:
108110
rt-smooth-scroll-lerp="0.2"
109111
rt-smooth-scroll-wheel-multiplier="1"
110112
rt-smooth-scroll-easing="easeOutCubic"
113+
rt-smooth-scroll-debug="true"
111114
></body>
112115
```
113116

@@ -131,13 +134,15 @@ Important Lenis behavior:
131134
| `rt-smooth-scroll-sync-touch-lerp` | Lenis `syncTouchLerp` |
132135
| `rt-smooth-scroll-touch-inertia-exponent` | Lenis `touchInertiaExponent` |
133136
| `rt-smooth-scroll-infinite` | Lenis `infinite` |
134-
| `rt-smooth-scroll-auto-resize` | Lenis `autoResize` |
137+
| `rt-smooth-scroll-auto-resize` | Lenis `autoResize` (window resize only) |
135138
| `rt-smooth-scroll-overscroll` | Lenis `overscroll` |
136139
| `rt-smooth-scroll-anchors` | Lenis `anchors` (boolean or JSON) |
137140
| `rt-smooth-scroll-auto-toggle` | Lenis `autoToggle` |
138141
| `rt-smooth-scroll-allow-nested-scroll` | Lenis `allowNestedScroll` |
139142
| `rt-smooth-scroll-easing` | Named easing function (only applies when `lerp` is not used) |
140143
| `rt-smooth-scroll-options-json` | Merge additional Lenis options via JSON |
144+
| `rt-smooth-scroll-debug` | Enable/disable console logging (default: `true`) |
145+
| `rt-smooth-scroll-resize-debounce-ms` | Delay (ms) for resize calculations (default: `0`) |
141146

142147
**Easing options included:**
143148

@@ -440,16 +445,23 @@ window.lenis;
440445

441446
---
442447

443-
## 9. Console Logging
448+
## 9. Console Logging & Debugging
449+
450+
By default, `rt-smooth-scroll` runs in **debug mode** (`true`). It will log helpful messages to the console during development, such as:
451+
452+
- Lenis load status
453+
- Anchor link conversion counts
454+
- Instance creation (showing resolved options)
455+
- Scroll triggers (showing target resolution)
456+
- ResizeObserver attachments
444457

445-
On startup, each instance logs:
458+
### Disabling Logs
446459

447-
- Instance ID
448-
- Wrapper element
449-
- Content element
450-
- Final resolved options
460+
To silence these logs in production, set the attribute to false on your root element:
451461

452-
This helps you confirm exactly what configuration is applied in the browser.
462+
```html
463+
<body rt-smooth-scroll rt-smooth-scroll-debug="false"></body>
464+
```
453465

454466
---
455467

@@ -461,9 +473,12 @@ This helps you confirm exactly what configuration is applied in the browser.
461473
- **Decrease** `rt-smooth-scroll-lerp` (e.g. `0.1 → 0.05`) for a smoother/heavier feel.
462474
- Leave `rt-smooth-scroll-wheel-multiplier="1"` unless you have a strong reason to change perceived speed.
463475

464-
### Duration / easing doesn’t seem to do anything
476+
### Dynamic content (Accordions/Tabs) cuts off scroll
477+
478+
This library includes a built-in `ResizeObserver` that watches your content for height changes.
465479

466-
Lenis treats `duration` and `easing` as **useless if `lerp` is defined**. If you want time-based behavior, ensure you’re not effectively running in lerp-mode.
480+
- Ensure your content is properly wrapped.
481+
- If you have rapid animations causing lag, you can debounce the resize events using `rt-smooth-scroll-resize-debounce-ms="100"`.
467482

468483
### My `rt-smooth-scroll-on-complete` didn’t run
469484

dist/index.js

Lines changed: 62 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)