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

Functional sizeField for RecycleScroller's variable-size mode #848

Open
2 tasks done
ThEditor opened this issue Jan 1, 2024 · 3 comments
Open
2 tasks done

Functional sizeField for RecycleScroller's variable-size mode #848

ThEditor opened this issue Jan 1, 2024 · 3 comments

Comments

@ThEditor
Copy link

ThEditor commented Jan 1, 2024

Clear and concise description of the problem

When using recycle-scroller's variable size mode, a "sizeField" can be defined. This sizeField, however, can only be a constant number and not a function that outs a number. I have a component where sizes vary with respective to a scale parameter and hence, I need the sizeField to be a function (synchronous) that returns a number instead. (So that I can return something like defaultSize * scale)

Suggested solution

Currently, in variable size mode

current = items[i][field] || minItemSize

This can be replaced by

current = ((typeof items[i][field] === 'function') ? items[i][field]() : items[i][field]) || minItemSize;

Alternative

No response

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@ThEditor
Copy link
Author

ThEditor commented Jan 1, 2024

I can open a PR if you guys are willing to accept this change. (Also, I'm using Vue 2 in my project that requires this behavior)

Copy link
Owner

Akryum commented Jan 2, 2024

It would probably make more sense to accept a function for itemSize prop

@srackhall
Copy link

接受 prop 的函数可能更有意义itemSize

If this feature is really implemented, that would be great

This feature is indeed very practical

In addition, if "itemSize" can support CSS units other than px, then it should be more flexible.

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

3 participants