Skip to content

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
Copy Markdown
Collaborator

No description provided.

Comment thread virtualscroll/controller.ts Outdated
Comment thread virtualscroll/controller.ts Outdated
// TODO в этом методе нужно рассчитывать необходимо ли производить догрузку данных
}

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

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
}
}

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

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
}
}

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

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts Outdated
if (scrollUtils.canScrollToItem(getIndexById(id), this.range, this.heights)) {
scrollToElement(element);
} else {
await this.applyIndexes(VS.recalcFromIndex(getIndexById(id)));
Copy link
Copy Markdown
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
Copy Markdown
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.Возможно стоит это сделать

Comment thread scroll.ts Outdated
class Scroll {
protected _beforeMount(options): void {
if (options.itemHeightProperty) {
this.applyIndexes(VS.recalcFromItemHeightProperty(options.activeElement, this.heights));
Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts Outdated

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

Choose a reason for hiding this comment

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

это что?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
}
}

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

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts Outdated
}

private recalcToDirection(triggerName): void {
this.applyIndexes(VS.recalcToDirection(triggerName, this.range, this._options.segmentSize, this.heights));
Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
@@ -0,0 +1,163 @@
interface IHeights {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/interfaces.ts Outdated
// Высота вьюпорта
viewport: number;
// Высота позиции скролла
scrollTop: number;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

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

Comment thread scroll.ts Outdated
if (triggerState && this._options.virtualScroll) {
this._recalcToDirection(triggerName);
} else {
this._notifyLoadMore(triggerName);
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
return this._range;
}

get itemsHeightsData() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread virtualscroll/controller.ts Outdated
}
}

getPlaceholders(): IPlaceholders {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

что за state?

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

Choose a reason for hiding this comment

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

убери itemsOffests

Comment thread virtualscroll/controller.ts Outdated
let {start, stop} = this._range;

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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts
}

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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread scroll.ts
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
Copy Markdown
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