Skip to content

Commit dc45695

Browse files
authored
Merge pull request #1175 from cycsmail/hide-cursor-when-controls-dimmed-736
Hide the mouse cursor when the lightbox controls are hidden
2 parents 3a62e85 + 89fbbb1 commit dc45695

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ input[type="range"].zoom-progress::-moz-range-track {
302302
opacity: 0.0;
303303
}
304304

305+
/* hide the mouse cursor together with the controls (e.g. during slideshow) */
306+
#swipeable-container.hide-cursor {
307+
cursor: none;
308+
}
309+
305310
.controls-title.controls-nodim {
306311
opacity: 0.7;
307312
}

src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
</div>
137137

138138
<div id="swipeable-container"
139+
[class.hide-cursor]="controllersDimmed"
139140
(swipeleft)="zoom == 1 && nextPhoto.emit()"
140141
(swiperight)="zoom == 1 && previousPhoto.emit()"
141142
(swipeup)="zoom == 1 && closed.emit()"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import {ComponentFixture, TestBed} from '@angular/core/testing';
2+
import {provideNoopAnimations} from '@angular/platform-browser/animations';
3+
import {provideRouter} from '@angular/router';
4+
import {NgIconsModule} from '@ng-icons/core';
5+
import {
6+
ionChevronBackOutline,
7+
ionChevronForwardOutline,
8+
ionCloseOutline,
9+
ionContractOutline,
10+
ionExpandOutline,
11+
ionInformationOutline,
12+
ionMenuOutline,
13+
ionPauseOutline,
14+
ionPlayOutline,
15+
} from '@ng-icons/ionicons';
16+
17+
import {ControlsLightboxComponent} from './controls.lightbox.gallery.component';
18+
import {LightboxService} from '../lightbox.service';
19+
import {FullScreenService} from '../../fullscreen.service';
20+
import {AuthenticationService} from '../../../../model/network/authentication.service';
21+
import {FileSizePipe} from '../../../../pipes/FileSizePipe';
22+
import {DatePipe} from '@angular/common';
23+
24+
class MockLightboxService {
25+
controllersDimmed = false;
26+
slideshowSpeed = 5;
27+
captionAlwaysOn = false;
28+
facesAlwaysOn = false;
29+
}
30+
31+
class MockFullScreenService {
32+
isFullScreenEnabled() {
33+
return false;
34+
}
35+
}
36+
37+
class MockAuthenticationService {
38+
canSearch() {
39+
return false;
40+
}
41+
}
42+
43+
describe('ControlsLightboxComponent - cursor visibility', () => {
44+
let component: ControlsLightboxComponent;
45+
let fixture: ComponentFixture<ControlsLightboxComponent>;
46+
47+
beforeEach(async () => {
48+
await TestBed.configureTestingModule({
49+
imports: [
50+
ControlsLightboxComponent,
51+
NgIconsModule.withIcons({
52+
ionInformationOutline,
53+
ionContractOutline,
54+
ionExpandOutline,
55+
ionMenuOutline,
56+
ionCloseOutline,
57+
ionChevronBackOutline,
58+
ionChevronForwardOutline,
59+
ionPlayOutline,
60+
ionPauseOutline,
61+
}),
62+
],
63+
providers: [
64+
{provide: LightboxService, useClass: MockLightboxService},
65+
{provide: FullScreenService, useClass: MockFullScreenService},
66+
{provide: AuthenticationService, useClass: MockAuthenticationService},
67+
{provide: FileSizePipe, useValue: {}},
68+
{provide: DatePipe, useValue: {}},
69+
provideNoopAnimations(),
70+
provideRouter([]),
71+
],
72+
}).compileComponents();
73+
74+
fixture = TestBed.createComponent(ControlsLightboxComponent);
75+
component = fixture.componentInstance;
76+
fixture.detectChanges();
77+
});
78+
79+
it('should hide the cursor while the controls are dimmed', () => {
80+
component.controllersDimmed = true;
81+
fixture.detectChanges();
82+
83+
const swipeable: HTMLElement = fixture.nativeElement.querySelector('#swipeable-container');
84+
expect(swipeable).toBeTruthy();
85+
expect(swipeable.classList.contains('hide-cursor')).toBe(true);
86+
});
87+
88+
it('should keep the cursor visible while the controls are shown', () => {
89+
component.controllersDimmed = false;
90+
fixture.detectChanges();
91+
92+
const swipeable: HTMLElement = fixture.nativeElement.querySelector('#swipeable-container');
93+
expect(swipeable).toBeTruthy();
94+
expect(swipeable.classList.contains('hide-cursor')).toBe(false);
95+
});
96+
});

0 commit comments

Comments
 (0)