Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace blur with average color in video background in all cases
For consistency between browsers now the average color is shown in all
cases, even if CSS blur filters work fine in Firefox.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Jan 25, 2021
commit b96a86177ee8598874f76d9f9f8bc092e842c8a5
51 changes: 8 additions & 43 deletions src/components/CallView/shared/VideoBackground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
class="observer"
@notify="setBlur" />
</div>
<img
v-if="hasPicture && !useAverageColor"
ref="backgroundImage"
:src="backgroundImageUrl"
:style="backgroundStyle"
class="video-background__picture"
alt="">
<div v-else
<div
:style="{'background-color': backgroundColor }"
class="video-background" />
</div>
Expand All @@ -49,7 +42,6 @@ import usernameToColor from '@nextcloud/vue/dist/Functions/usernameToColor'
import { generateUrl } from '@nextcloud/router'
import { ResizeObserver } from 'vue-resize'
import { getBuilder } from '@nextcloud/browser-storage'
import browserCheck from '../../../mixins/browserCheck'

const browserStorage = getBuilder('nextcloud').persist().build()

Expand All @@ -72,10 +64,6 @@ export default {
ResizeObserver,
},

mixins: [
browserCheck,
],

props: {
displayName: {
type: String,
Expand All @@ -94,21 +82,20 @@ export default {
data() {
return {
hasPicture: false,
useAverageColor: false,
blur: 0,
}
},

computed: {
backgroundImageAverageColor() {
if (!this.backgroundImageUrlToAverage) {
if (!this.backgroundImageUrl) {
return ''
}

return this.$store.getters.getCachedBackgroundImageAverageColor(this.backgroundImageUrlToAverage)
return this.$store.getters.getCachedBackgroundImageAverageColor(this.backgroundImageUrl)
},
backgroundColor() {
if (this.hasPicture && this.useAverageColor) {
if (this.hasPicture) {
return this.backgroundImageAverageColor
}

Expand All @@ -131,31 +118,13 @@ export default {
backgroundBlur() {
return this.gridBlur ? this.gridBlur : this.blur
},
backgroundStyle() {
if (this.useAverageColor) {
return {}
}

return {
filter: `blur(${this.backgroundBlur}px)`,
}
},
// Special computed property to combine the properties that should be
// watched to set (or not) the background image average color.
backgroundImageUrlToAverage() {
if (!this.useAverageColor) {
return null
}

return this.backgroundImageUrl
},
},

watch: {
backgroundImageUrlToAverage: {
backgroundImageUrl: {
immediate: true,
handler() {
if (!this.backgroundImageUrlToAverage) {
if (!this.backgroundImageUrl) {
return
}

Expand All @@ -164,9 +133,9 @@ export default {
return
}

average(this.backgroundImageUrlToAverage, { format: 'hex' }).then(color => {
average(this.backgroundImageUrl, { format: 'hex' }).then(color => {
this.$store.dispatch('setCachedBackgroundImageAverageColor', {
videoBackgroundId: this.backgroundImageUrlToAverage,
videoBackgroundId: this.backgroundImageUrl,
backgroundImageAverageColor: color,
})
})
Expand All @@ -175,10 +144,6 @@ export default {
},

async beforeMount() {
if (!this.isFirefox) {
this.useAverageColor = true
}

if (!this.user) {
return
}
Expand Down