mirror of
https://github.com/pinry/pinry.git
synced 2025-11-16 01:45:51 +01:00
Feature: Flow by height-offset now works well
This commit is contained in:
committed by
Isaac Bythewood
parent
44ed242970
commit
6df4a90d8a
@@ -30,10 +30,9 @@ function HeightTable(rowSize) {
|
||||
return 0;
|
||||
}
|
||||
var height = 0;
|
||||
for (var index = 0; index += rowSize; index < indexOfElement) {
|
||||
for (var index = 0; index < indexOfElement; index += rowSize) {
|
||||
var value = obj.get(index);
|
||||
if (value === null) {
|
||||
console.log("Get null value for index: " + index);
|
||||
return null
|
||||
}
|
||||
height += value;
|
||||
@@ -64,16 +63,17 @@ Vue.component('pin', {
|
||||
'imageStyle': null,
|
||||
'pinStyle': null,
|
||||
'height': null,
|
||||
'heightOffset': null,
|
||||
}
|
||||
},
|
||||
props: ['pin', 'args', 'index', 'heightOffset'],
|
||||
props: ['pin', 'args', 'index', 'heightTable'],
|
||||
template: '#pin-template',
|
||||
mounted: function() {
|
||||
this.heightOffset = this.heightTable.getHeightOffset(this.index);
|
||||
this.imageStyle = this.getImageStyle();
|
||||
this.pinStyle = this.getPinStyle();
|
||||
this.height = this.getTextHeight();
|
||||
console.log(this.height);
|
||||
this.$emit("rendered", {index: this.index, height: this.height})
|
||||
this.height = this.getTextHeight() + this.pin.image.thumbnail.height;
|
||||
this.$emit("rendered", {index: this.index, height: this.height});
|
||||
},
|
||||
methods: {
|
||||
getImageStyle: function() {
|
||||
@@ -112,7 +112,7 @@ Vue.component('pin', {
|
||||
marginTop = 0;
|
||||
} else {
|
||||
var lineNumber = getLineNumber(self.args.rowSize, self.index);
|
||||
marginTop = self.args.blockMargin + (self.args.blockMargin + 300) * lineNumber;
|
||||
marginTop = (self.args.blockMargin + self.heightOffset) * lineNumber;
|
||||
}
|
||||
|
||||
if (isFirstOne(self.args.rowSize, self.index)) {
|
||||
@@ -140,7 +140,7 @@ Vue.component('pin', {
|
||||
return "/pins/tags/" + tag + "/"
|
||||
},
|
||||
getTextHeight: function() {
|
||||
var element = this.$el;
|
||||
var element = this.$el.querySelector(".pin-description");
|
||||
var height = element.getBoundingClientRect().height;
|
||||
return height
|
||||
},
|
||||
@@ -165,6 +165,7 @@ Vue.component('pin-container', {
|
||||
},
|
||||
template: "#pin-container-template",
|
||||
created: function() {
|
||||
this.heightTable = HeightTable(this.rowSize);
|
||||
this.$emit("loading");
|
||||
var self = this;
|
||||
var offset = 0;
|
||||
@@ -180,16 +181,12 @@ Vue.component('pin-container', {
|
||||
mounted: function() {
|
||||
this.reflow();
|
||||
},
|
||||
updated: function() {
|
||||
this.reflow();
|
||||
},
|
||||
methods: {
|
||||
updateChildHeight: function(childArg) {
|
||||
this.heightTable.set(childArg.index, childArg.height);
|
||||
},
|
||||
reflow: function() {
|
||||
this.updateArguments();
|
||||
this.heightTable = HeightTable(this.rowSize);
|
||||
},
|
||||
updateArguments: function() {
|
||||
var blockContainer = this.$el;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
:pin="item"
|
||||
:index="index"
|
||||
:args="args"
|
||||
:heightTable="heightTable"
|
||||
v-on:rendered="updateChildHeight"
|
||||
></pin>
|
||||
</template>
|
||||
@@ -38,7 +39,7 @@
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div>
|
||||
<div class="pin-description">
|
||||
<p v-if="pin.description">{{ pin.description }}</p>
|
||||
<div class="pin-footer clearfix">
|
||||
<div class="avatar pull-left">
|
||||
|
||||
Reference in New Issue
Block a user