Commit 6e377ee 1 parent a0f53fe commit 6e377ee Copy full SHA for 6e377ee
File tree 3 files changed +44
-2
lines changed
3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 1
- import { Component } from '@angular/core' ;
1
+ import { Component , OnInit } from '@angular/core' ;
2
2
import { RouterOutlet } from '@angular/router' ;
3
+ import { ScrollService } from '@services/scroll.service' ;
3
4
4
5
@Component ( {
5
6
selector : 'app-root' ,
6
7
imports : [ RouterOutlet ] ,
7
8
templateUrl : './app.component.html' ,
8
9
styleUrl : './app.component.scss' ,
9
10
} )
10
- export class AppComponent { }
11
+ export class AppComponent implements OnInit {
12
+ constructor ( private scrollService : ScrollService ) { }
13
+
14
+ ngOnInit ( ) {
15
+ this . scrollService . initLenis ( ) ;
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ import { TestBed } from '@angular/core/testing' ;
2
+
3
+ import { ScrollService } from './scroll.service' ;
4
+
5
+ describe ( 'ScrollService' , ( ) => {
6
+ let service : ScrollService ;
7
+
8
+ beforeEach ( ( ) => {
9
+ TestBed . configureTestingModule ( { } ) ;
10
+ service = TestBed . inject ( ScrollService ) ;
11
+ } ) ;
12
+
13
+ it ( 'should be created' , ( ) => {
14
+ expect ( service ) . toBeTruthy ( ) ;
15
+ } ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { Injectable , NgZone } from '@angular/core' ;
2
+ import Lenis from 'lenis' ;
3
+
4
+ @Injectable ( {
5
+ providedIn : 'root' ,
6
+ } )
7
+ export class ScrollService {
8
+ private lenis ! : Lenis ;
9
+
10
+ constructor ( private ngZone : NgZone ) { }
11
+
12
+ initLenis ( ) {
13
+ this . ngZone . runOutsideAngular ( ( ) => {
14
+ this . lenis = new Lenis ( {
15
+ autoRaf : true ,
16
+ } ) ;
17
+ } ) ;
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments