SVG: Pass the imported SVG date as the 2nd parameter to onLoad()

This commit is contained in:
Jürg Lehni 2016-02-01 20:09:43 +01:00
parent b2f3b587ec
commit ad21b2b07a
3 changed files with 22 additions and 16 deletions

View file

@ -2121,9 +2121,10 @@ new function() { // // Scope to inject various item event handlers
*
* @option [options.expandShapes=false] {Boolean} whether imported shape
* items should be expanded to path items
* @option [options.onLoad] {Function} the callback function to call once
* the SVG content is loaded from the given URL. Only required when
* loading from external files.
* @option options.onLoad {Function} the callback function to call once the
* SVG content is loaded from the given URL receiving two arguments: the
* converted `item` and the original `svg` data as a string. Only
* required when loading from external files.
* @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
* {Boolean} whether imported items should have their transformation
* matrices applied to their contents or not
@ -2145,7 +2146,9 @@ new function() { // // Scope to inject various item event handlers
*
* @param {SVGElement|String} svg the URL of the SVG file to fetch.
* @param {Function} onLoad the callback function to call once the SVG
* content is loaded from the given URL.
* content is loaded from the given URL receiving two arguments: the
* converted `item` and the original `svg` data as a string. Only
* required when loading from external files.
* @return {Item} the newly created Paper.js item containing the converted
* SVG content
*/

View file

@ -757,20 +757,21 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
* @function
*
* @option [options.expandShapes=false] {Boolean} whether imported shape
* items should be expanded to path items
* @option [options.onLoad] {Function} the callback function to call once
* the SVG content is loaded from the given URL. Only required when loading
* from external files.
* items should be expanded to path items
* @option options.onLoad(item, svg) {Function} the callback function to
* call once the SVG content is loaded from the given URL receiving two
* arguments: the converted `item` and the original `svg` data as a
* string. Only required when loading from external files.
* @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
* {Boolean} whether imported items should have their transformation
* matrices applied to their contents or not
* {Boolean} whether imported items should have their transformation
* matrices applied to their contents or not
*
* @param {SVGElement|String} svg the SVG content to import, either as a SVG
* DOM node, a string containing SVG content, or a string describing the URL
* of the SVG file to fetch.
* DOM node, a string containing SVG content, or a string describing the
* URL of the SVG file to fetch.
* @param {Object} [options] the import options
* @return {Item} the newly created Paper.js item containing the converted
* SVG content
* SVG content
*/
/**
* Imports the provided external SVG file, converts it into Paper.js items
@ -783,9 +784,11 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
*
* @param {SVGElement|String} svg the URL of the SVG file to fetch.
* @param {Function} onLoad the callback function to call once the SVG
* content is loaded from the given URL.
* content is loaded from the given URL receiving two arguments: the
* converted `item` and the original `svg` data as a string. Only
* required when loading from external files.
* @return {Item} the newly created Paper.js item containing the converted
* SVG content
* SVG content
*/
removeOn: function(type) {

View file

@ -563,7 +563,7 @@ new function() {
onLoad = options.onLoad,
view = scope.project && scope.getView();
if (onLoad)
onLoad.call(this, item);
onLoad.call(this, item, svg);
}
if (isRoot) {