Project

General

Profile

« Previous | Next » 

Revision 60847

[Graph | Trunk]: Add smooth scroll

View differences:

modules/uoa-graph-portal/trunk/src/app/app.component.ts
1
import {Component, OnInit} from '@angular/core';
1
import {Component, OnDestroy, OnInit} from '@angular/core';
2 2
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
3 3
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
4 4
import {User} from './openaireLibrary/login/utils/helper.class';
5 5
import {properties} from '../environments/environment';
6 6
import {LayoutService} from './services/layout.service';
7 7
import {Header} from './openaireLibrary/sharedComponents/navigationBar.component';
8
import {SmoothScroll} from './openaireLibrary/utils/smooth-scroll';
8 9

  
9 10
@Component({
10 11
  selector: 'app',
11 12
  templateUrl: './app.component.html',
12 13
})
13 14

  
14
export class AppComponent implements OnInit {
15
export class AppComponent implements OnInit, OnDestroy {
15 16
  title = 'OpenAIRE - Research Graph';
16 17
  userMenuItems: MenuItem[] = [];
17 18
  menuItems: RootMenuItem [] = [];
......
23 24
  header: Header;
24 25
  logoPath: string = 'assets/common-assets/';
25 26
  
26
  constructor(private layoutService: LayoutService) {}
27
  constructor(private layoutService: LayoutService,
28
              private smoothScroll: SmoothScroll) {}
27 29
  
28 30
  ngOnInit() {
29 31
    this.logInUrl = this.properties.loginUrl;
......
43 45
    });
44 46
  }
45 47
  
48
  ngOnDestroy() {
49
    this.smoothScroll.clearSubscriptions();
50
  }
51
  
46 52
  buildMenu(isHome) {
47 53
    this.menuItems = [
48 54
      {
modules/uoa-graph-portal/trunk/src/app/home/home.component.ts
27 27
})
28 28
export class HomeComponent {
29 29
  public pageTitle = "OpenAIRE - Research Graph";
30
  
31
  public errorCodes: ErrorCodes = new ErrorCodes();
32
  public routerHelper: RouterHelper = new RouterHelper();
33
  
34 30
  public publicationsSize: any = null;
35 31
  public datasetsSize: any = null;
36 32
  public datasetsLinkedSize: any = null;
......
42 38
  public datasourcesSize: any = null;
43 39
  public portals: any[] = portals;
44 40
  public state: number = 0;
41
  public properties: EnvProperties = properties;
45 42
  private timeouts: any[] = [];
43
  private subs: Subscription[] = [];
46 44
  
47
  properties: EnvProperties = properties;
48
  
49
  subs: Subscription[] = [];
50
  
51 45
  constructor(
52 46
    private route: ActivatedRoute,
53 47
    private _router: Router,
modules/uoa-graph-portal/trunk/src/app/about/about.component.ts
23 23
  public dedupMatchingAndElectionReadMore: boolean = false;
24 24
  public enrichmentPropagationReadMore: boolean = false;
25 25
  public enrichmentMiningReadMore: boolean = false;
26
  properties:EnvProperties;
26
  properties:EnvProperties = properties;
27 27
  subs: Subscription[] = [];
28 28
  description = "The OpenAIRE Research Graph includes metadata and links between scientific products (e.g. literature, datasets, software, other research products), organizations, funders, funding streams, projects, communities, and (provenance) data sources.  Information on how we build it, the architecture, the infrastructure and the team.";
29 29
  title = "OpenAIRE - Research Graph | About";
......
44 44
  }
45 45
  
46 46
  ngOnInit() {
47
    this.properties = properties;
48 47
    this._title.setTitle(this.title);
49 48
    this._meta.updateTag({content:this.description},"name='description'");
50 49
    this._meta.updateTag({content:this.description},"property='og:description'");
51 50
    this._meta.updateTag({content:this.title},"property='og:title'");
52
    this.subs.push(this.route.fragment.subscribe(fragment => {
53
      setTimeout(() => {
54
        this.goTo(fragment);
55
      }, 100);
56
    }));
57 51
    var url = this.properties.domain + this.properties.baseLink+this._router.url;
58 52
    this.seoService.createLinkForCanonicalURL(url, false);
59 53
    this._meta.updateTag({content:url},"property='og:url'");
modules/uoa-graph-portal/trunk/src/app/about/about.component.html
81 81
             class="uk-width-4-5 architecture-image">
82 82

  
83 83
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 27%; top: 48%"
84
           (click)="goTo('tabs_card'); changeTab(0)"
84
           (click)="changeTab(0)" routerLink="/about" fragment="tabs_card"
85 85
           (mouseenter)="architectureImage = 'aggregation_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
86 86
          <action-point [class.uk-invisible]="architectureImage == 'aggregation_hover.png'"></action-point>
87 87
        </a>
88 88
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 47%; top: 48%"
89
           (click)="goTo('tabs_card'); changeTab(1)"
89
           (click)="changeTab(1)" routerLink="/about" fragment="tabs_card"
90 90
           (mouseenter)="architectureImage = 'deduplication_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
91 91
          <action-point [class.uk-invisible]="architectureImage == 'deduplication_hover.png'"></action-point>
92 92
        </a>
93 93
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 58%; top: 48%"
94
           (click)="goTo('tabs_card'); changeTab(2)"
94
           (click)="changeTab(2)" routerLink="/about" fragment="tabs_card"
95 95
           (mouseenter)="architectureImage = 'enrichment_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
96 96
          <action-point [class.uk-invisible]="architectureImage == 'enrichment_hover.png'"></action-point>
97 97
        </a>
98 98
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 70%; top: 48%"
99
           (click)="goTo('tabs_card'); changeTab(3)"
99
           (click)="changeTab(3)" routerLink="/about" fragment="tabs_card"
100 100
           (mouseenter)="architectureImage = 'post_cleaning_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
101 101
          <action-point [class.uk-invisible]="architectureImage == 'post_cleaning_hover.png'"></action-point>
102 102
        </a>
103 103
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 76%; top: 32%"
104
           (click)="goTo('tabs_card'); changeTab(4)"
104
           (click)="changeTab(4)" routerLink="/about" fragment="tabs_card"
105 105
           (mouseenter)="architectureImage = 'indexing_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
106 106
          <action-point [class.uk-invisible]="architectureImage == 'indexing_hover.png'"></action-point>
107 107
        </a>
108 108
        <a class="uk-position-absolute uk-transform-center uk-padding" style="left: 76%; top: 72%"
109
           (click)="goTo('tabs_card'); changeTab(5)"
109
           (click)="changeTab(5)" routerLink="/about" fragment="tabs_card"
110 110
           (mouseenter)="architectureImage = 'stats_analysis_hover.png'" (mouseleave)="architectureImage = 'gray.png'">
111 111
          <action-point [class.uk-invisible]="architectureImage == 'stats_analysis_hover.png'"></action-point>
112 112
        </a>
modules/uoa-graph-portal/trunk/src/app/resources/resources.component.ts
45 45
    if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
46 46
      this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
47 47
    }
48
    this.subs.push(this.route.fragment.subscribe(fragment => {
49
      setTimeout(() => {
50
        this.goTo(fragment);
51
      }, 100);
52
    }));
53 48
  }
54

  
55
  goTo(id: string) {
56
    const yOffset = -100;
57
    const element = document.getElementById(id);
58
    if(element) {
59
      const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
60
      window.scrollTo({top: y, behavior: 'smooth'});
61
    }
62
  }
63

  
49
  
64 50
  public ngOnDestroy() {
65 51
    for (let sub of this.subs) {
66 52
      sub.unsubscribe();
modules/uoa-graph-portal/trunk/src/app/app.routing.ts
32 32
@NgModule({
33 33
  imports: [RouterModule.forRoot(appRoutes, {
34 34
    preloadingStrategy: PreloadAllModules,
35
    scrollPositionRestoration: 'top'
35
    onSameUrlNavigation: "reload",
36
    relativeLinkResolution: 'corrected'
36 37
  })],
37 38
  exports: [RouterModule]
38 39
})
modules/uoa-graph-portal/trunk/src/app/contact/contact.component.ts
58 58
    this._meta.updateTag({content:this.description},"name='description'");
59 59
    this._meta.updateTag({content:this.description},"property='og:description'");
60 60
    this._meta.updateTag({content:this.title},"property='og:title'");
61
    this.subs.push(this.route.fragment.subscribe(fragment => {
62
      setTimeout(() => {
63
        this.goTo(fragment);
64
      }, 100);
65
    }));
66 61
    this.email = {body: '', subject: '', recipients: []};
67 62
    this.reset();
68 63
    this.showLoading = false;
......
155 150
        "For each field you can know if they have been collected from one of our sources, if it has been inferred (and with which algorithm and with which confidence level)"
156 151
    });
157 152
  }
158

  
159
  goTo(id: string) {
160
    const yOffset = -100;
161
    const element = document.getElementById(id);
162
    if(element) {
163
      const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
164
      window.scrollTo({top: y, behavior: 'smooth'});
165
    }
166
  }
153
  
167 154
  public ngOnDestroy() {
168 155
    for (let sub of this.subs) {
169 156
      sub.unsubscribe();
modules/uoa-graph-portal/trunk/src/index.html
27 27
<body>
28 28
<app></app>
29 29
</body>
30
<script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>
30 31
</html>
modules/uoa-graph-portal/trunk/src/index.prod.html
27 27
<body>
28 28
<app></app>
29 29
</body>
30
<script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>
30 31
</html>

Also available in: Unified diff