Project

General

Profile

« Previous | Next » 

Revision 59691

[Monitor | Trunk]: home page redesign

View differences:

home.component.ts
23 23
  selector: 'home',
24 24
  templateUrl: 'home.component.html',
25 25
  styleUrls: ['home.component.css'],
26
  encapsulation: ViewEncapsulation.None,
27 26
  animations: [
28
    trigger('captain-left', [
29
      state('before', style({
30
        transform: 'translateX(-300px)'
31
      })),
32
      state('after', style({
33
        transform: 'translateX(0)'
34
      })),
35
      transition('before => after', [
36
        animate('0.7s')
37
      ])
38
    ]),
39
    trigger('captain-right', [
40
      state('before', style({
41
        transform: 'translateX(300px)'
42
      })),
43
      state('after', style({
44
        transform: 'translateX(0)'
45
      })),
46
      transition('before => after', [
47
        animate('0.7s')
48
      ])
49
    ]),
50 27
    trigger('1', [
51 28
      state('1', style({
52 29
        opacity: 1
......
77 54
  public piwiksub: any;
78 55
  
79 56
  public pageTitle = "OpenAIRE | Monitor";
80
  public stakeholders: any[] = [];
57
  public stakeholders: Stakeholder[] = [];
81 58
  public selected: Stakeholder = null;
82 59
  public pageContents = null;
83 60
  public divContents = null;
......
100 77
  numberSubs = [];
101 78
  public state = 1;
102 79
  private timeouts: any[] = [];
103
  public observer: IntersectionObserver;
104
  public captains: boolean = false;
105
  @ViewChild('ref') ref: ElementRef;
106 80
  @ViewChild('AlertModal') modal;
107 81
  public directLink: boolean = true;
108 82
  private user: User;
......
157 131
        })
158 132
      });
159 133
    if(typeof document != "undefined") {
160
      this.initAnimations();
161 134
      this.startAnimation();
162 135
    }
163 136
  }
164 137
  
165
  public initAnimations() {
166
    this.observer = new IntersectionObserver(entries => {
167
      if (entries[0].isIntersecting == true && this.captains == false) {
168
        this.captains = true;
169
      }
170
    }, {threshold: [0]});
171
    this.observer.observe(this.ref.nativeElement);
172
  }
173
  
174 138
  public startAnimation(state = 1) {
175 139
    this.clearTimeouts();
176 140
    this.state = state;
......
282 246
          this.status = this.errorCodes.NONE;
283 247
        } else {
284 248
          this.stakeholders = stakeholders.filter(stakeholder => stakeholder.isActive && (stakeholder.isPublic || this.isStakeholderManager()));
285
          this.stakeholders.forEach((stakeholder, index, stakeholders) => {
286
            this.setSizeOfStakeholder(index);
287
          });
288 249
        }
289 250
        this.loading = false;
290 251
      },
......
299 260
    return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user);
300 261
  }
301 262
  
302
  private setSizeOfStakeholder(index) {
303
    let mod = index % 9;
304
    if (mod === 0 || mod === 4 || mod === 8) {
305
      this.stakeholders[index].size = 'large';
306
    } else if (mod === 1 || mod === 5 || mod === 6) {
307
      this.stakeholders[index].size = 'small';
308
    } else {
309
      this.stakeholders[index].size = 'medium';
310
    }
311
  }
312
  
313 263
  public confirmModalOpen(result: Stakeholder) {
314 264
    this.selected = result;
315 265
    this.modal.cancelButton = true;
......
344 294
      this.piwiksub.unsubscribe();
345 295
    }
346 296
    this.clearTimeouts();
347
    if(this.observer) {
348
      this.observer.disconnect();
349
    }
350 297
  }
351 298
  
352 299
  private handleError(message: string, error): number {
......
358 305
      code = error.status;
359 306
    }
360 307
    
361
    console.error("Communities (component): " + message, error);
308
    console.error("Home Component: " + message, error);
362 309
    
363 310
    return this.errorMessages.getErrorCode(code);
364 311
  }

Also available in: Unified diff