Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. define(["require", "exports", "./kurst/events/EventDispatcher", "./kurst/events/Event", "./kurst/svg/display/SVGCanvas", "./kurst/svg/display/SVGRectangle", "./kurst/svg/display/SVGGroup", "./kurst/svg/loader/SVGLoader"], function (require, exports, EventDispatcher, Event, SVGCanvas, SVGRectangle, SVGGroup, SVGLoader) {
  8. var SVGLoadersTest = (function (_super) {
  9. __extends(SVGLoadersTest, _super);
  10. function SVGLoadersTest() {
  11. var _this = this;
  12. _super.call(this);
  13. this.loadersNames = new Array('audio.svg', 'ball-triangle.svg', 'bars.svg', 'circles.svg', 'grid.svg', 'hearts.svg', 'oval.svg', 'puff.svg', 'rings.svg', 'spinning-circles.svg', 'tail-spin.svg', 'three-dots.svg');
  14. this.loadersScales = new Array(.4, .5, .25, .25, .25, .25, 1, 1, 1, .75, 1, .4);
  15. this.row = 0;
  16. this.col = 0;
  17. this.container = document.createElement('div');
  18. document.body.appendChild(this.container);
  19. window.addEventListener('resize', function () { return _this.onResize(); });
  20. this.svg = new SVGCanvas(this.container);
  21. this.svg.width = 800;
  22. this.svg.height = 600;
  23. this.background = new SVGRectangle();
  24. this.background.fill('#000000');
  25. this.svg.append(this.background);
  26. this.group = new SVGGroup();
  27. this.svg.append(this.group);
  28. var svgLoad;
  29. for (var c = 0; c < this.loadersNames.length; c++) {
  30. svgLoad = new SVGLoader();
  31. svgLoad.load('assets/loaders/' + this.loadersNames[c]);
  32. svgLoad.addEventListener(Event.COMPLETE, function (e) { return _this.svgLoaded(e); });
  33. }
  34. this.onResize();
  35. }
  36. SVGLoadersTest.prototype.svgLoaded = function (e) {
  37. var loader = e.target;
  38. if (this.col == 3) {
  39. this.col = 0;
  40. this.row++;
  41. }
  42. loader.element.id = loader.url;
  43. loader.element.scaleX = loader.element.scaleY = this.getScale(loader.url);
  44. loader.element.x = this.col * 80;
  45. loader.element.y = this.row * 80;
  46. this.group.append(loader.element);
  47. this.col++;
  48. this.onResize();
  49. };
  50. SVGLoadersTest.prototype.getScale = function (url) {
  51. var fullPath;
  52. fullPath;
  53. for (var c = 0; c < this.loadersNames.length; c++) {
  54. fullPath = 'assets/loaders/' + this.loadersNames[c];
  55. if (fullPath == url) {
  56. return this.loadersScales[c];
  57. }
  58. }
  59. return 1;
  60. };
  61. SVGLoadersTest.prototype.onResize = function () {
  62. this.background.width = this.svg.width = window.innerWidth;
  63. this.background.height = this.svg.height = window.innerHeight;
  64. this.group.x = (window.innerWidth - this.group.width) / 2;
  65. this.group.y = (window.innerHeight - this.group.height) / 2;
  66. };
  67. return SVGLoadersTest;
  68. })(EventDispatcher);
  69. return SVGLoadersTest;
  70. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement