]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/misc/list-overflow.component.ts
Replace glyphicon chevron
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / misc / list-overflow.component.ts
index 144e0f1567370ac2bad8809d59edd88e22cc4e6c..541991f7438f34a8b098e4d8edc5eb6880ab7c23 100644 (file)
@@ -15,6 +15,9 @@ import {
 } from '@angular/core'
 import { ScreenService } from '@app/core'
 import { NgbDropdown, NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import * as debug from 'debug'
+
+const logger = debug('peertube:main:ListOverflowItem')
 
 export interface ListOverflowItem {
   label: string
@@ -22,7 +25,7 @@ export interface ListOverflowItem {
 }
 
 @Component({
-  selector: 'list-overflow',
+  selector: 'my-list-overflow',
   templateUrl: './list-overflow.component.html',
   styleUrls: [ './list-overflow.component.scss' ],
   changeDetection: ChangeDetectionStrategy.OnPush
@@ -37,7 +40,6 @@ export class ListOverflowComponent<T extends ListOverflowItem> implements AfterV
 
   showItemsUntilIndexExcluded: number
   active = false
-  isInTouchScreen = false
   isInMobileView = false
 
   private openedOnHover = false
@@ -58,14 +60,15 @@ export class ListOverflowComponent<T extends ListOverflowItem> implements AfterV
 
   @HostListener('window:resize')
   onWindowResize () {
-    this.isInTouchScreen = !!this.screenService.isInTouchScreen()
     this.isInMobileView = !!this.screenService.isInMobileView()
 
     const parentWidth = this.parent.nativeElement.getBoundingClientRect().width
     let showItemsUntilIndexExcluded: number
     let accWidth = 0
 
-    for (const [index, el] of this.itemsRendered.toArray().entries()) {
+    logger('Parent width is %d', parentWidth)
+
+    for (const [ index, el ] of this.itemsRendered.toArray().entries()) {
       accWidth += el.nativeElement.getBoundingClientRect().width
       if (showItemsUntilIndexExcluded === undefined) {
         showItemsUntilIndexExcluded = (parentWidth < accWidth) ? index : undefined
@@ -76,6 +79,8 @@ export class ListOverflowComponent<T extends ListOverflowItem> implements AfterV
       e.style.visibility = shouldBeVisible ? 'inherit' : 'hidden'
     }
 
+    logger('Accumulated children width is %d so exclude index is %d', accWidth, showItemsUntilIndexExcluded)
+
     this.showItemsUntilIndexExcluded = showItemsUntilIndexExcluded
     this.cdr.markForCheck()
   }