Loading assets

105  
106        /**
107         * fetch image asset
108         * @param url - asset url
109         * @param node - book object node to update
110         * @returns {*}
111         */
112        this.fetchImageAsset = function(url, node) {
113          var deferred = $q.defer()
114            , loader;
115          loader = new PIXI.ImageLoader(url);
116          loader.onLoaded = function() {
117            var texture = PIXI.TextureCache[url];
118            node.sprite = new PIXI.Sprite(texture);
119            node.sprite.anchor.x = 0;
120            node.sprite.anchor.y = 0;
121            node.sprite.position.x = -21;
122            node.sprite.position.y = -21;
123            node.sprite.node = node;
124            if (node.properties.styles) {
125              node.sprite.position.x = Math.ceil(node.properties.styles.left);
126              node.sprite.position.y = Math.ceil(node.properties.styles.top);
127            }
128            deferred.resolve(node);
129          };
130          loader.load();
131          return deferred.promise;
132        };
133