mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 10:50:38 +01:00
Feature: Now the-end and container-height display correctlly
This commit is contained in:
committed by
Isaac Bythewood
parent
765a188717
commit
e280c0e6ca
@@ -24,7 +24,6 @@ function EventCounter(countEvent, triggerEvent, triggerTimes) {
|
|||||||
countEvent,
|
countEvent,
|
||||||
function() {
|
function() {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
console.log(self.id, self.count);
|
|
||||||
if (self.count >= self.targetCount) {
|
if (self.count >= self.targetCount) {
|
||||||
events.$emit(triggerEvent)
|
events.$emit(triggerEvent)
|
||||||
}
|
}
|
||||||
@@ -83,6 +82,18 @@ function HeightTable(blockMargin) {
|
|||||||
self.getHeightOffset = function (index, rowSize) {
|
self.getHeightOffset = function (index, rowSize) {
|
||||||
return getHeightOffset(self, index, rowSize);
|
return getHeightOffset(self, index, rowSize);
|
||||||
};
|
};
|
||||||
|
self.getMaxHeight = function(rowSize, blockMargin) {
|
||||||
|
var size = Object.keys(self.data).length;
|
||||||
|
var heightArray = [];
|
||||||
|
for (var column = 0; column < rowSize; column ++) {
|
||||||
|
heightArray.push(0);
|
||||||
|
}
|
||||||
|
for (var index = 0; index < size; index++) {
|
||||||
|
var column = index % rowSize;
|
||||||
|
heightArray[column] = heightArray[column] + self.get(index) + blockMargin;
|
||||||
|
}
|
||||||
|
return Math.max(...heightArray);
|
||||||
|
};
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,13 +122,15 @@ Vue.component('pin', {
|
|||||||
this.reflow();
|
this.reflow();
|
||||||
this.$emit("rendered", {index: this.index, height: this.height});
|
this.$emit("rendered", {index: this.index, height: this.height});
|
||||||
},
|
},
|
||||||
|
updated: function() {
|
||||||
|
events.$emit(eventsName.pinReflowDone);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reflow: function() {
|
reflow: function() {
|
||||||
this.heightOffset = this.heightTable.getHeightOffset(this.index, this.args.rowSize);
|
this.heightOffset = this.heightTable.getHeightOffset(this.index, this.args.rowSize);
|
||||||
this.imageStyle = this.getImageStyle();
|
this.imageStyle = this.getImageStyle();
|
||||||
this.pinStyle = this.getPinStyle();
|
this.pinStyle = this.getPinStyle();
|
||||||
this.height = this.getTextHeight() + this.pin.image.thumbnail.height;
|
this.height = this.getTextHeight() + this.pin.image.thumbnail.height;
|
||||||
events.$emit(eventsName.pinReflowDone);
|
|
||||||
},
|
},
|
||||||
getImageStyle: function() {
|
getImageStyle: function() {
|
||||||
return {
|
return {
|
||||||
@@ -192,6 +205,7 @@ Vue.component('pin-container', {
|
|||||||
"pins": [],
|
"pins": [],
|
||||||
"heightTable": [],
|
"heightTable": [],
|
||||||
"counter": null,
|
"counter": null,
|
||||||
|
"containerStyle": null,
|
||||||
status: {
|
status: {
|
||||||
loading: true,
|
loading: true,
|
||||||
hasNext: true,
|
hasNext: true,
|
||||||
@@ -220,7 +234,13 @@ Vue.component('pin-container', {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateContainerStyle: function() {
|
updateContainerStyle: function() {
|
||||||
|
var height = this.heightTable.getMaxHeight(
|
||||||
|
this.args.rowSize,
|
||||||
|
this.args.blockMargin,
|
||||||
|
);
|
||||||
|
this.containerStyle = {
|
||||||
|
height: height + "px",
|
||||||
|
};
|
||||||
},
|
},
|
||||||
loadMore() {
|
loadMore() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|||||||
@@ -8,5 +8,7 @@
|
|||||||
>
|
>
|
||||||
</pin-container>
|
</pin-container>
|
||||||
<div v-show="loading" class="spinner"></div>
|
<div v-show="loading" class="spinner"></div>
|
||||||
<div v-show="noMore">— End —</div>
|
<template v-if="noMore">
|
||||||
|
<div id="the-end">— End —</div>
|
||||||
|
</template>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
|
|
||||||
<script type="text/x-template" id="pin-container-template">
|
<script type="text/x-template" id="pin-container-template">
|
||||||
<div id="pins">
|
<div id="pins" :style="containerStyle">
|
||||||
<template v-for="(item, index) in pins">
|
<template v-for="(item, index) in pins">
|
||||||
<pin
|
<pin
|
||||||
:pin="item"
|
:pin="item"
|
||||||
|
|||||||
Reference in New Issue
Block a user