Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/social/social.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="dspace-a2a" [class.d-none]="(showOnCurrentRoute$ | async) !== true" data-a2a-scroll-show="0,60"
<div id="dspace-a2a" [class.d-none]="(showOnCurrentRoute$ | async) !== true" [attr.data-a2a-scroll-show]="pageIsScrollable ? '0,60' : null"
class="a2a_kit a2a_kit_size_32 a2a_floating_style a2a_default_style" [attr.data-a2a-title]="title" [attr.data-a2a-url]="url">
@for (button of buttonList; track button) {
<a [class]="'a2a_button_' + button" [class.a2a_counter]="showCounters && button !== 'facebook'"></a>
Expand Down
26 changes: 24 additions & 2 deletions src/app/social/social.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { AsyncPipe } from '@angular/common';
import {
AsyncPipe,
isPlatformBrowser,
} from '@angular/common';
import {
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Inject,
OnInit,
PLATFORM_ID,
} from '@angular/core';
import { Observable } from 'rxjs';

Expand All @@ -20,7 +27,7 @@ import { SocialService } from './social.service';
/**
* Component to render dynamically the social2 buttons using addToAny plugin
*/
export class SocialComponent implements OnInit {
export class SocialComponent implements OnInit, AfterViewInit {

/**
* The script containing the profile ID
Expand All @@ -35,8 +42,16 @@ export class SocialComponent implements OnInit {
url: string;
showCounters: boolean;

/**
* Whether the current page has a scrollbar or not.
* If false, we show the bar without waiting for scroll.
*/
pageIsScrollable = true;

constructor(
private socialService: SocialService,
@Inject(PLATFORM_ID) private platformId: object,
private cdr: ChangeDetectorRef,
) {}

ngOnInit() {
Expand All @@ -50,4 +65,11 @@ export class SocialComponent implements OnInit {
}
}

ngAfterViewInit() {
if (this.socialService.enabled && isPlatformBrowser(this.platformId)) {
this.pageIsScrollable = document.body.scrollHeight > window.innerHeight;
this.cdr.detectChanges();
}
}

}
Loading