Skip to content

Comments

virtualscroll#1

Open
versusvirus wants to merge 27 commits intomasterfrom
vvd/virtualscroll
Open

virtualscroll#1
versusvirus wants to merge 27 commits intomasterfrom
vvd/virtualscroll

Conversation

@versusvirus
Copy link
Collaborator

No description provided.

// TODO в этом методе нужно рассчитывать необходимо ли производить догрузку данных
}

export function recalcFromScrollTop(heights: IHeights): IRange {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это вообще нелогично.
пересчитать от скроллтопа - а передается вся латуха непонятно чего

}
}

export function recalcFromItemHeightProperty(index: number, heights: IHeights): IRange {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут тоже ничего не понятно
ты уверен, что нужен весь IHeight?
и что такое index?

}
}

export function recalcToDirection(direction: IDirection, range: IRange, segmentSize: number, heights: IHeights): IRange {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь точно нужен весь IHeight?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у виртуального скролла нет вообще никакого состояния?
есть же какая то инициализация
а потом его начинают менять
разве не так?

scroll.ts Outdated
if (scrollUtils.canScrollToItem(getIndexById(id), this.range, this.heights)) {
scrollToElement(element);
} else {
await this.applyIndexes(VS.recalcFromIndex(getIndexById(id)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему scroll вообще должен зависеть от виртуального скроллинга?
кто вызывает ScrollToItem?
когда?
что если он научиться возвращать результат, и вернет false
если не может проскроллить
то кто тогда мог бы сдвигать виртуальный скролл?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.Потому что могут вызвать скролл к имеющейся, но не отрисованной записи
2.Прикладники, scrollViewer, календарь и прочие
3.Когда нужно прибить элемент к верхушке вьюпорта
4.Возможно стоит это сделать

scroll.ts Outdated
class Scroll {
protected _beforeMount(options): void {
if (options.itemHeightProperty) {
this.applyIndexes(VS.recalcFromItemHeightProperty(options.activeElement, this.heights));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а что с this.heights? это одна из самых интересных штук
когда она меняется? и как?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

интересно, почему называется recalc. если это первый calc?

scroll.ts Outdated

class Scroll {
protected _beforeMount(options): void {
if (options.itemHeightProperty) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это что?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и почему вилка такая? почему способ расчета виртуального скролла зависит от параметра конструктора?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это нужно для отрисовки по заранее вычисленным высотам

}
}

export function recalcToDirection(direction: IDirection, range: IRange, segmentSize: number, heights: IHeights): IRange {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у виртуального скролла нет вообще никакого состояния?
есть же какая то инициализация
а потом его начинают менять
разве не так?

scroll.ts Outdated
}

private recalcToDirection(triggerName): void {
this.applyIndexes(VS.recalcToDirection(triggerName, this.range, this._options.segmentSize, this.heights));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты уверен, что в этом классе нужен this.range?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я ниже писал, точно ли не нужен никакой класс
вроде как, если был бы класс -то диапазон мог бы храниться в нем

@@ -0,0 +1,163 @@
interface IHeights {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

подробно опиши что это такое и зачем

// Высота вьюпорта
viewport: number;
// Высота позиции скролла
scrollTop: number;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убери от сюда scrollTop

* @remark
* Вызывается при смещении скролла за счет движения скроллбара
*/
updateRangeByScrollTop(): IRange {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

передай сюда scrollTop

scroll.ts Outdated
*/
private _scrollMove(params: IScrollEventParams): void {
this._scrollTop = params.scrollTop;
const activeElementIndex = scrollUtils.getActiveElementIndex(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что это такое?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я думал, что при scrollMove нужно менять диапазон. а где это?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно, это не движения scrollBar.

Это высчитывание активного элемента(чтобы маркер в карточке контрагента при скролле передвигался)

scroll.ts Outdated
if (triggerState && this._options.virtualScroll) {
this._recalcToDirection(triggerName);
} else {
this._notifyLoadMore(triggerName);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот тут опять нелогично. 3 подряд _notifyLoadMore
почему бы не сделать так, чтобы виртуальный скролл был всегда
просто размер виртуального окна сделать по всей высоте
тогда не нужно будет расставлять кучу условий

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможно эта идея неплохая

scroll.ts Outdated
* @param direction
* @private
*/
private _checkEdgeReached(direction: IDirection): boolean {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эту логику нужно перенести в virtualScroll
спрашивать его, где находится виртуальное окно: сверху или снизу?

return this._range;
}

get itemsHeightsData() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем передавать itemsHeightsData а потом получать его?
он же никак не модифицируется и не рассчитывается
в итоге в месте вызова непонятная лишняя связь между модулями

}
}

getPlaceholders(): IPlaceholders {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это нужно объединять с IRange

scroll.ts Outdated
* @param triggerName
* @param triggerState
*/
private _triggerVisibilityChanged(triggerName: IDirection, triggerState: boolean): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что за state?

scroll.ts Outdated
if (index) {
return new Promise((resolve, reject) => {
if (this._virtualScroll.canScrollToItem(index)) {
this._scrollToPosition(this._virtualScroll.itemsOffsets[index]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убери itemsOffests

let {start, stop} = this._range;

if (segmentSize) {
const quantity = VirtualScroll.getItemsToHideQuantity(direction, this._range, this._containerHeightsData, itemsHeightsData);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переделать в приватный метод

scroll.ts Outdated
* Вычисляет реальные высоты элемента
* @param container
*/
private static getItemsHeightsDataByContainer(container: HTMLElement): IItemsHeights {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрать вычисления в virtualScroll
добавить проверку на range

*/
private _viewportResize(params: IScrollEventParams): void {
this._virtualScroll.resizeViewport(params.viewportHeight, Scroll.getItemsHeightsDataByContainer(this._children.itemsContainer));
this._updateTriggerOffset(params.scrollHeight, params.viewportHeight);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

внутри меняется virtualScroll
почему не сделать это за 1 раз?

}

protected _afterMount(): void {
this.__mounted = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не понимаю зачем это
неужели какой-то код начинает выполняться раньше, чем этот флаг?

protected _afterRender(): void {
if (this._virtualScroll.rangeChanged) {
this._virtualScroll.updateItemsHeights(this._children.itemsContainer);
this._virtualScroll.rangeChanged = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты сказал, что удалишь этот флаг

private _viewportResize(params: IScrollEventParams): void {
this._updateTriggerOffset(params.scrollHeight, params.viewportHeight);
this._virtualScroll.resizeViewport(params.viewportHeight, this._triggerOffset);
this._virtualScroll.updateItemsHeights(this._children.itemsContainer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты хотел сделать одним методом

private _viewResize(params: IScrollEventParams): void {
this._updateTriggerOffset(params.scrollHeight, params.viewportHeight);
this._virtualScroll.resizeView(params.scrollHeight, this._triggerOffset);
this._virtualScroll.updateItemsHeights(this._children.itemsContainer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

туда же

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

Successfully merging this pull request may close these issues.

2 participants