diff --git a/src/addons/badges/pages/issued-badge/issued-badge.html b/src/addons/badges/pages/issued-badge/issued-badge.html index 4e7ac334e..834845a06 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.html +++ b/src/addons/badges/pages/issued-badge/issued-badge.html @@ -9,242 +9,240 @@ - - - - - - - - - - - - {{ 'addon.badges.expired' | translate }} - - - - + + + + + + + + + + + {{ 'addon.badges.expired' | translate }} + + + + - + + + +

{{ 'addon.badges.recipientdetails' | translate}}

+
+
+ + +

{{ 'core.name' | translate}}

+

{{ user.fullname }}

+
+
+
+ + + -

{{ 'addon.badges.recipientdetails' | translate}}

+

{{ 'addon.badges.issuerdetails' | translate}}

- + -

{{ 'core.name' | translate}}

-

{{ user.fullname }}

+

{{ 'addon.badges.issuername' | translate}}

+

{{ badge.issuername }}

+
+
+ + +

{{ 'addon.badges.contact' | translate}}

+

+ {{ badge.issuercontact }} +

- - - - -

{{ 'addon.badges.issuerdetails' | translate}}

-
-
- - -

{{ 'addon.badges.issuername' | translate}}

-

{{ badge.issuername }}

-
-
- - -

{{ 'addon.badges.contact' | translate}}

-

- {{ badge.issuercontact }} -

-
-
-
+ + + +

{{ 'addon.badges.badgedetails' | translate}}

+
+
+ + +

{{ 'core.name' | translate}}

+

{{ badge.name }}

+
+
+ + +

{{ 'addon.badges.version' | translate}}

+

{{ badge.version }}

+
+
+ + +

{{ 'addon.badges.language' | translate}}

+

{{ badge.language }}

+
+
+ + +

{{ 'core.description' | translate}}

+

{{ badge.description }}

+
+
+ + +

{{ 'addon.badges.imageauthorname' | translate}}

+

{{ badge.imageauthorname }}

+
+
+ + +

{{ 'addon.badges.imageauthoremail' | translate}}

+

+ {{ badge.imageauthoremail }} +

+
+
+ + +

{{ 'addon.badges.imageauthorurl' | translate}}

+

{{ badge.imageauthorurl }}

+
+
+ + +

{{ 'addon.badges.imagecaption' | translate}}

+

{{ badge.imagecaption }}

+
+
+ + +

{{ 'core.course' | translate}}

+

+ + +

+
+
+ +
- - - -

{{ 'addon.badges.badgedetails' | translate}}

-
-
- - -

{{ 'core.name' | translate}}

-

{{ badge.name }}

-
-
- - -

{{ 'addon.badges.version' | translate}}

-

{{ badge.version }}

-
-
- - -

{{ 'addon.badges.language' | translate}}

-

{{ badge.language }}

-
-
- - -

{{ 'core.description' | translate}}

-

{{ badge.description }}

-
-
- - -

{{ 'addon.badges.imageauthorname' | translate}}

-

{{ badge.imageauthorname }}

-
-
- - -

{{ 'addon.badges.imageauthoremail' | translate}}

-

- {{ badge.imageauthoremail }} -

-
-
- - -

{{ 'addon.badges.imageauthorurl' | translate}}

-

{{ badge.imageauthorurl }}

-
-
- - -

{{ 'addon.badges.imagecaption' | translate}}

-

{{ badge.imagecaption }}

-
-
- - -

{{ 'core.course' | translate}}

-

- - -

-
-
- -
+ + + +

{{ 'addon.badges.issuancedetails' | translate}}

+
+
+ + +

{{ 'addon.badges.dateawarded' | translate}}

+

{{badge.dateissued * 1000 | coreFormatDate }}

+
+
+ + +

{{ 'addon.badges.expirydate' | translate}}

+

+ {{ badge.dateexpire * 1000 | coreFormatDate }} + + {{ 'addon.badges.warnexpired' | translate }} + +

+
+
+ +
- - - -

{{ 'addon.badges.issuancedetails' | translate}}

-
-
- - -

{{ 'addon.badges.dateawarded' | translate}}

-

{{badge.dateissued * 1000 | coreFormatDate }}

-
-
- - -

{{ 'addon.badges.expirydate' | translate}}

-

- {{ badge.dateexpire * 1000 | coreFormatDate }} - - {{ 'addon.badges.warnexpired' | translate }} - -

-
-
- -
+ + + + +

{{ 'addon.badges.bendorsement' | translate}}

+
+
+ + +

{{ 'addon.badges.issuername' | translate}}

+

{{ badge.endorsement.issuername }}

+
+
+ + +

{{ 'addon.badges.issueremail' | translate}}

+

+ + {{ badge.endorsement.issueremail }} + +

+
+
+ + +

{{ 'addon.badges.issuerurl' | translate}}

+

{{ badge.endorsement.issuerurl }}

+
+
+ + +

{{ 'addon.badges.dateawarded' | translate}}

+

{{ badge.endorsement.dateissued * 1000 | coreFormatDate }}

+
+
+ + +

{{ 'addon.badges.claimid' | translate}}

+

{{ badge.endorsement.claimid }}

+
+
+ + +

{{ 'addon.badges.claimcomment' | translate}}

+

{{ badge.endorsement.claimcomment }}

+
+
+
- - - - -

{{ 'addon.badges.bendorsement' | translate}}

-
-
- - -

{{ 'addon.badges.issuername' | translate}}

-

{{ badge.endorsement.issuername }}

-
-
- - -

{{ 'addon.badges.issueremail' | translate}}

-

- - {{ badge.endorsement.issueremail }} - -

-
-
- - -

{{ 'addon.badges.issuerurl' | translate}}

-

{{ badge.endorsement.issuerurl }}

-
-
- - -

{{ 'addon.badges.dateawarded' | translate}}

-

{{ badge.endorsement.dateissued * 1000 | coreFormatDate }}

-
-
- - -

{{ 'addon.badges.claimid' | translate}}

-

{{ badge.endorsement.claimid }}

-
-
- - -

{{ 'addon.badges.claimcomment' | translate}}

-

{{ badge.endorsement.claimcomment }}

-
-
-
+ + + + +

{{ 'addon.badges.relatedbages' | translate}}

+
+
+ + +

{{ relatedBadge.name }}

+
+
+ + +

{{ 'addon.badges.norelated' | translate}}

+
+
+
- - - - -

{{ 'addon.badges.relatedbages' | translate}}

-
-
- - -

{{ relatedBadge.name }}

-
-
- - -

{{ 'addon.badges.norelated' | translate}}

-
-
-
- - - - - -

{{ 'addon.badges.alignment' | translate}}

-
-
- - -

{{ alignment.targetname }}

-
-
- - -

{{ 'addon.badges.noalignment' | translate}}

-
-
-
-
-
-
+ + + + +

{{ 'addon.badges.alignment' | translate}}

+
+
+ + +

{{ alignment.targetname }}

+
+
+ + +

{{ 'addon.badges.noalignment' | translate}}

+
+
+
+ +
diff --git a/src/addons/mod/assign/pages/submission-review/submission-review.html b/src/addons/mod/assign/pages/submission-review/submission-review.html index 3655e0816..370086cb0 100644 --- a/src/addons/mod/assign/pages/submission-review/submission-review.html +++ b/src/addons/mod/assign/pages/submission-review/submission-review.html @@ -19,15 +19,12 @@ - - - - - - - - - - + + + + + + + + diff --git a/src/addons/mod/feedback/pages/attempt/attempt.html b/src/addons/mod/feedback/pages/attempt/attempt.html index 3fee6027f..cb30f110e 100644 --- a/src/addons/mod/feedback/pages/attempt/attempt.html +++ b/src/addons/mod/feedback/pages/attempt/attempt.html @@ -9,47 +9,45 @@ - - - - - - - -

{{attempt.fullname}}

-

{{attempt.timemodified * 1000 | coreFormatDate }}

-
-
+ + + + + + +

{{attempt.fullname}}

+

{{attempt.timemodified * 1000 | coreFormatDate }}

+
+
- - - -

{{ 'addon.mod_feedback.anonymous_user' |translate }}

-

{{ 'addon.mod_feedback.response_nr' | translate }}: {{anonAttempt.number}}

-
-
- - - - - -

- {{item.itemnumber}}. - - -

-

- - -

-
-
-
+ + + +

{{ 'addon.mod_feedback.anonymous_user' |translate }}

+

{{ 'addon.mod_feedback.response_nr' | translate }}: {{anonAttempt.number}}

+
+
+ + + + + +

+ {{item.itemnumber}}. + + +

+

+ + +

+
+
-
-
-
+ + +
diff --git a/src/addons/mod/forum/pages/discussion/discussion.html b/src/addons/mod/forum/pages/discussion/discussion.html index e022d7c11..fa0eb810a 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.html +++ b/src/addons/mod/forum/pages/discussion/discussion.html @@ -55,75 +55,73 @@ - - - - - + + + + - - - - - - {{ 'core.hasdatatosync' | translate:{$a: discussionStr} }} - - + + + + + + {{ 'core.hasdatatosync' | translate:{$a: discussionStr} }} + + - - - - - {{ availabilityMessage }} - - + + + + + {{ availabilityMessage }} + + - - - - {{ 'addon.mod_forum.discussionlocked' | translate }} - - + + + + {{ 'addon.mod_forum.discussionlocked' | translate }} + + -
- +
+ + +
+ + + + + -
- - - - - - - - - - - - - + - - - - - -
- - - -
-
-
-
+ + + + + + + + + + + +
+ + + +
+
+
diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.html b/src/addons/mod/forum/pages/new-discussion/new-discussion.html index e84f01638..daebbcd75 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.html +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.html @@ -11,78 +11,76 @@ - - - - - - -
- - {{ 'addon.mod_forum.subject' | translate }} - - + + + + + + + + {{ 'addon.mod_forum.subject' | translate }} + + + + + {{ 'addon.mod_forum.message' | translate }} + + + + + + + +

{{ 'addon.mod_forum.advanced' | translate }}

+
+
+
+ + {{ 'addon.mod_forum.posttomygroups' | translate }} + + + + {{ 'addon.mod_forum.group' | translate }} + + {{ group.name }} + - {{ 'addon.mod_forum.message' | translate }} - - + {{ 'addon.mod_forum.discussionsubscription' | translate }} + - - - - -

{{ 'addon.mod_forum.advanced' | translate }}

-
+ + {{ 'addon.mod_forum.discussionpinned' | translate }} + -
- - {{ 'addon.mod_forum.posttomygroups' | translate }} - - - - {{ 'addon.mod_forum.group' | translate }} - - {{ group.name }} - - - - {{ 'addon.mod_forum.discussionsubscription' | translate }} - - - - {{ 'addon.mod_forum.discussionpinned' | translate }} - - - - -
- - - - - - {{ 'addon.mod_forum.posttoforum' | translate }} - - - - {{ 'core.discard' | translate }} - - - - - - - + + +
+ + + + + + {{ 'addon.mod_forum.posttoforum' | translate }} + + + + {{ 'core.discard' | translate }} + + + + + +
diff --git a/src/addons/mod/glossary/pages/edit/edit.html b/src/addons/mod/glossary/pages/edit/edit.html index 4b195ebab..f943c19e3 100644 --- a/src/addons/mod/glossary/pages/edit/edit.html +++ b/src/addons/mod/glossary/pages/edit/edit.html @@ -11,76 +11,73 @@ - - - -
- - {{ 'addon.mod_glossary.concept' | translate }} - - - - - {{ 'addon.mod_glossary.definition' | translate }} - - - - - - {{ 'addon.mod_glossary.categories' | translate }} - - - - {{ category.name }} - - - - - - {{ 'addon.mod_glossary.aliases' | translate }} - - - - + + + + + {{ 'addon.mod_glossary.concept' | translate }} + + + + + {{ 'addon.mod_glossary.definition' | translate }} + + + + + + {{ 'addon.mod_glossary.categories' | translate }} + + + + {{ category.name }} + + + + + + {{ 'addon.mod_glossary.aliases' | translate }} + + + + + + +

{{ 'addon.mod_glossary.attachment' | translate }}

+
+
+ + + -

{{ 'addon.mod_glossary.attachment' | translate }}

+

{{ 'addon.mod_glossary.linking' | translate }}

- - - - - -

{{ 'addon.mod_glossary.linking' | translate }}

-
-
- - {{ 'addon.mod_glossary.entryusedynalink' | translate }} - - - - {{ 'addon.mod_glossary.casesensitive' | translate }} - - - - - {{ 'addon.mod_glossary.fullmatch' | translate }} - - -
- - {{ 'core.save' | translate }} - - -
-
+ + {{ 'addon.mod_glossary.entryusedynalink' | translate }} + + + + {{ 'addon.mod_glossary.casesensitive' | translate }} + + + + + {{ 'addon.mod_glossary.fullmatch' | translate }} + + + + + {{ 'core.save' | translate }} + + +
diff --git a/src/addons/mod/glossary/pages/entry/entry.html b/src/addons/mod/glossary/pages/entry/entry.html index e5d870d40..ebe54a345 100644 --- a/src/addons/mod/glossary/pages/entry/entry.html +++ b/src/addons/mod/glossary/pages/entry/entry.html @@ -11,76 +11,74 @@ - - - - - + + + + - - - - - -

- - -

-

{{ entry.userfullname }}

-
- {{ entry.timemodified | coreDateDayOrTime }} -
- - -

- - -

-
- {{ entry.timemodified | coreDateDayOrTime }} -
- - - + + + + + +

+ - - -
- - -
- - -
{{ 'core.tag.tags' | translate }}:
- -
-
- - -

{{ 'addon.mod_glossary.entrypendingapproval' | translate }}

-
-
- - - - - - - +

+

{{ entry.userfullname }}

+
+ {{ entry.timemodified | coreDateDayOrTime }} +
+ + +

+ + +

+
+ {{ entry.timemodified | coreDateDayOrTime }} +
+ + + + + + +
+ + +
+ + +
{{ 'core.tag.tags' | translate }}:
+ +
+
+ + +

{{ 'addon.mod_glossary.entrypendingapproval' | translate }}

+
+
+ + + + + + +
- - - {{ 'addon.mod_glossary.errorloadingentry' | translate }} - - -
-
+ + + {{ 'addon.mod_glossary.errorloadingentry' | translate }} + + +
diff --git a/src/core/classes/items-management/swipe-navigation-items-manager.ts b/src/core/classes/items-management/swipe-navigation-items-manager.ts index 57b1dd2c7..2548b7b7d 100644 --- a/src/core/classes/items-management/swipe-navigation-items-manager.ts +++ b/src/core/classes/items-management/swipe-navigation-items-manager.ts @@ -49,6 +49,24 @@ export class CoreSwipeNavigationItemsManager< await this.navigateToItemBy(1, 'forward'); } + /** + * Has a next item. + */ + async hasNextItem(): Promise { + const item = await this.getItemBy(-1); + + return !!item; + } + + /** + * Has a previous item. + */ + async hasPreviousItem(): Promise { + const item = await this.getItemBy(1); + + return !!item; + } + /** * @inheritdoc */ diff --git a/src/core/classes/page-transition.ts b/src/core/classes/page-transition.ts index 7443f6c55..4ae2d83c9 100644 --- a/src/core/classes/page-transition.ts +++ b/src/core/classes/page-transition.ts @@ -229,11 +229,19 @@ export const moodleTransitionAnimation = (navEl: HTMLElement, opts: TransitionOp rootAnimation.addAnimation(leavingContent); + // Check if leaving content is being translated using transform styles and decide to use fromTo or only To animation. + const hasTransformStyle = !!leavingContentEl && (leavingContentEl as HTMLElement).style.transform !== ''; if (backDirection) { // leaving content, back direction - leavingContent - .beforeClearStyles([OPACITY]) - .fromTo('transform', `translateX(${CENTER})`, (isRTL ? 'translateX(-100%)' : 'translateX(100%)')); + if (hasTransformStyle) { + leavingContent + .to('transform', (isRTL ? 'translateX(-100%)' : 'translateX(100%)')) + .fromTo(OPACITY, 1, OFF_OPACITY); + } else { + leavingContent + .beforeClearStyles([OPACITY]) + .fromTo('transform', `translateX(${CENTER})`, (isRTL ? 'translateX(-100%)' : 'translateX(100%)')); + } const leavingPage = getIonPageElement(leavingEl) as HTMLElement; rootAnimation.afterAddWrite(() => { @@ -244,9 +252,15 @@ export const moodleTransitionAnimation = (navEl: HTMLElement, opts: TransitionOp } else { // leaving content, forward direction - leavingContent - .fromTo('transform', `translateX(${CENTER})`, `translateX(${OFF_LEFT})`) - .fromTo(OPACITY, 1, OFF_OPACITY); + if (hasTransformStyle) { + leavingContent + .to('transform', (isRTL ? 'translateX(100%)' : 'translateX(-100%)')) + .fromTo(OPACITY, 1, OFF_OPACITY); + } else { + leavingContent + .fromTo('transform', `translateX(${CENTER})`, `translateX(${OFF_LEFT})`) + .fromTo(OPACITY, 1, OFF_OPACITY); + } } if (leavingContentEl) { diff --git a/src/core/components/components.module.ts b/src/core/components/components.module.ts index ae31faa41..0bfb96dc3 100644 --- a/src/core/components/components.module.ts +++ b/src/core/components/components.module.ts @@ -50,7 +50,6 @@ import { CoreShowPasswordComponent } from './show-password/show-password'; import { CoreSitePickerComponent } from './site-picker/site-picker'; import { CoreSplitViewComponent } from './split-view/split-view'; import { CoreStyleComponent } from './style/style'; -import { CoreSwipeNavigationComponent } from './swipe-navigation/swipe-navigation'; import { CoreTabComponent } from './tabs/tab'; import { CoreTabsComponent } from './tabs/tabs'; import { CoreTabsOutletComponent } from './tabs-outlet/tabs-outlet'; @@ -94,7 +93,6 @@ import { CoreSwipeSlidesComponent } from './swipe-slides/swipe-slides'; CoreSitePickerComponent, CoreSplitViewComponent, CoreStyleComponent, - CoreSwipeNavigationComponent, CoreSwipeSlidesComponent, CoreTabComponent, CoreTabsComponent, @@ -144,7 +142,6 @@ import { CoreSwipeSlidesComponent } from './swipe-slides/swipe-slides'; CoreSitePickerComponent, CoreSplitViewComponent, CoreStyleComponent, - CoreSwipeNavigationComponent, CoreSwipeSlidesComponent, CoreTabComponent, CoreTabsComponent, diff --git a/src/core/components/swipe-navigation/swipe-navigation.html b/src/core/components/swipe-navigation/swipe-navigation.html deleted file mode 100644 index 1a47ecb89..000000000 --- a/src/core/components/swipe-navigation/swipe-navigation.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/core/components/swipe-navigation/swipe-navigation.scss b/src/core/components/swipe-navigation/swipe-navigation.scss deleted file mode 100644 index e1bd0f739..000000000 --- a/src/core/components/swipe-navigation/swipe-navigation.scss +++ /dev/null @@ -1,24 +0,0 @@ -ion-slides { - min-height: 100%; -} - -ion-slide { - align-items: start; -} - -:host ::ng-deep { - - .swiper-wrapper { - position: absolute; - } - - core-loading .core-loading-content { - display: block !important; - width: 100%; - } - - ion-refresher.refresher-native { - z-index: 2; - } - -} diff --git a/src/core/components/swipe-navigation/swipe-navigation.ts b/src/core/components/swipe-navigation/swipe-navigation.ts deleted file mode 100644 index c26e0ab67..000000000 --- a/src/core/components/swipe-navigation/swipe-navigation.ts +++ /dev/null @@ -1,54 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, Input } from '@angular/core'; -import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager'; -import { CoreScreen } from '@services/screen'; - -@Component({ - selector: 'core-swipe-navigation', - templateUrl: 'swipe-navigation.html', - styleUrls: ['swipe-navigation.scss'], -}) -export class CoreSwipeNavigationComponent { - - @Input() manager?: CoreSwipeNavigationItemsManager; - - get enabled(): boolean { - return CoreScreen.isMobile && !!this.manager; - } - - /** - * Swipe to previous item. - */ - swipeLeft(): void { - if (!this.enabled) { - return; - } - - this.manager?.navigateToPreviousItem(); - } - - /** - * Swipe to next item. - */ - swipeRight(): void { - if (!this.enabled) { - return; - } - - this.manager?.navigateToNextItem(); - } - -} diff --git a/src/core/directives/directives.module.ts b/src/core/directives/directives.module.ts index e1d6dc959..018ddafad 100644 --- a/src/core/directives/directives.module.ts +++ b/src/core/directives/directives.module.ts @@ -28,6 +28,7 @@ import { CoreAriaButtonClickDirective } from './aria-button'; import { CoreOnResizeDirective } from './on-resize'; import { CoreDownloadFileDirective } from './download-file'; import { CoreCollapsibleHeaderDirective } from './collapsible-header'; +import { CoreSwipeNavigationDirective } from './swipe-navigation'; @NgModule({ declarations: [ @@ -45,6 +46,7 @@ import { CoreCollapsibleHeaderDirective } from './collapsible-header'; CoreOnResizeDirective, CoreDownloadFileDirective, CoreCollapsibleHeaderDirective, + CoreSwipeNavigationDirective, ], exports: [ CoreAutoFocusDirective, @@ -61,6 +63,7 @@ import { CoreCollapsibleHeaderDirective } from './collapsible-header'; CoreOnResizeDirective, CoreDownloadFileDirective, CoreCollapsibleHeaderDirective, + CoreSwipeNavigationDirective, ], }) export class CoreDirectivesModule {} diff --git a/src/core/directives/swipe-navigation.ts b/src/core/directives/swipe-navigation.ts new file mode 100644 index 000000000..31caacaef --- /dev/null +++ b/src/core/directives/swipe-navigation.ts @@ -0,0 +1,158 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core'; +import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager'; +import { Gesture } from '@ionic/angular'; +import { CoreScreen } from '@services/screen'; +import { GestureController } from '@singletons'; + +const ACTIVATION_THRESHOLD = 150; +const SWIPE_FRICTION = 0.6; + +/** + * Directive to enable content navigation with swipe. + * + * Example usage: + * + * + */ +@Directive({ + selector: 'ion-content[core-swipe-navigation]', +}) +export class CoreSwipeNavigationDirective implements AfterViewInit, OnDestroy { + + // eslint-disable-next-line @angular-eslint/no-input-rename + @Input('core-swipe-navigation') manager?: CoreSwipeNavigationItemsManager; + + protected element: HTMLElement; + protected swipeGesture?: Gesture; + + constructor(el: ElementRef) { + this.element = el.nativeElement; + } + + get enabled(): boolean { + return CoreScreen.isMobile && !!this.manager; + } + + /** + * @inheritdoc + */ + ngAfterViewInit(): void { + const style = this.element.style; + this.swipeGesture = GestureController.create({ + el: this.element, + gestureName: 'swipe', + threshold: 10, + gesturePriority: 10, + canStart: () => this.enabled, + onStart: () => { + style.transition = ''; + }, + onMove: (ev) => { + style.transform = `translateX(${ev.deltaX * SWIPE_FRICTION }px)`; + }, + onEnd: (ev) => { + style.transition = '.5s ease-out'; + + if (ev.deltaX > ACTIVATION_THRESHOLD) { + this.manager?.hasNextItem().then((hasNext) => { + if (hasNext) { + this.preventClickOnElement(); + + style.transform = 'translateX(100%) !important'; + this.swipeRight(); + } else { + style.transform = ''; + } + + return; + }); + + return; + } + + if (ev.deltaX < -ACTIVATION_THRESHOLD) { + this.manager?.hasPreviousItem().then((hasPrevious) => { + if (hasPrevious) { + + this.preventClickOnElement(); + + style.transform = 'translateX(-100%) !important'; + this.swipeLeft(); + } else { + style.transform = ''; + } + + return; + }); + + return; + } + + style.transform = ''; + + }, + }); + this.swipeGesture.enable(); + } + + /** + * Swipe to previous item. + */ + swipeLeft(): void { + if (!this.enabled) { + return; + } + + this.manager?.navigateToPreviousItem(); + } + + /** + * Swipe to next item. + */ + swipeRight(): void { + if (!this.enabled) { + return; + } + + this.manager?.navigateToNextItem(); + } + + /** + * Prevent click event by capturing the click before happening. + */ + protected preventClickOnElement(): void { + this.element.addEventListener( + 'click', + (ev: Event) => { + ev.preventDefault(); + ev.stopPropagation(); + + return false; + }, + true, // Register event on the capture phase. + ); + + } + + /** + * @inheritdoc + */ + ngOnDestroy(): void { + this.swipeGesture?.destroy(); + } + +} diff --git a/src/core/features/user/pages/profile/profile.html b/src/core/features/user/pages/profile/profile.html index ab29e5819..1d12c3003 100644 --- a/src/core/features/user/pages/profile/profile.html +++ b/src/core/features/user/pages/profile/profile.html @@ -8,89 +8,86 @@ - - - - - - - - + + + + + + + -
- - - - - {{ handler.title | translate }} - - - -
- -
-
-
+ + + + +