diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1602d2c8..830a2272 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 15.1.0
+
+- feat: Add a new option `hoverOffset` to activate hover effect on the offset area around the scrollbar, closes [#616](https://github.com/MurhafSousli/ngx-scrollbar/issues/616).
+- fix: Scrollbar thumb color is not changing on hover, closes [#625](https://github.com/MurhafSousli/ngx-scrollbar/issues/625).
+
## 15.0.4
- fix: global Angular app styles gets broken in Firefox, closes [#615](https://github.com/MurhafSousli/ngx-scrollbar/issues/615).
diff --git a/projects/ngx-scrollbar-demo/src/app/example2/example2.component.scss b/projects/ngx-scrollbar-demo/src/app/example2/example2.component.scss
index 73c443bc..10cc13e3 100644
--- a/projects/ngx-scrollbar-demo/src/app/example2/example2.component.scss
+++ b/projects/ngx-scrollbar-demo/src/app/example2/example2.component.scss
@@ -1,5 +1,6 @@
ng-scrollbar {
--scrollbar-thickness: 7;
+ --scrollbar-hover-thickness: 7;
--scrollbar-offset: 16;
--scrollbar-track-color: rgb(0 0 0 / 10%);
--scrollbar-thumb-color: rgb(0 0 0 / 20%);
diff --git a/projects/ngx-scrollbar-demo/src/app/lab/lab.component.html b/projects/ngx-scrollbar-demo/src/app/lab/lab.component.html
index de0f4379..7de502a9 100644
--- a/projects/ngx-scrollbar-demo/src/app/lab/lab.component.html
+++ b/projects/ngx-scrollbar-demo/src/app/lab/lab.component.html
@@ -61,6 +61,15 @@
+
+
Hover offset
+
+ True
+ False
+
+
+
Buttons
-
+
Styling
@@ -153,6 +164,7 @@
[position]="position"
[style]="cssVariables"
[buttons]="buttons"
+ [hoverOffset]="hoverOffset"
[disableInteraction]="interactionDisabled"
[disableSensor]="disableSensor"
[sensorThrottleTime]="sensorThrottleTime"
diff --git a/projects/ngx-scrollbar-demo/src/app/lab/lab.component.ts b/projects/ngx-scrollbar-demo/src/app/lab/lab.component.ts
index 450c0d91..bbc2e745 100644
--- a/projects/ngx-scrollbar-demo/src/app/lab/lab.component.ts
+++ b/projects/ngx-scrollbar-demo/src/app/lab/lab.component.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, Component, signal, ViewChild, WritableSignal } from '@angular/core';
+import { Component, inject, signal, ViewChild, WritableSignal, ChangeDetectionStrategy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DomSanitizer, SafeStyle } from '@angular/platform-browser';
@@ -51,10 +51,15 @@ import { SmoothScrollFormComponent, SmoothScrollOptionsForm } from './smooth-scr
})
export class LabComponent {
+ private sanitizer: DomSanitizer = inject(DomSanitizer);
+
@ViewChild(NgScrollbar, { static: true }) component: NgScrollbar;
+ stylingPanelExpanded: boolean;
+
direction: 'ltr' | 'rtl' = 'ltr';
buttons: boolean = true;
+ hoverOffset: boolean = false;
interactionDisabled: boolean = false;
disableSensor: boolean = false;
disableReached: boolean = false;
@@ -97,9 +102,6 @@ export class LabComponent {
return 'Lorem ipsum dolor sit amet' + content.repeat(this.slider.contentSize);
}
- constructor(private sanitizer: DomSanitizer) {
- }
-
width: number = 448;
height: number = 300;
id: number = -1;
@@ -154,6 +156,11 @@ export class LabComponent {
}
}
+ onExpandedChange(expanded: boolean): void {
+ if (!expanded) {
+ this.stylingPanelExpanded = false;
+ }
+ }
}
const content: string = `
diff --git a/projects/ngx-scrollbar/package.json b/projects/ngx-scrollbar/package.json
index aab5c0ed..80f584d1 100644
--- a/projects/ngx-scrollbar/package.json
+++ b/projects/ngx-scrollbar/package.json
@@ -1,6 +1,6 @@
{
"name": "ngx-scrollbar",
- "version": "15.0.4",
+ "version": "15.1.0",
"license": "MIT",
"homepage": "https://ngx-scrollbar.netlify.com/",
"author": {
@@ -20,9 +20,9 @@
"scroll-reached"
],
"peerDependencies": {
- "@angular/common": ">=17.0.0",
- "@angular/core": ">=17.0.0",
- "@angular/cdk": ">=17.0.0",
+ "@angular/common": ">=17.1.0",
+ "@angular/core": ">=17.1.0",
+ "@angular/cdk": ">=17.1.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/projects/ngx-scrollbar/src/lib/ng-scrollbar-core.ts b/projects/ngx-scrollbar/src/lib/ng-scrollbar-core.ts
index bad8a7aa..6de5ad99 100644
--- a/projects/ngx-scrollbar/src/lib/ng-scrollbar-core.ts
+++ b/projects/ngx-scrollbar/src/lib/ng-scrollbar-core.ts
@@ -58,7 +58,8 @@ const defaultOptions: NgScrollbarOptions = {
sensorThrottleTime: 0,
disableSensor: false,
disableInteraction: false,
- buttons: false
+ buttons: false,
+ hoverOffset: false
};
interface ViewportState {
@@ -154,6 +155,11 @@ export abstract class NgScrollbarCore implements _NgScrollbar, OnInit, AfterView
transform: numberAttribute
});
+ /** A flag used to activate hover effect on the offset area around the scrollbar */
+ hoverOffset: InputSignalWithTransform = input(this.options.hoverOffset, {
+ transform: booleanAttribute
+ });
+
viewportDimension: WritableSignal = signal({
contentHeight: 0,
contentWidth: 0,
diff --git a/projects/ngx-scrollbar/src/lib/ng-scrollbar.model.ts b/projects/ngx-scrollbar/src/lib/ng-scrollbar.model.ts
index 2f1acee4..448fffe9 100644
--- a/projects/ngx-scrollbar/src/lib/ng-scrollbar.model.ts
+++ b/projects/ngx-scrollbar/src/lib/ng-scrollbar.model.ts
@@ -66,4 +66,6 @@ export interface NgScrollbarOptions {
disableSensor?: boolean;
/** Show scrollbar buttons */
buttons?: boolean;
+ /** A flag used to activate hover effect on the offset area around the scrollbar */
+ hoverOffset?: boolean;
}
diff --git a/projects/ngx-scrollbar/src/lib/scrollbar/horizontal.scss b/projects/ngx-scrollbar/src/lib/scrollbar/horizontal.scss
index e2122e49..62dc0c67 100644
--- a/projects/ngx-scrollbar/src/lib/scrollbar/horizontal.scss
+++ b/projects/ngx-scrollbar/src/lib/scrollbar/horizontal.scss
@@ -56,11 +56,11 @@
.ng-scrollbar-track-wrapper {
height: var(--_track-x-thickness);
flex-direction: row;
+}
- &:hover {
- --_track-x-thickness: var(--_scrollbar-hover-thickness-px);
- --_thumb-x-color: var(var(--INTERNAL-scrollbar-thumb-min-size));
- }
+.ng-scrollbar-hover:hover {
+ --_track-x-thickness: var(--_scrollbar-hover-thickness-px);
+ --_thumb-x-color: var(--INTERNAL-scrollbar-thumb-hover-color);
}
.ng-scrollbar-thumb {
diff --git a/projects/ngx-scrollbar/src/lib/scrollbar/scrollbar.ts b/projects/ngx-scrollbar/src/lib/scrollbar/scrollbar.ts
index 971f073b..b8ca462b 100644
--- a/projects/ngx-scrollbar/src/lib/scrollbar/scrollbar.ts
+++ b/projects/ngx-scrollbar/src/lib/scrollbar/scrollbar.ts
@@ -11,8 +11,10 @@ import { ScrollbarManager } from '../utils/scrollbar-manager';
standalone: true,
selector: 'scrollbar-y',
template: `
-