Projekt

Obecné

Profil

Stáhnout (683 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import {Position} from './app/model/crates/Position';
2

    
3
export default class Utils {
4

    
5
  static removeFileSuffix(file: File): string {
6
    return file.name.substring(0, file.name.indexOf('.'));
7
  }
8

    
9
  static isIterable(obj): boolean {
10
    // checks for null and undefined
11
    if (obj == null) {
12
      return false;
13
    }
14
    return typeof obj[Symbol.iterator] === 'function';
15
  }
16

    
17
  static getAbsolutePositionOfElement(element: HTMLElement): Position {
18
    let top = 0, left = 0;
19

    
20
    do {
21
      top += element.offsetTop  || 0;
22
      left += element.offsetLeft || 0;
23
      element = <HTMLElement> element.offsetParent;
24
    } while (element);
25

    
26
    return new Position(top, left);
27
  }
28
}
(1-1/8)