Merge pull request #1485 from crazyserver/MOBILE-2558
MOBILE-2558 utils: Check scroll is not destroyed before performmain
commit
47f15ebf9d
|
@ -306,7 +306,8 @@ export class AddonCalendarListPage implements OnDestroy {
|
||||||
popover.onDidDismiss((course) => {
|
popover.onDidDismiss((course) => {
|
||||||
if (course) {
|
if (course) {
|
||||||
this.filter.course = course;
|
this.filter.course = course;
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
this.filteredEvents = this.getFilteredEvents();
|
this.filteredEvents = this.getFilteredEvents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -232,7 +232,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are at the bottom to scroll it after render.
|
// Check if we are at the bottom to scroll it after render.
|
||||||
this.scrollBottom = this.content.scrollHeight - this.content.scrollTop === this.content.contentHeight;
|
this.scrollBottom = this.domUtils.getScrollHeight(this.content) - this.domUtils.getScrollTop(this.content) ===
|
||||||
|
this.domUtils.getContentHeight(this.content);
|
||||||
|
|
||||||
if (this.messagesBeingSent > 0) {
|
if (this.messagesBeingSent > 0) {
|
||||||
// Ignore polling due to a race condition.
|
// Ignore polling due to a race condition.
|
||||||
|
@ -569,15 +570,15 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
// Wait for new content height to be calculated.
|
// Wait for new content height to be calculated.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Visible content size changed, maintain the bottom position.
|
// Visible content size changed, maintain the bottom position.
|
||||||
if (!this.viewDestroyed && this.content && this.content.contentHeight != this.oldContentHeight) {
|
if (!this.viewDestroyed && this.content && this.domUtils.getContentHeight(this.content) != this.oldContentHeight) {
|
||||||
if (!top) {
|
if (!top) {
|
||||||
top = this.content.getContentDimensions().scrollTop;
|
top = this.content.getContentDimensions().scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
top += this.oldContentHeight - this.content.contentHeight;
|
top += this.oldContentHeight - this.domUtils.getContentHeight(this.content);
|
||||||
this.oldContentHeight = this.content.contentHeight;
|
this.oldContentHeight = this.domUtils.getContentHeight(this.content);
|
||||||
|
|
||||||
this.content.scrollTo(0, top, 0);
|
this.domUtils.scrollTo(this.content, 0, top, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -591,7 +592,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
// Need a timeout to leave time to the view to be rendered.
|
// Need a timeout to leave time to the view to be rendered.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!this.viewDestroyed) {
|
if (!this.viewDestroyed) {
|
||||||
this.content.scrollToBottom(0);
|
this.domUtils.scrollToBottom(this.content, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.scrollBottom = false;
|
this.scrollBottom = false;
|
||||||
|
|
|
@ -155,7 +155,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
*/
|
*/
|
||||||
protected loadChapter(chapterId: string): Promise<void> {
|
protected loadChapter(chapterId: string): Promise<void> {
|
||||||
this.currentChapter = chapterId;
|
this.currentChapter = chapterId;
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return this.bookProvider.getChapterContent(this.contentsMap, chapterId, this.module.id).then((content) => {
|
return this.bookProvider.getChapterContent(this.contentsMap, chapterId, this.module.id).then((content) => {
|
||||||
this.chapterContent = content;
|
this.chapterContent = content;
|
||||||
|
|
|
@ -288,7 +288,7 @@ export class AddonModChatChatPage {
|
||||||
// Need a timeout to leave time to the view to be rendered.
|
// Need a timeout to leave time to the view to be rendered.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!this.viewDestroyed) {
|
if (!this.viewDestroyed) {
|
||||||
this.content.scrollToBottom(0);
|
this.domUtils.scrollToBottom(this.content, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -303,13 +303,13 @@ export class AddonModChatChatPage {
|
||||||
// Wait for new content height to be calculated.
|
// Wait for new content height to be calculated.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Visible content size changed, maintain the bottom position.
|
// Visible content size changed, maintain the bottom position.
|
||||||
if (!this.viewDestroyed && this.content && this.content.contentHeight != this.oldContentHeight) {
|
if (!this.viewDestroyed && this.content && this.domUtils.getContentHeight(this.content) != this.oldContentHeight) {
|
||||||
if (!top) {
|
if (!top) {
|
||||||
top = this.content.getContentDimensions().scrollTop;
|
top = this.content.getContentDimensions().scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
top += this.oldContentHeight - this.content.contentHeight;
|
top += this.oldContentHeight - this.domUtils.getContentHeight(this.content);
|
||||||
this.oldContentHeight = this.content.contentHeight;
|
this.oldContentHeight = this.domUtils.getContentHeight(this.content);
|
||||||
|
|
||||||
this.content.scrollTo(0, top, 0);
|
this.content.scrollTo(0, top, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
*/
|
*/
|
||||||
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
||||||
if (this.choice && syncEventData.choiceId == this.choice.id && syncEventData.userId == this.userId) {
|
if (this.choice && syncEventData.choiceId == this.choice.id && syncEventData.userId == this.userId) {
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
// Success!
|
// Success!
|
||||||
// Check completion since it could be configured to complete once the user answers the choice.
|
// Check completion since it could be configured to complete once the user answers the choice.
|
||||||
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
|
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completionstatus);
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
// Let's refresh the data.
|
// Let's refresh the data.
|
||||||
return this.refreshContent(false);
|
return this.refreshContent(false);
|
||||||
|
@ -374,7 +374,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
this.domUtils.showConfirm(this.translate.instant('core.areyousure')).then(() => {
|
this.domUtils.showConfirm(this.translate.instant('core.areyousure')).then(() => {
|
||||||
const modal = this.domUtils.showModalLoading('core.sending', true);
|
const modal = this.domUtils.showModalLoading('core.sending', true);
|
||||||
this.choiceProvider.deleteResponses(this.choice.id, this.choice.name, this.courseId).then(() => {
|
this.choiceProvider.deleteResponses(this.choice.id, this.choice.name, this.courseId).then(() => {
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
// Success! Let's refresh the data.
|
// Success! Let's refresh the data.
|
||||||
return this.refreshContent(false);
|
return this.refreshContent(false);
|
||||||
|
|
|
@ -142,7 +142,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
if (this.data && syncEventData.dataId == this.data.id && typeof syncEventData.entryId == 'undefined') {
|
if (this.data && syncEventData.dataId == this.data.id && typeof syncEventData.entryId == 'undefined') {
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
// Refresh the data.
|
// Refresh the data.
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,7 @@ export class AddonModDataEditPage {
|
||||||
*/
|
*/
|
||||||
protected scrollToFirstError(): void {
|
protected scrollToFirstError(): void {
|
||||||
if (!this.domUtils.scrollToElementBySelector(this.content, '.addon-data-error')) {
|
if (!this.domUtils.scrollToElementBySelector(this.content, '.addon-data-error')) {
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ export class AddonModDataEntryPage implements OnDestroy {
|
||||||
|
|
||||||
this.domUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true);
|
this.domUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
this.entryLoaded = true;
|
this.entryLoaded = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
||||||
if (this.feedback && syncEventData.feedbackId == this.feedback.id) {
|
if (this.feedback && syncEventData.feedbackId == this.feedback.id) {
|
||||||
// Refresh the data.
|
// Refresh the data.
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ export class AddonModFeedbackFormPage implements OnDestroy {
|
||||||
* @return {Promise<void>} Resolved when done.
|
* @return {Promise<void>} Resolved when done.
|
||||||
*/
|
*/
|
||||||
gotoPage(goPrevious: boolean): Promise<void> {
|
gotoPage(goPrevious: boolean): Promise<void> {
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
this.feedbackLoaded = false;
|
this.feedbackLoaded = false;
|
||||||
|
|
||||||
const responses = this.feedbackHelper.getPageItemsResponses(this.items),
|
const responses = this.feedbackHelper.getPageItemsResponses(this.items),
|
||||||
|
|
|
@ -366,7 +366,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
refreshPosts(sync?: boolean, showErrors?: boolean): Promise<any> {
|
refreshPosts(sync?: boolean, showErrors?: boolean): Promise<any> {
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
this.refreshIcon = 'spinner';
|
this.refreshIcon = 'spinner';
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
changeSort(type: SortType): Promise<any> {
|
changeSort(type: SortType): Promise<any> {
|
||||||
this.discussionLoaded = false;
|
this.discussionLoaded = false;
|
||||||
this.sort = type;
|
this.sort = type;
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return this.fetchPosts();
|
return this.fetchPosts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadingMessage = this.translate.instant('core.loading');
|
this.loadingMessage = this.translate.instant('core.loading');
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
this.switchMode(newMode);
|
this.switchMode(newMode);
|
||||||
|
|
||||||
if (this.fetchMode === 'search') {
|
if (this.fetchMode === 'search') {
|
||||||
|
|
|
@ -426,7 +426,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.refreshIcon = 'spinner';
|
this.refreshIcon = 'spinner';
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
this.refreshContent().finally(() => {
|
this.refreshContent().finally(() => {
|
||||||
|
@ -488,7 +488,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.quizData && syncEventData.quizId == this.quizData.id) {
|
if (this.quizData && syncEventData.quizId == this.quizData.id) {
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,11 +182,11 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy {
|
||||||
scrollLeft = scrollElement.scrollLeft || 0;
|
scrollLeft = scrollElement.scrollLeft || 0;
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.content.scrollToTop(); // Scroll top so the spinner is seen.
|
this.domUtils.scrollToTop(this.content); // Scroll top so the spinner is seen.
|
||||||
|
|
||||||
return this.loadPage(this.attempt.currentpage).finally(() => {
|
return this.loadPage(this.attempt.currentpage).finally(() => {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.content.scrollTo(scrollLeft, scrollTop);
|
this.domUtils.scrollTo(this.content, scrollLeft, scrollTop);
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
|
@ -222,7 +222,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
// First try to save the attempt data. We only save it if we're not seeing the summary.
|
// First try to save the attempt data. We only save it if we're not seeing the summary.
|
||||||
const promise = this.showSummary ? Promise.resolve() : this.processAttempt(false, false);
|
const promise = this.showSummary ? Promise.resolve() : this.processAttempt(false, false);
|
||||||
|
|
|
@ -104,7 +104,7 @@ export class AddonModQuizReviewPage implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
this.loadPage(page).catch((error) => {
|
this.loadPage(page).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquestions', true);
|
this.domUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquestions', true);
|
||||||
|
|
|
@ -165,7 +165,7 @@ export class AddonModWorkshopIndexComponent extends CoreCourseModuleMainActivity
|
||||||
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
protected isRefreshSyncNeeded(syncEventData: any): boolean {
|
||||||
if (this.workshop && syncEventData.workshopId == this.workshop.id) {
|
if (this.workshop && syncEventData.workshopId == this.workshop.id) {
|
||||||
// Refresh the data.
|
// Refresh the data.
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
protected eventReceived(data: any): void {
|
protected eventReceived(data: any): void {
|
||||||
if (this.workshopId === data.workshopId) {
|
if (this.workshopId === data.workshopId) {
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.refreshAllData();
|
this.refreshAllData();
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class AddonNotesListComponent implements OnInit, OnDestroy {
|
||||||
this.refreshIcon = 'spinner';
|
this.refreshIcon = 'spinner';
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
|
|
||||||
this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
this.fetchNotes(false);
|
this.fetchNotes(false);
|
||||||
}
|
}
|
||||||
}, sitesProvider.getCurrentSiteId());
|
}, sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -141,7 +141,7 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy
|
||||||
const deferred = this.utils.promiseDefer();
|
const deferred = this.utils.promiseDefer();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const contentVisibleHeight = this.content.contentHeight - this.kbHeight;
|
const contentVisibleHeight = this.domUtils.getContentHeight(this.content) - this.kbHeight;
|
||||||
|
|
||||||
if (contentVisibleHeight <= 0) {
|
if (contentVisibleHeight <= 0) {
|
||||||
deferred.resolve(0);
|
deferred.resolve(0);
|
||||||
|
@ -164,7 +164,7 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Header is fixed, use the content to calculate the editor height.
|
// Header is fixed, use the content to calculate the editor height.
|
||||||
height = this.content.contentHeight - this.kbHeight - this.getSurroundingHeight(this.element);
|
height = this.domUtils.getContentHeight(this.content) - this.kbHeight - this.getSurroundingHeight(this.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > this.minHeight) {
|
if (height > this.minHeight) {
|
||||||
|
|
|
@ -162,7 +162,7 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
this.refreshIcon = 'spinner';
|
this.refreshIcon = 'spinner';
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return this.loadContent(false, sync, showErrors).finally(() => {
|
return this.loadContent(false, sync, showErrors).finally(() => {
|
||||||
this.refreshIcon = 'refresh';
|
this.refreshIcon = 'refresh';
|
||||||
|
@ -181,7 +181,7 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR
|
||||||
this.refreshIcon = 'spinner';
|
this.refreshIcon = 'spinner';
|
||||||
this.syncIcon = 'spinner';
|
this.syncIcon = 'spinner';
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.content && this.content.scrollToTop();
|
this.domUtils.scrollToTop(this.content);
|
||||||
|
|
||||||
return this.refreshContent(sync, showErrors);
|
return this.refreshContent(sync, showErrors);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ core-course-module {
|
||||||
core-format-text {
|
core-format-text {
|
||||||
flex-grow: 2;
|
flex-grow: 2;
|
||||||
}
|
}
|
||||||
.core-module-buttons {
|
.core-module-buttons,
|
||||||
|
.buttons.core-module-buttons {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
scrollLeft = scrollElement.scrollLeft || 0;
|
scrollLeft = scrollElement.scrollLeft || 0;
|
||||||
|
|
||||||
this.dataLoaded = false;
|
this.dataLoaded = false;
|
||||||
this.content.scrollToTop(); // Scroll top so the spinner is seen.
|
this.domUtils.scrollToTop(this.content); // Scroll top so the spinner is seen.
|
||||||
|
|
||||||
this.loadData().then(() => {
|
this.loadData().then(() => {
|
||||||
return this.formatComponent.doRefresh(undefined, undefined, true);
|
return this.formatComponent.doRefresh(undefined, undefined, true);
|
||||||
|
|
|
@ -717,6 +717,77 @@ export class CoreDomUtilsProvider {
|
||||||
return element.innerHTML;
|
return element.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll to somehere in the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @param {number} x The x-value to scroll to.
|
||||||
|
* @param {number} y The y-value to scroll to.
|
||||||
|
* @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
|
||||||
|
* @returns {Promise} Returns a promise which is resolved when the scroll has completed.
|
||||||
|
*/
|
||||||
|
scrollTo(content: Content, x: number, y: number, duration?: number, done?: Function): Promise<any> {
|
||||||
|
return content && content._scroll && content.scrollTo(x, y, duration, done);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll to Bottom of the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
|
||||||
|
* @returns {Promise} Returns a promise which is resolved when the scroll has completed.
|
||||||
|
*/
|
||||||
|
scrollToBottom(content: Content, duration?: number): Promise<any> {
|
||||||
|
return content && content._scroll && content.scrollToBottom(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll to Top of the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
|
||||||
|
* @returns {Promise} Returns a promise which is resolved when the scroll has completed.
|
||||||
|
*/
|
||||||
|
scrollToTop(content: Content, duration?: number): Promise<any> {
|
||||||
|
return content && content._scroll && content.scrollToTop(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns contentHeight of the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @return {number} Content contentHeight or 0.
|
||||||
|
*/
|
||||||
|
getContentHeight(content: Content): number {
|
||||||
|
return (content && content._scroll && content.contentHeight) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns scrollHeight of the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @return {number} Content scrollHeight or 0.
|
||||||
|
*/
|
||||||
|
getScrollHeight(content: Content): number {
|
||||||
|
return (content && content._scroll && content.scrollHeight) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns scrollTop of the content.
|
||||||
|
* Checks hidden property _scroll to avoid errors if view is not active.
|
||||||
|
*
|
||||||
|
* @param {Content} content Content where to execute the function.
|
||||||
|
* @return {number} Content scrollTop or 0.
|
||||||
|
*/
|
||||||
|
getScrollTop(content: Content): number {
|
||||||
|
return (content && content._scroll && content.scrollTop) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scroll to a certain element.
|
* Scroll to a certain element.
|
||||||
*
|
*
|
||||||
|
@ -731,7 +802,7 @@ export class CoreDomUtilsProvider {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content.scrollTo(position[0], position[1]);
|
this.scrollTo(content, position[0], position[1]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -750,7 +821,7 @@ export class CoreDomUtilsProvider {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content.scrollTo(position[0], position[1]);
|
this.scrollTo(content, position[0], position[1]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue