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

View File

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

View File

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

View File

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