Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
- };
- 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) {
- var SVGLoadersTest = (function (_super) {
- __extends(SVGLoadersTest, _super);
- function SVGLoadersTest() {
- var _this = this;
- _super.call(this);
- 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');
- this.loadersScales = new Array(.4, .5, .25, .25, .25, .25, 1, 1, 1, .75, 1, .4);
- this.row = 0;
- this.col = 0;
- this.container = document.createElement('div');
- document.body.appendChild(this.container);
- window.addEventListener('resize', function () { return _this.onResize(); });
- this.svg = new SVGCanvas(this.container);
- this.svg.width = 800;
- this.svg.height = 600;
- this.background = new SVGRectangle();
- this.background.fill('#000000');
- this.svg.append(this.background);
- this.group = new SVGGroup();
- this.svg.append(this.group);
- var svgLoad;
- for (var c = 0; c < this.loadersNames.length; c++) {
- svgLoad = new SVGLoader();
- svgLoad.load('assets/loaders/' + this.loadersNames[c]);
- svgLoad.addEventListener(Event.COMPLETE, function (e) { return _this.svgLoaded(e); });
- }
- this.onResize();
- }
- SVGLoadersTest.prototype.svgLoaded = function (e) {
- var loader = e.target;
- if (this.col == 3) {
- this.col = 0;
- this.row++;
- }
- loader.element.id = loader.url;
- loader.element.scaleX = loader.element.scaleY = this.getScale(loader.url);
- loader.element.x = this.col * 80;
- loader.element.y = this.row * 80;
- this.group.append(loader.element);
- this.col++;
- this.onResize();
- };
- SVGLoadersTest.prototype.getScale = function (url) {
- var fullPath;
- fullPath;
- for (var c = 0; c < this.loadersNames.length; c++) {
- fullPath = 'assets/loaders/' + this.loadersNames[c];
- if (fullPath == url) {
- return this.loadersScales[c];
- }
- }
- return 1;
- };
- SVGLoadersTest.prototype.onResize = function () {
- this.background.width = this.svg.width = window.innerWidth;
- this.background.height = this.svg.height = window.innerHeight;
- this.group.x = (window.innerWidth - this.group.width) / 2;
- this.group.y = (window.innerHeight - this.group.height) / 2;
- };
- return SVGLoadersTest;
- })(EventDispatcher);
- return SVGLoadersTest;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement