1
- import { Inject , Injectable , isDevMode } from '@angular/core' ;
1
+ import { Inject , Injectable } from '@angular/core' ;
2
2
3
3
import { PageScrollConfig } from '../types/page-scroll.config' ;
4
4
import { InterruptReporter , PageScrollInstance , PageScrollOptions } from '../page-scroll-instance' ;
@@ -84,8 +84,10 @@ export class PageScrollService {
84
84
85
85
if ( pageScrollInstance . pageScrollOptions . scrollViews === null || pageScrollInstance . pageScrollOptions . scrollViews . length === 0 ) {
86
86
// 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
+ }
89
91
}
90
92
91
93
return ;
@@ -131,8 +133,10 @@ export class PageScrollService {
131
133
if ( isNaN ( pageScrollInstance . distanceToScroll ) ) {
132
134
// We weren't able to find the target position, maybe the element does not exist?
133
135
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
+ }
136
140
}
137
141
pageScrollInstance . fireEvent ( false ) ;
138
142
@@ -160,11 +164,13 @@ export class PageScrollService {
160
164
const tooShortInterval = pageScrollInstance . executionDuration <= pageScrollInstance . pageScrollOptions . _interval ;
161
165
162
166
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
+ }
168
174
}
169
175
}
170
176
pageScrollInstance . setScrollPosition ( pageScrollInstance . targetScrollPosition ) ;
@@ -177,8 +183,10 @@ export class PageScrollService {
177
183
const alreadyInView = pageScrollInstance . targetScrollPosition > pageScrollInstance . startScrollPosition &&
178
184
pageScrollInstance . targetScrollPosition <= pageScrollInstance . startScrollPosition + scrollRange ;
179
185
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
+ }
182
190
}
183
191
pageScrollInstance . fireEvent ( true ) ;
184
192
@@ -215,8 +223,10 @@ export class PageScrollService {
215
223
instance . distanceToScroll ,
216
224
instance . executionDuration ) ) ;
217
225
}
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
+ }
220
230
}
221
231
// Set the new scrollPosition to all scrollViews elements
222
232
if ( ! instance . setScrollPosition ( newScrollPosition ) ) {
0 commit comments