@@ -25,6 +25,7 @@ import { IgxTabsGroupComponent } from './tabs-group.component';
2525import { IgxLeftButtonStyleDirective , IgxRightButtonStyleDirective , IgxTabItemTemplateDirective } from './tabs.directives' ;
2626import { IgxTabsBase , IgxTabItemBase } from './tabs.common' ;
2727import ResizeObserver from 'resize-observer-polyfill' ;
28+ import { PlatformUtil } from '../core/utils' ;
2829
2930export enum TabsType {
3031 FIXED = 'fixed' ,
@@ -298,7 +299,7 @@ export class IgxTabsComponent implements IgxTabsBase, AfterViewInit, OnDestroy {
298299 }
299300 }
300301
301- constructor ( private _element : ElementRef , private _ngZone : NgZone ) {
302+ constructor ( private _element : ElementRef , private _ngZone : NgZone , private platformUtil : PlatformUtil ) {
302303 }
303304
304305 /**
@@ -317,29 +318,32 @@ export class IgxTabsComponent implements IgxTabsBase, AfterViewInit, OnDestroy {
317318 this . _selectedIndex = 0 ;
318319 }
319320
320- requestAnimationFrame ( ( ) => {
321- const newTab = this . tabs . toArray ( ) [ this . _selectedIndex ] ;
322- if ( newTab ) {
323- this . performSelection ( newTab ) ;
324- } else {
325- this . hideIndicator ( ) ;
321+ if ( this . platformUtil . isBrowser ) {
322+ requestAnimationFrame ( ( ) => {
323+ const newTab = this . tabs . toArray ( ) [ this . _selectedIndex ] ;
324+ if ( newTab ) {
325+ this . performSelection ( newTab ) ;
326+ } else {
327+ this . hideIndicator ( ) ;
328+ }
329+ } ) ;
330+ if ( this . platformUtil . isBrowser ) {
331+ this . _ngZone . runOutsideAngular ( ( ) => {
332+ this . _resizeObserver = new ResizeObserver ( ( ) => {
333+ if ( ! this . hasContentTabs && this . _selectedIndex >= 0 && this . _selectedIndex < this . tabs . length ) {
334+ const newTab = this . tabs . toArray ( ) [ this . _selectedIndex ] ;
335+ this . transformContentAnimation ( newTab , 0 ) ;
336+ }
337+ } ) ;
338+
339+ this . _resizeObserver . observe ( this . tabsContainer . nativeElement ) ;
340+ } ) ;
326341 }
327- } ) ;
342+ }
328343
329344 this . _groupChanges$ = this . groups . changes . subscribe ( ( ) => {
330345 this . resetSelectionOnCollectionChanged ( ) ;
331346 } ) ;
332-
333- this . _ngZone . runOutsideAngular ( ( ) => {
334- this . _resizeObserver = new ResizeObserver ( ( ) => {
335- if ( ! this . hasContentTabs && this . _selectedIndex >= 0 && this . _selectedIndex < this . tabs . length ) {
336- const newTab = this . tabs . toArray ( ) [ this . _selectedIndex ] ;
337- this . transformContentAnimation ( newTab , 0 ) ;
338- }
339- } ) ;
340-
341- this . _resizeObserver . observe ( this . tabsContainer . nativeElement ) ;
342- } ) ;
343347 }
344348
345349 /**
0 commit comments