-
Notifications
You must be signed in to change notification settings - Fork 66
Add ember-flexberry-infinite-scroll info #219
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
Open
TeterinaSvetlana
wants to merge
5
commits into
master
Choose a base branch
from
add-ember-flexberry-infinite-scroll-info
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...flexberry-ember/3.x/additional-addons/ef3_ember_flexberry_infinite_scroll.ru.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| --- | ||
| title: Аддон Ember flexberry infinite scroll | ||
| sidebar: flexberry-ember-3_sidebar | ||
| keywords: Ember Flexberry infinite scroll | ||
| toc: true | ||
| permalink: ru/ef3_ember_flexberry_infinite_scroll.html | ||
| lang: ru | ||
| summary: Описание аддона Ember flexberry infinite scroll | ||
| --- | ||
|
|
||
| ## Описание аддона | ||
|
|
||
| [`ember-flexberry-infinite-scroll`](https://github.com/Flexberry/ember-flexberry-infinite-scroll) - аддон для [ember-flexberry](https://github.com/Flexberry/ember-flexberry/tree/develop) с компонентом бесконечной прокрутки. | ||
|
|
||
| ## Установка | ||
|
|
||
| ```cmd | ||
| ember install ember-flexberry-infinite-scroll | ||
| ``` | ||
|
|
||
| Требуется версия node 12 или выше. | ||
|
|
||
| ## Использование | ||
|
|
||
| В шаблоне для использования компонента прописать: | ||
|
|
||
| ```hbs | ||
| {{flexberry-infinite-scroll | ||
| modelProjection=modelProjection | ||
| content=infiniteModel | ||
| lastReached=(action "lastReached") | ||
| estimateRowHeight=20 | ||
| bufferSize=1 | ||
| }} | ||
TeterinaSvetlana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| где: | ||
|
|
||
| * `modelProjection` - объект проекции, где определены отображаемые на списке свойства модели. | ||
| * `infiniteModel` - массив записей из модели, отображаемых в данных момент. | ||
| * `estimateRowHeight` - высота ячеек таблицы компонента. | ||
| * `bufferSize` - сколько дополнительных строк (сверх видимых) должно быть загружено и отображено (помогает сгладить переходы между страницами и обеспечивает более плавную прокрутку). | ||
|
|
||
| В контроллере прописываем вычислимое свойство записей модели и экшен догрузки `lastReached`. | ||
|
|
||
| Событие `lastReached` срабатывает, когда пользователь прокручивает таблицу до последней видимой строки. | ||
| Это позволяет обнаружить, когда пользователь достиг конца таблицы, и загрузить дополнительные данные, чтобы продолжить отображение. | ||
|
|
||
| Контроллер может выглядеть так: | ||
|
|
||
| ```js | ||
| import Controller from '@ember/controller'; | ||
| import { computed } from '@ember/object'; | ||
| import Builder from 'ember-flexberry-data/query/builder'; | ||
|
|
||
| export default Controller.extend({ | ||
|
|
||
| infiniteModel: computed('model', function() { | ||
| return this.get('model').toArray(); | ||
| }), | ||
|
|
||
| actions: { | ||
| lastReached() { | ||
| let infiniteModel = this.get('infiniteModel'); | ||
| if (this.get('model.meta.count') > infiniteModel.length) { | ||
| const modelName = this.get('modelName'); // название модели строкой | ||
| const projectionName = this.get('projectionName'); // название проекции строкой | ||
| const store = this.store; | ||
| const builder = new Builder(store) | ||
| .from(modelName) | ||
| .selectByProjection(projectionName) | ||
| .top(15) | ||
| .skip(infiniteModel.length) | ||
| .orderBy('name asc') | ||
| .count(); | ||
|
|
||
| return store.query(modelName, builder.build()).then((result) => { | ||
| infiniteModel.pushObjects(result.toArray()); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| ``` | ||
TeterinaSvetlana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.