} 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
}
@Component({
- selector: 'list-overflow',
+ selector: 'my-list-overflow',
templateUrl: './list-overflow.component.html',
styleUrls: [ './list-overflow.component.scss' ],
changeDetection: ChangeDetectionStrategy.OnPush
showItemsUntilIndexExcluded: number
active = false
- isInTouchScreen = false
isInMobileView = false
private openedOnHover = false
@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
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()
}