Skip to content

Padding should be considered when calculating columns #37

@sogehige

Description

@sogehige

In several cases I have 1 extra column when padding is used

I solved it with, but it is just workaround for me

diff --git a/node_modules/vue-masonry-wall/src/vue-masonry-wall.vue b/node_modules/vue-masonry-wall/src/vue-masonry-wall.vue
index 5400ef7..4a97dbd 100644
--- a/node_modules/vue-masonry-wall/src/vue-masonry-wall.vue
+++ b/node_modules/vue-masonry-wall/src/vue-masonry-wall.vue
@@ -185,7 +185,7 @@
        * @private internal component use
        */
       _columnSize() {
-        const length = Math.round(this.$refs.wall.scrollWidth / this._options.width)
+        const length = Math.round(this.$refs.wall.scrollWidth / (this._options.width + this._options.padding.default * 2))
         if (length < 1) return 1
         return length
       },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions