mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
SVG rezise preload. svgConfig object
svgConfig, contains the width and height. Change zise.
This commit is contained in:
parent
081f4188df
commit
b8371eba7b
1 changed files with 12 additions and 10 deletions
|
@ -45,7 +45,7 @@ var SVGFile = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function SVGFile (loader, key, url, xhrSettings)
|
||||
function SVGFile (loader, key, url, svgConfig, xhrSettings)
|
||||
{
|
||||
var extension = 'svg';
|
||||
|
||||
|
@ -55,6 +55,7 @@ var SVGFile = new Class({
|
|||
|
||||
key = GetFastValue(config, 'key');
|
||||
url = GetFastValue(config, 'url');
|
||||
svgConfig = GetFastValue(config, 'svgConfig');
|
||||
xhrSettings = GetFastValue(config, 'xhrSettings');
|
||||
extension = GetFastValue(config, 'extension', extension);
|
||||
}
|
||||
|
@ -66,6 +67,7 @@ var SVGFile = new Class({
|
|||
responseType: 'text',
|
||||
key: key,
|
||||
url: url,
|
||||
svgConfig: svgConfig,
|
||||
xhrSettings: xhrSettings
|
||||
};
|
||||
|
||||
|
@ -85,17 +87,16 @@ var SVGFile = new Class({
|
|||
|
||||
var text = this.xhrLoader.responseText;
|
||||
var svg = [ text ];
|
||||
var width = this.xhrSettings.width;
|
||||
var height = this.xhrSettings.height;
|
||||
var width = this.svgConfig.width;
|
||||
var height = this.svgConfig.height;
|
||||
|
||||
if (width && height)
|
||||
{
|
||||
var xml = null;
|
||||
var parser = new DOMParser();
|
||||
xml = parser.parseFromString(text , 'text/xml');
|
||||
xml = parser.parseFromString(text, 'text/xml');
|
||||
var svgXML = xml.getElementsByTagName('svg')[0];
|
||||
|
||||
// Si no tiene el atributo viewBox, le asigna el valor del alto y ancho predefinidos, para no tener problemas en el escalado.
|
||||
if (svgXML.getAttribute('viewBox'))
|
||||
{
|
||||
svgXML.setAttribute('viewBox', '0 0 ' + svgXML.getAttribute('width') + ' ' + svgXML.getAttribute('height'));
|
||||
|
@ -255,3 +256,4 @@ FileTypesManager.register('svg', function (key, url, xhrSettings)
|
|||
});
|
||||
|
||||
module.exports = SVGFile;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue