mirror of
https://github.com/pinry/pinry.git
synced 2025-11-17 18:30:39 +01:00
Feature: Add pin-image show transition on opacity
This commit is contained in:
committed by
Isaac Bythewood
parent
5d86ef1e1d
commit
d3e30ca38f
@@ -10,17 +10,22 @@
|
|||||||
gutter=".gutter-sizer"
|
gutter=".gutter-sizer"
|
||||||
>
|
>
|
||||||
<template v-for="item in blocks">
|
<template v-for="item in blocks">
|
||||||
<div v-bind:key="item.id" v-masonry-tile class="grid">
|
<div v-bind:key="item.id"
|
||||||
|
v-masonry-tile
|
||||||
|
:class="item.class"
|
||||||
|
class="grid pin-masonry">
|
||||||
<div class="grid-sizer"></div>
|
<div class="grid-sizer"></div>
|
||||||
<div class="gutter-sizer"></div>
|
<div class="gutter-sizer"></div>
|
||||||
<div class="pin-card grid-item">
|
<div class="pin-card grid-item">
|
||||||
<img :src="item.url"
|
<img :src="item.url"
|
||||||
|
@load="onPinImageLoaded(item.id)"
|
||||||
@click="openPreview(item)"
|
@click="openPreview(item)"
|
||||||
alt="item.description"
|
alt="item.description"
|
||||||
:style="item.style"
|
:style="item.style"
|
||||||
class="pin-preview-image">
|
class="pin-preview-image">
|
||||||
<div class="pin-footer">
|
<div class="pin-footer">
|
||||||
<div class="description" v-show="item.description"><p>{{ item.description }}</p></div>
|
<div class="description" v-show="item.description"><p>{{ item.description }}</p>
|
||||||
|
</div>
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<div class="is-pulled-left">
|
<div class="is-pulled-left">
|
||||||
<img class="avatar" :src="item.avatar" alt="">
|
<img class="avatar" :src="item.avatar" alt="">
|
||||||
@@ -37,7 +42,8 @@
|
|||||||
in
|
in
|
||||||
<template v-for="tag in item.tags">
|
<template v-for="tag in item.tags">
|
||||||
<span v-bind:key="tag" class="pin-tag">
|
<span v-bind:key="tag" class="pin-tag">
|
||||||
<router-link :to="{ name: 'tag', params: {tag: tag} }" params="{tag: tag}">{{ tag }}</router-link>
|
<router-link :to="{ name: 'tag', params: {tag: tag} }"
|
||||||
|
params="{tag: tag}">{{ tag }}</router-link>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -79,6 +85,7 @@ function createImageItem(pin) {
|
|||||||
width: `${pin.image.thumbnail.width}px`,
|
width: `${pin.image.thumbnail.width}px`,
|
||||||
height: `${pin.image.thumbnail.height}px`,
|
height: `${pin.image.thumbnail.height}px`,
|
||||||
};
|
};
|
||||||
|
image.class = {};
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +98,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
blocks: [],
|
blocks: [],
|
||||||
|
blocksMap: {},
|
||||||
status: {
|
status: {
|
||||||
loading: false,
|
loading: false,
|
||||||
hasNext: true,
|
hasNext: true,
|
||||||
@@ -110,6 +118,11 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onPinImageLoaded(itemId) {
|
||||||
|
this.blocksMap[itemId].class = {
|
||||||
|
'image-loaded': true,
|
||||||
|
};
|
||||||
|
},
|
||||||
registerScrollEvent() {
|
registerScrollEvent() {
|
||||||
const self = this;
|
const self = this;
|
||||||
scroll.bindScroll2Bottom(
|
scroll.bindScroll2Bottom(
|
||||||
@@ -125,8 +138,9 @@ export default {
|
|||||||
const blocks = [];
|
const blocks = [];
|
||||||
results.forEach(
|
results.forEach(
|
||||||
(pin) => {
|
(pin) => {
|
||||||
|
const item = createImageItem(pin);
|
||||||
blocks.push(
|
blocks.push(
|
||||||
createImageItem(pin),
|
item,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -175,6 +189,9 @@ export default {
|
|||||||
(resp) => {
|
(resp) => {
|
||||||
const { results, next } = resp.data;
|
const { results, next } = resp.data;
|
||||||
let newBlocks = this.buildBlocks(results);
|
let newBlocks = this.buildBlocks(results);
|
||||||
|
newBlocks.forEach(
|
||||||
|
(item) => { this.blocksMap[item.id] = item; },
|
||||||
|
);
|
||||||
newBlocks = this.blocks.concat(newBlocks);
|
newBlocks = this.blocks.concat(newBlocks);
|
||||||
this.blocks = newBlocks;
|
this.blocks = newBlocks;
|
||||||
this.status.offset = newBlocks.length;
|
this.status.offset = newBlocks.length;
|
||||||
@@ -202,6 +219,16 @@ export default {
|
|||||||
.gutter-sizer {
|
.gutter-sizer {
|
||||||
width: 15px;
|
width: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pin-image transition */
|
||||||
|
.pin-masonry.image-loaded{
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity .3s;
|
||||||
|
}
|
||||||
|
.pin-masonry {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* card */
|
/* card */
|
||||||
$pin-footer-position-fix: -6px;
|
$pin-footer-position-fix: -6px;
|
||||||
$avatar-width: 30px;
|
$avatar-width: 30px;
|
||||||
@@ -222,12 +249,20 @@ $avatar-height: 30px;
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin loader {
|
||||||
|
background: url('../assets/loader.gif');
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
.pin-card{
|
.pin-card{
|
||||||
.pin-preview-image {
|
.pin-preview-image {
|
||||||
cursor: zoom-in;
|
cursor: zoom-in;
|
||||||
}
|
}
|
||||||
> img {
|
> img {
|
||||||
|
background-color: white;
|
||||||
border-radius: 3px 3px 0 0;
|
border-radius: 3px 3px 0 0;
|
||||||
|
@include loader;
|
||||||
}
|
}
|
||||||
.avatar {
|
.avatar {
|
||||||
height: $avatar-height;
|
height: $avatar-height;
|
||||||
|
|||||||
Reference in New Issue
Block a user