Video previews take all the width on mobile

This commit is contained in:
Chocobozzz 2018-02-09 09:30:37 +01:00
parent 7193ad1044
commit 3290f37c76
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
10 changed files with 49 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { GuardsCheckStart, NavigationEnd, Router } from '@angular/router' import { GuardsCheckStart, NavigationEnd, Router } from '@angular/router'
import { AuthService, ServerService } from '@app/core' import { AuthService, ServerService } from '@app/core'
import { isInMobileView } from '@app/shared/misc/utils' import { isInSmallView } from '@app/shared/misc/utils'
@Component({ @Component({
selector: 'my-app', selector: 'my-app',
@ -54,14 +54,14 @@ export class AppComponent implements OnInit {
this.serverService.loadVideoPrivacies() this.serverService.loadVideoPrivacies()
// Do not display menu on small screens // Do not display menu on small screens
if (isInMobileView()) { if (isInSmallView()) {
this.isMenuDisplayed = false this.isMenuDisplayed = false
} }
this.router.events.subscribe( this.router.events.subscribe(
e => { e => {
// User clicked on a link in the menu, change the page // User clicked on a link in the menu, change the page
if (e instanceof GuardsCheckStart && isInMobileView()) { if (e instanceof GuardsCheckStart && isInSmallView()) {
this.isMenuDisplayed = false this.isMenuDisplayed = false
} }
} }

View File

@ -2,7 +2,7 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import 'rxjs/add/operator/debounceTime' import 'rxjs/add/operator/debounceTime'
import 'rxjs/add/operator/distinctUntilChanged' import 'rxjs/add/operator/distinctUntilChanged'
import { isInMobileView } from '@app/shared/misc/utils' import { isInSmallView } from '@app/shared/misc/utils'
import { MarkdownService } from '@app/videos/shared' import { MarkdownService } from '@app/videos/shared'
import { Subject } from 'rxjs/Subject' import { Subject } from 'rxjs/Subject'
import truncate from 'lodash-es/truncate' import truncate from 'lodash-es/truncate'
@ -74,7 +74,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
} }
arePreviewsDisplayed () { arePreviewsDisplayed () {
return isInMobileView() === false return isInSmallView() === false
} }
private updateDescriptionPreviews () { private updateDescriptionPreviews () {

View File

@ -55,15 +55,20 @@ function dateToHuman (date: string) {
return datePipe.transform(date, 'medium') return datePipe.transform(date, 'medium')
} }
function isInMobileView () { function isInSmallView () {
return window.innerWidth < 600 return window.innerWidth < 600
} }
function isInMobileView () {
return window.innerWidth < 500
}
export { export {
viewportHeight, viewportHeight,
getParameterByName, getParameterByName,
populateAsyncUserVideoChannels, populateAsyncUserVideoChannels,
getAbsoluteAPIUrl, getAbsoluteAPIUrl,
dateToHuman, dateToHuman,
isInSmallView,
isInMobileView isInMobileView
} }

View File

@ -6,23 +6,29 @@
} }
} }
@media screen and (max-width: 400px) and (min-resolution: 1.5dppx) { @media screen and (max-width: 500px) {
.videos { .videos {
text-align: center; text-align: center;
/deep/ .video-miniature { /deep/ .video-miniature {
padding-right: 0; padding-right: 0;
height: 215px; height: auto;
width: 100%; width: 100%;
margin-bottom: 20px;
.video-miniature-information { .video-miniature-information {
width: 100%; width: 100% !important;
span {
width: 100%;
}
} }
/deep/ .video-thumbnail { /deep/ .video-thumbnail {
width: 100%; width: 100%;
img { img {
height: auto;
width: 100%; width: 100%;
} }
} }

View File

@ -1,5 +1,6 @@
import { OnInit } from '@angular/core' import { OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { isInMobileView, isInSmallView } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
import { Observable } from 'rxjs/Observable' import { Observable } from 'rxjs/Observable'
import { AuthService } from '../../core/auth' import { AuthService } from '../../core/auth'
@ -42,6 +43,10 @@ export abstract class AbstractVideoList implements OnInit {
const routeParams = this.route.snapshot.params const routeParams = this.route.snapshot.params
this.loadRouteParams(routeParams) this.loadRouteParams(routeParams)
if (isInMobileView()) {
this.pagination.itemsPerPage = 5
}
if (this.loadOnInit === true) this.loadMoreVideos('after') if (this.loadOnInit === true) this.loadMoreVideos('after')
} }

View File

@ -2,7 +2,7 @@
[routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name"
class="video-thumbnail" class="video-thumbnail"
> >
<img [attr.src]="video.thumbnailUrl" alt="video thumbnail" [ngClass]="{ 'blur-filter': nsfw }" /> <img [attr.src]="getImageUrl()" alt="video thumbnail" [ngClass]="{ 'blur-filter': nsfw }" />
<div class="video-thumbnail-overlay"> <div class="video-thumbnail-overlay">
{{ video.durationLabel }} {{ video.durationLabel }}

View File

@ -11,9 +11,14 @@
text-decoration: none !important; text-decoration: none !important;
} }
img.blur-filter { img {
filter: blur(5px); width: $video-thumbnail-width;
transform : scale(1.03); height: $video-thumbnail-height;
&.blur-filter {
filter: blur(5px);
transform : scale(1.03);
}
} }
.video-thumbnail-overlay { .video-thumbnail-overlay {

View File

@ -1,4 +1,5 @@
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { isInMobileView } from '@app/shared/misc/utils'
import { Video } from './video.model' import { Video } from './video.model'
@Component({ @Component({
@ -9,4 +10,14 @@ import { Video } from './video.model'
export class VideoThumbnailComponent { export class VideoThumbnailComponent {
@Input() video: Video @Input() video: Video
@Input() nsfw = false @Input() nsfw = false
getImageUrl () {
if (!this.video) return ''
if (isInMobileView()) {
return this.video.previewUrl
}
return this.video.thumbnailUrl
}
} }

View File

@ -1,5 +1,5 @@
{ {
"background_color": "gray", "background_color": "white",
"description": "A federated video streaming platform using P2P", "description": "A federated video streaming platform using P2P",
"display": "fullscreen", "display": "fullscreen",
"orientation": "portrait", "orientation": "portrait",

View File

@ -27,3 +27,6 @@ $footer-height: 30px;
$footer-margin: 30px; $footer-margin: 30px;
$footer-border-color: $header-border-color; $footer-border-color: $header-border-color;
$video-thumbnail-height: 110px;
$video-thumbnail-width: 200px;