From 6eb62c33908025d877a28f1cfbc527c511ae3103 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Aug 2019 13:59:54 +0200 Subject: [PATCH] Fix video rows overflow In discover and account channel videos pages --- .../account-video-channels.component.scss | 1 - .../account-video-channels.component.ts | 9 +++++++-- client/src/app/shared/misc/screen.service.ts | 16 +++++++++++++++- .../video-list/video-overview.component.html | 9 ++++++--- .../video-list/video-overview.component.ts | 10 +++++++++- client/src/sass/include/_miniature.scss | 3 --- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss index 7f7652460..a258c7b86 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss @@ -9,7 +9,6 @@ .section { @include miniature-rows; - overflow: visible; // For the subscribe dropdown padding-top: 0 !important; .section-title { diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 85dedd7de..29d2991fd 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -11,6 +11,7 @@ import { AuthService } from '@app/core' import { VideoService } from '@app/shared/video/video.service' import { VideoSortField } from '@app/shared/video/sort-field.type' import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model' +import { ScreenService } from '@app/shared/misc/screen.service' @Component({ selector: 'my-account-video-channels', @@ -42,7 +43,8 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { private authService: AuthService, private accountService: AccountService, private videoChannelService: VideoChannelService, - private videoService: VideoService + private videoService: VideoService, + private screenService: ScreenService ) { } get user () { @@ -83,7 +85,10 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { } getVideosOf (videoChannel: VideoChannel) { - return this.videos[ videoChannel.id ] + const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures() + + // 2 rows + return this.videos[ videoChannel.id ].slice(0, numberOfVideos * 2) } onNearOfBottom () { diff --git a/client/src/app/shared/misc/screen.service.ts b/client/src/app/shared/misc/screen.service.ts index af75569d9..220d41d59 100644 --- a/client/src/app/shared/misc/screen.service.ts +++ b/client/src/app/shared/misc/screen.service.ts @@ -22,8 +22,22 @@ export class ScreenService { return 'ontouchstart' in window || navigator.msMaxTouchPoints } + getNumberOfAvailableMiniatures () { + const screenWidth = this.getWindowInnerWidth() + + let numberOfVideos = 1 + + if (screenWidth > 1850) numberOfVideos = 6 + else if (screenWidth > 1600) numberOfVideos = 5 + else if (screenWidth > 1370) numberOfVideos = 4 + else if (screenWidth > 1100) numberOfVideos = 3 + else if (screenWidth > 850) numberOfVideos = 2 + + return numberOfVideos + } + // Cache window inner width, because it's an expensive call - private getWindowInnerWidth () { + getWindowInnerWidth () { if (this.cacheWindowInnerWidthExpired()) this.refreshWindowInnerWidth() return this.windowInnerWidth diff --git a/client/src/app/videos/video-list/video-overview.component.html b/client/src/app/videos/video-list/video-overview.component.html index f59de584a..5fe1f5c80 100644 --- a/client/src/app/videos/video-list/video-overview.component.html +++ b/client/src/app/videos/video-list/video-overview.component.html @@ -7,7 +7,8 @@ {{ object.category.label }} - + +
@@ -15,7 +16,8 @@ #{{ object.tag }}
- + +
@@ -27,7 +29,8 @@
- + + diff --git a/client/src/app/videos/video-list/video-overview.component.ts b/client/src/app/videos/video-list/video-overview.component.ts index 7ff52b259..4fee92d54 100644 --- a/client/src/app/videos/video-list/video-overview.component.ts +++ b/client/src/app/videos/video-list/video-overview.component.ts @@ -4,6 +4,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill' import { VideosOverview } from '@app/shared/overview/videos-overview.model' import { OverviewService } from '@app/shared/overview' import { Video } from '@app/shared/video/video.model' +import { ScreenService } from '@app/shared/misc/screen.service' @Component({ selector: 'my-video-overview', @@ -22,7 +23,8 @@ export class VideoOverviewComponent implements OnInit { private i18n: I18n, private notifier: Notifier, private authService: AuthService, - private overviewService: OverviewService + private overviewService: OverviewService, + private screenService: ScreenService ) { } get user () { @@ -53,4 +55,10 @@ export class VideoOverviewComponent implements OnInit { buildVideoChannelAvatarUrl (object: { videos: Video[] }) { return object.videos[0].videoChannelAvatarUrl } + + buildVideos (videos: Video[]) { + const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures() + + return videos.slice(0, numberOfVideos * 2) + } } diff --git a/client/src/sass/include/_miniature.scss b/client/src/sass/include/_miniature.scss index e4ed88d31..56126d41f 100644 --- a/client/src/sass/include/_miniature.scss +++ b/client/src/sass/include/_miniature.scss @@ -140,9 +140,6 @@ $play-overlay-width: 18px; } @mixin miniature-rows { - max-height: 540px; // 2 rows max - overflow: hidden; - &:first-child { padding-top: 30px; -- 2.41.0