Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The vertical gap of the elements are different. #30

Open
ihaichao opened this issue Jul 11, 2017 · 1 comment
Open

The vertical gap of the elements are different. #30

ihaichao opened this issue Jul 11, 2017 · 1 comment

Comments

@ihaichao
Copy link

762704fc-a24f-41fd-ae52-d6eba6b3f239

As the picture above shows, the height of the element bigger, the vertical gap of the element bigger.
Core code is below:

waterfall(
    :line-gap="260",
    :watch="list",
)
    waterfall-slot(
         v-for="(card, index) in list",
         :key="card.user.uid",
         :width="waterfallWidth",
         :height="waterfallHeight",
         :order="index"
     )
        canvas-card

I have saw the source code of vue-waterfall. I think the code of calculating position is below, but can't understand some code.

function reflow () {
  if (!this.$el) { return }
  let width = this.$el.clientWidth
  let metas = this.$children.map((slot) => slot.getMeta())
  metas.sort((a, b) => a.order - b.order)
  console.log('reflow-metas', metas)
  this.virtualRects = metas.map(() => ({}))  // can't understand
  console.log('virtualRects', this.virtualRects)
  calculate(this, metas, this.virtualRects)
  setTimeout(() => {
    if (isScrollBarVisibilityChange(this.$el, width)) {
      calculate(this, metas, this.virtualRects)
    }
    this.style.overflow = 'hidden'
    render(this.virtualRects, metas)
    this.$emit('reflowed', this)
  }, 0)
}

I print some data on the console, I don't konw why the this.virtualRects is shown as below:
d4e33739-6d8f-41ef-badc-9c6460b7a781

3e6629d6-9703-4a9d-8bfc-8efd57f96374

Could you give me some advice?

@YDSS
Copy link

YDSS commented Sep 29, 2017

@ihaichao you should focus on where to use this.virtualRects. this.virtualRects is a variable to store all of waterfall-slot's rect info.

Where you can't understand this.virtualRects = metas.map(() => ({})) is just for initializing this.virtualRects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants