-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add useResizeObserver option #51
Conversation
packages/conveyer/src/Conveyer.ts
Outdated
@@ -454,6 +456,16 @@ class Conveyer extends Component<ConveyerEvents> { | |||
useNormalized: false, | |||
})); | |||
} | |||
if (!IS_IE && options.useResizeObserver) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than comparing with IS_IE
, compare with/without ResizeObserver.
packages/conveyer/src/Conveyer.ts
Outdated
|
||
entries.forEach((entry: ResizeObserverEntry) => { | ||
if (entry.target !== this._scrollAreaElement) { | ||
for (let i = 0; i < items.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to make items.length
a constant.
packages/conveyer/src/Conveyer.ts
Outdated
@@ -312,10 +316,22 @@ class Conveyer extends Component<ConveyerEvents> { | |||
public updateItems() { | |||
const scrollAreaElement = this._scrollAreaElement; | |||
const itemSelector = this._options.itemSelector; | |||
const childrenDiffer = this._childrenDiffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to use children differ. Rather than using classes/instances. Use the function `import { diff } from "@egjs/children-differ".
packages/conveyer/src/Conveyer.ts
Outdated
this.setItems(itemElements.map((el) => this._getItem(el))); | ||
|
||
if (resizeObserver){ | ||
const prevItemElements = this._itemElements; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be no need to create _itemElements
.
Use items.map(item => item.element)
.
Issue
#50
Details