summaryrefslogtreecommitdiff
path: root/src/web/app
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-11 13:33:33 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-11 13:33:33 +0900
commite36a7081324b9e538ae40918072edd93ebc9b2cb (patch)
tree98983f6f3d37f55627f2fedcb6ebb7cde9b902a6 /src/web/app
parentFix bug (diff)
downloadsharkey-e36a7081324b9e538ae40918072edd93ebc9b2cb.tar.gz
sharkey-e36a7081324b9e538ae40918072edd93ebc9b2cb.tar.bz2
sharkey-e36a7081324b9e538ae40918072edd93ebc9b2cb.zip
#986
Diffstat (limited to 'src/web/app')
-rw-r--r--src/web/app/desktop/tags/drive/file.tag16
-rw-r--r--src/web/app/desktop/tags/images.tag13
-rw-r--r--src/web/app/mobile/tags/drive/file-viewer.tag7
-rw-r--r--src/web/app/mobile/tags/drive/file.tag6
-rw-r--r--src/web/app/mobile/tags/images.tag6
5 files changed, 43 insertions, 5 deletions
diff --git a/src/web/app/desktop/tags/drive/file.tag b/src/web/app/desktop/tags/drive/file.tag
index 0f019d95bf..8b3d36b3f3 100644
--- a/src/web/app/desktop/tags/drive/file.tag
+++ b/src/web/app/desktop/tags/drive/file.tag
@@ -5,7 +5,9 @@
<div class="label" if={ I.banner_id == file.id }><img src="/assets/label.svg"/>
<p>%i18n:desktop.tags.mk-drive-browser-file.banner%</p>
</div>
- <div class="thumbnail"><img src={ file.url + '?thumbnail&size=128' } alt=""/></div>
+ <div class="thumbnail" ref="thumbnail" style="background-color:{ file.properties.average_color ? 'rgb(' + file.properties.average_color.join(',') + ')' : 'transparent' }">
+ <img src={ file.url + '?thumbnail&size=128' } alt="" onload={ onload }/>
+ </div>
<p class="name"><span>{ file.name.lastIndexOf('.') != -1 ? file.name.substr(0, file.name.lastIndexOf('.')) : file.name }</span><span class="ext" if={ file.name.lastIndexOf('.') != -1 }>{ file.name.substr(file.name.lastIndexOf('.')) }</span></p>
<style>
:scope
@@ -139,6 +141,7 @@
</style>
<script>
+ import anime from 'animejs';
import bytesToSize from '../../../common/scripts/bytes-to-size';
this.mixin('i');
@@ -199,5 +202,16 @@
this.isDragging = false;
this.browser.isDragSource = false;
};
+
+ this.onload = () => {
+ if (this.file.properties.average_color) {
+ anime({
+ targets: this.refs.thumbnail,
+ backgroundColor: `rgba(${this.file.properties.average_color.join(',')}, 0)`,
+ duration: 100,
+ easing: 'linear'
+ });
+ }
+ };
</script>
</mk-drive-browser-file>
diff --git a/src/web/app/desktop/tags/images.tag b/src/web/app/desktop/tags/images.tag
index ce67d26a9f..5e4be481dc 100644
--- a/src/web/app/desktop/tags/images.tag
+++ b/src/web/app/desktop/tags/images.tag
@@ -53,7 +53,13 @@
</mk-images>
<mk-images-image>
- <a ref="view" href={ image.url } onmousemove={ mousemove } onmouseleave={ mouseleave } style={ 'background-image: url(' + image.url + '?thumbnail&size=512' } onclick={ click } title={ image.name }></a>
+ <a ref="view"
+ href={ image.url }
+ onmousemove={ mousemove }
+ onmouseleave={ mouseleave }
+ style={ styles }
+ onclick={ click }
+ title={ image.name }></a>
<style>
:scope
display block
@@ -74,6 +80,11 @@
</style>
<script>
this.image = this.opts.image;
+ this.styles = {
+ 'background-color': `rgb(${this.image.properties.average_color.join(',')})`,
+ 'background-image': `url(${this.image.url}?thumbnail&size=512)`
+ };
+ console.log(this.styles);
this.mousemove = e => {
const rect = this.refs.view.getBoundingClientRect();
diff --git a/src/web/app/mobile/tags/drive/file-viewer.tag b/src/web/app/mobile/tags/drive/file-viewer.tag
index 48fc83fa67..259873d95c 100644
--- a/src/web/app/mobile/tags/drive/file-viewer.tag
+++ b/src/web/app/mobile/tags/drive/file-viewer.tag
@@ -1,6 +1,11 @@
<mk-drive-file-viewer>
<div class="preview">
- <img if={ kind == 'image' } src={ file.url } alt={ file.name } title={ file.name } onload={ onImageLoaded } ref="img">
+ <img if={ kind == 'image' } ref="img"
+ src={ file.url }
+ alt={ file.name }
+ title={ file.name }
+ onload={ onImageLoaded }
+ style="background-color:rgb({ file.properties.average_color.join(',') })">
<virtual if={ kind != 'image' }>%fa:file%</virtual>
<footer if={ kind == 'image' && file.properties && file.properties.width && file.properties.height }>
<span class="size">
diff --git a/src/web/app/mobile/tags/drive/file.tag b/src/web/app/mobile/tags/drive/file.tag
index 196dd1141e..684df7dd08 100644
--- a/src/web/app/mobile/tags/drive/file.tag
+++ b/src/web/app/mobile/tags/drive/file.tag
@@ -1,7 +1,7 @@
<mk-drive-file data-is-selected={ isSelected }>
<a onclick={ onclick } href="/i/drive/file/{ file.id }">
<div class="container">
- <div class="thumbnail" style={ 'background-image: url(' + file.url + '?thumbnail&size=128)' }></div>
+ <div class="thumbnail" style={ thumbnail }></div>
<div class="body">
<p class="name"><span>{ file.name.lastIndexOf('.') != -1 ? file.name.substr(0, file.name.lastIndexOf('.')) : file.name }</span><span class="ext" if={ file.name.lastIndexOf('.') != -1 }>{ file.name.substr(file.name.lastIndexOf('.')) }</span></p>
<!--
@@ -132,6 +132,10 @@
this.browser = this.parent;
this.file = this.opts.file;
+ this.thumbnail = {
+ 'background-color': this.file.properties.average_color ? `rgb(${this.file.properties.average_color.join(',')})` : 'transparent',
+ 'background-image': `url(${this.file.url}?thumbnail&size=128)`
+ };
this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id);
this.browser.on('change-selection', selections => {
diff --git a/src/web/app/mobile/tags/images.tag b/src/web/app/mobile/tags/images.tag
index aaa80e4fd1..b200eefe7e 100644
--- a/src/web/app/mobile/tags/images.tag
+++ b/src/web/app/mobile/tags/images.tag
@@ -56,7 +56,7 @@
</mk-images>
<mk-images-image>
- <a ref="view" href={ image.url } target="_blank" style={ 'background-image: url(' + image.url + '?thumbnail&size=512' } title={ image.name }></a>
+ <a ref="view" href={ image.url } target="_blank" style={ styles } title={ image.name }></a>
<style>
:scope
display block
@@ -74,5 +74,9 @@
</style>
<script>
this.image = this.opts.image;
+ this.styles = {
+ 'background-color': `rgb(${this.image.properties.average_color.join(',')})`,
+ 'background-image': `url(${this.image.url}?thumbnail&size=512)`
+ };
</script>
</mk-images-image>