This commit is contained in:
syuilo 2017-12-11 13:33:33 +09:00
parent 9852c57b8f
commit e36a708132
8 changed files with 157 additions and 11 deletions

View file

@ -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>

View file

@ -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();