use scrolltop instead of scrollintoview

pull/9621/head
bsatarnejad 3 years ago
parent c6f3c974f4
commit 3cf8a71169
  1. 6
      frontend/src/app/core/browser/device.service.ts
  2. 8
      frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts

@ -4,13 +4,7 @@ import { Injectable } from '@angular/core';
export class DeviceService { export class DeviceService {
public mobileWidthTreshold = 680; public mobileWidthTreshold = 680;
public tabletWidthTreshold = 1249;
public get isMobile():boolean { public get isMobile():boolean {
return (window.innerWidth < this.mobileWidthTreshold); return (window.innerWidth < this.mobileWidthTreshold);
} }
public get isTablet():boolean {
return (window.innerWidth < this.tabletWidthTreshold);
}
} }

@ -41,7 +41,6 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destr
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service'; import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { DeviceService } from 'core-app/core/browser/device.service';
import { WpSingleViewService } from 'core-app/features/work-packages/routing/wp-view-base/state/wp-single-view.service'; import { WpSingleViewService } from 'core-app/features/work-packages/routing/wp-view-base/state/wp-single-view.service';
@Directive() @Directive()
@ -75,7 +74,6 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
readonly cdRef:ChangeDetectorRef, readonly cdRef:ChangeDetectorRef,
readonly uiRouterGlobals:UIRouterGlobals, readonly uiRouterGlobals:UIRouterGlobals,
readonly wpActivity:WorkPackagesActivityService, readonly wpActivity:WorkPackagesActivityService,
readonly deviceService:DeviceService,
readonly storeService:WpSingleViewService, readonly storeService:WpSingleViewService,
) { ) {
super(); super();
@ -144,7 +142,7 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
protected scrollToUnreadNotification():void { protected scrollToUnreadNotification():void {
// scroll to the unread notification only if there is no deep link // scroll to the unread notification only if there is no deep link
if (window.location.href.indexOf('activity#') > -1 || this.deviceService.isTablet) { if (window.location.href.indexOf('activity#') > -1) {
return; return;
} }
const unreadNotifications = document.querySelectorAll('.comments-number--bubble'); const unreadNotifications = document.querySelectorAll('.comments-number--bubble');
@ -154,10 +152,10 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements
} }
if (this.reverse) { if (this.reverse) {
unreadNotifications[unreadNotificationsLength - 1].classList.add('op-user-activity--unread-notification-bubble_scrolled'); unreadNotifications[unreadNotificationsLength - 1].classList.add('op-user-activity--unread-notification-bubble_scrolled');
unreadNotifications[unreadNotificationsLength - 1].scrollIntoView(); document.getElementsByClassName('tabcontent')[0].scrollTop = (jQuery(unreadNotifications[unreadNotificationsLength - 1]).closest('.op-user-activity')[0] as HTMLElement).offsetTop;
} else { } else {
unreadNotifications[0].classList.add('op-user-activity--unread-notification-bubble_scrolled'); unreadNotifications[0].classList.add('op-user-activity--unread-notification-bubble_scrolled');
unreadNotifications[0].scrollIntoView(); document.getElementsByClassName('tabcontent')[0].scrollTop = (jQuery(unreadNotifications[0]).closest('.op-user-activity')[0] as HTMLElement).offsetTop;
} }
} }

Loading…
Cancel
Save