Skip to content

Commit 4a24d9b

Browse files
Simone-RamundiAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-1745 (pull request DSpace#1816)
Task/dspace cris 2023 02 x/DSC-1745 Approved-by: Andrea Barbasso
2 parents bebc88c + b207203 commit 4a24d9b

6 files changed

Lines changed: 33 additions & 8 deletions

File tree

src/app/app.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<ds-themed-root
22
[shouldShowFullscreenLoader]="(isAuthBlocking$ | async) || (isThemeLoading$ | async)"
33
[shouldShowRouteLoader]="isRouteLoading$ | async"></ds-themed-root>
4+
5+
<ds-social *ngIf="browserPlatform"></ds-social>

src/app/app.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export class AppComponent implements OnInit, AfterViewInit {
6161
*/
6262
idleModalOpen: boolean;
6363

64+
65+
/**
66+
* In order to show sharing component only in csr
67+
*/
68+
browserPlatform = false;
69+
6470
constructor(
6571
@Inject(NativeWindowService) private _window: NativeWindowRef,
6672
@Inject(DOCUMENT) private document: any,
@@ -78,11 +84,12 @@ export class AppComponent implements OnInit, AfterViewInit {
7884
private datadogRumService: DatadogRumService
7985
) {
8086
this.notificationOptions = environment.notifications;
87+
this.browserPlatform = isPlatformBrowser(this.platformId);
8188

8289
/* Use models object so all decorators are actually called */
8390
this.models = models;
8491

85-
if (isPlatformBrowser(this.platformId)) {
92+
if (this.browserPlatform) {
8693
this.trackIdleModal();
8794
}
8895

src/app/app.module.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { StoreDevModules } from '../config/store/devtools';
3232
import { RootModule } from './root.module';
3333
import { NuMarkdownModule } from '@ng-util/markdown';
3434
import { FooterModule } from './footer/footer.module';
35+
import { SocialModule } from './social/social.module';
3536

3637
export function getConfig() {
3738
return environment;
@@ -120,10 +121,11 @@ const EXPORTS = [
120121
];
121122

122123
@NgModule({
123-
imports: [
124-
BrowserModule.withServerTransition({ appId: 'dspace-angular' }),
125-
...IMPORTS
126-
],
124+
imports: [
125+
BrowserModule.withServerTransition({appId: 'dspace-angular'}),
126+
...IMPORTS,
127+
SocialModule
128+
],
127129
providers: [
128130
...PROVIDERS
129131
],

src/app/root/root.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</div>
2626
</div>
2727

28-
<ds-social *ngIf="browserPlatform"></ds-social>
2928

3029
<ds-notifications-board [options]="notificationOptions">
3130
</ds-notifications-board>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
:host {
1+
::ng-deep {
22
div#a2a {
33
bottom: 0;
44
right: 0;
5+
z-index: 998;
56
}
67
}
78

src/app/social/social.service.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,21 @@ export class SocialService {
6363
script.type = 'text/javascript';
6464
script.src = environment.addToAnyPlugin.scriptUrl;
6565
script.async = true;
66-
this._document.body.appendChild(script);
66+
67+
// Wait for document to finish grow vertically so that script listener handles properly body height changes
68+
let lastBodyHeight = 0;
69+
const documentBody = this._document.body;
70+
71+
const bodyHeightInterval = setInterval(() => {
72+
const currentBodyHeight = documentBody.getBoundingClientRect().height;
73+
74+
if (currentBodyHeight > lastBodyHeight) {
75+
lastBodyHeight = currentBodyHeight;
76+
} else {
77+
this._document.head.appendChild(script);
78+
clearInterval(bodyHeightInterval);
79+
}
80+
}, 200);
6781
}
6882

6983
/**

0 commit comments

Comments
 (0)