iceshrimp-legacy/src/web/app/desktop/tags/images-viewer.tag

46 lines
1.1 KiB
HTML
Raw Normal View History

2017-01-11 21:55:38 +01:00
<mk-images-viewer>
2017-01-11 22:03:49 +01:00
<div class="image" ref="view" onmousemove={ mousemove } style={ 'background-image: url(' + image.url + '?thumbnail' } onclick={ click }><img src={ image.url + '?thumbnail&size=512' } alt={ image.name } title={ image.name }/></div>
2017-02-19 04:31:53 +01:00
<style>
2017-01-11 21:55:38 +01:00
:scope
2016-12-28 23:49:51 +01:00
display block
2017-01-11 21:55:38 +01:00
overflow hidden
border-radius 4px
> .image
cursor zoom-in
> img
display block
max-height 256px
max-width 100%
margin 0 auto
&:hover
> img
visibility hidden
&:not(:hover)
background-image none !important
</style>
<script>
2017-02-21 12:34:54 +01:00
this.images = this.opts.images;
this.image = this.images[0];
2017-01-11 21:55:38 +01:00
2017-02-21 12:34:54 +01:00
this.mousemove = e => {
const rect = this.refs.view.getBoundingClientRect();
const mouseX = e.clientX - rect.left;
const mouseY = e.clientY - rect.top;
const xp = mouseX / this.refs.view.offsetWidth * 100;
const yp = mouseY / this.refs.view.offsetHeight * 100;
this.refs.view.style.backgroundPosition = xp + '% ' + yp + '%';
};
2017-01-11 21:55:38 +01:00
2017-02-20 02:34:57 +01:00
this.click = () => {
2017-02-21 12:34:54 +01:00
riot.mount(document.body.appendChild(document.createElement('mk-image-dialog')), {
image: this.image
});
};
2017-01-11 21:55:38 +01:00
</script>
</mk-images-viewer>