1- import { Inject , Injectable , isDevMode } from '@angular/core' ;
1+ import { Inject , Injectable } from '@angular/core' ;
22
33import { PageScrollConfig } from '../types/page-scroll.config' ;
44import { InterruptReporter , PageScrollInstance , PageScrollOptions } from '../page-scroll-instance' ;
@@ -84,8 +84,10 @@ export class PageScrollService {
8484
8585 if ( pageScrollInstance . pageScrollOptions . scrollViews === null || pageScrollInstance . pageScrollOptions . scrollViews . length === 0 ) {
8686 // No scrollViews specified, thus we can't animate anything
87- if ( this . config . _logLevel >= 2 || ( this . config . _logLevel >= 1 && isDevMode ( ) ) ) {
88- console . warn ( 'No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll' ) ;
87+ if ( typeof ngDevMode !== 'undefined' && ngDevMode ) {
88+ if ( this . config . _logLevel >= 1 ) {
89+ console . warn ( 'No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll' ) ;
90+ }
8991 }
9092
9193 return ;
@@ -131,8 +133,10 @@ export class PageScrollService {
131133 if ( isNaN ( pageScrollInstance . distanceToScroll ) ) {
132134 // We weren't able to find the target position, maybe the element does not exist?
133135
134- if ( this . config . _logLevel >= 2 || ( this . config . _logLevel >= 1 && isDevMode ( ) ) ) {
135- console . log ( 'Scrolling not possible, as we can\'t find the specified target' ) ;
136+ if ( typeof ngDevMode !== 'undefined' && ngDevMode ) {
137+ if ( this . config . _logLevel >= 1 ) {
138+ console . log ( 'Scrolling not possible, as we can\'t find the specified target' ) ;
139+ }
136140 }
137141 pageScrollInstance . fireEvent ( false ) ;
138142
@@ -160,11 +164,13 @@ export class PageScrollService {
160164 const tooShortInterval = pageScrollInstance . executionDuration <= pageScrollInstance . pageScrollOptions . _interval ;
161165
162166 if ( allReadyAtDestination || tooShortInterval ) {
163- if ( this . config . _logLevel >= 2 || ( this . config . _logLevel >= 1 && isDevMode ( ) ) ) {
164- if ( allReadyAtDestination ) {
165- console . log ( 'Scrolling not possible, as we can\'t get any closer to the destination' ) ;
166- } else {
167- console . log ( 'Scroll duration shorter that interval length, jumping to target' ) ;
167+ if ( this . config . _logLevel >= 2 || this . config . _logLevel >= 1 ) {
168+ if ( typeof ngDevMode !== 'undefined' && ngDevMode ) {
169+ if ( allReadyAtDestination ) {
170+ console . log ( 'Scrolling not possible, as we can\'t get any closer to the destination' ) ;
171+ } else {
172+ console . log ( 'Scroll duration shorter that interval length, jumping to target' ) ;
173+ }
168174 }
169175 }
170176 pageScrollInstance . setScrollPosition ( pageScrollInstance . targetScrollPosition ) ;
@@ -177,8 +183,10 @@ export class PageScrollService {
177183 const alreadyInView = pageScrollInstance . targetScrollPosition > pageScrollInstance . startScrollPosition &&
178184 pageScrollInstance . targetScrollPosition <= pageScrollInstance . startScrollPosition + scrollRange ;
179185 if ( alreadyInView ) {
180- if ( this . config . _logLevel >= 2 || ( this . config . _logLevel >= 1 && isDevMode ( ) ) ) {
181- console . log ( 'Not scrolling, as target already in view' ) ;
186+ if ( typeof ngDevMode !== 'undefined' && ngDevMode ) {
187+ if ( this . config . _logLevel >= 1 ) {
188+ console . log ( 'Not scrolling, as target already in view' ) ;
189+ }
182190 }
183191 pageScrollInstance . fireEvent ( true ) ;
184192
@@ -215,8 +223,10 @@ export class PageScrollService {
215223 instance . distanceToScroll ,
216224 instance . executionDuration ) ) ;
217225 }
218- if ( this . config . _logLevel >= 5 && isDevMode ( ) ) {
219- console . warn ( 'Scroll Position: ' + newScrollPosition ) ;
226+ if ( typeof ngDevMode !== 'undefined' && ngDevMode ) {
227+ if ( this . config . _logLevel >= 5 ) {
228+ console . warn ( 'Scroll Position: ' + newScrollPosition ) ;
229+ }
220230 }
221231 // Set the new scrollPosition to all scrollViews elements
222232 if ( ! instance . setScrollPosition ( newScrollPosition ) ) {
0 commit comments