2017-09-05 1 views
1

Je suis en train de charger le svg enregistré sur toile afin que je puisse modifier et enregistrer à nouveau. donc je reçois le tableau dans le champ caché et le chargement de ce tableau dans la toile:svg images chargement sur la toile après la deuxième actualisation du navigateur

<input type="hidden" name="insert_arry" value='<?=htmlspecialchars($get_result[$insert])?>' id="insert_arry"> 
// script for loading the json array of svg on canvas 
// loading the view of canvas here 
opc_Canvas_Load(
    opc_View[opc_Current_View].path.replace('thumb','large'), 
    opc_Current_View 
); 
responsive_slide('opc_Product_Slider', 'pWrapper'); 
jq(window).resize(function() { 
    opc_Canvas_Load(opc_OverlayImg, opc_Current_View); 
}); 

// tried to load the div first of canvas using jquery, won't work 
$(".handler-area").first().css('display', 'block'); 

// getting the array stored in to the hidden field 
var insert_arry = jq('#insert_arry').val(); 

// loading the json array in canvas 
canvas.loadFromJSON(insert_arry.substring(1, insert_arry.length - 1)); 

charges d'objets sur la toile, mais il montre les images après les navigateurs de rafraîchissement. cela peut être le problème de chargement d'image, mais n'a pas pu trouver exact pour résoudre le problème.

+0

'loadFromJSON' vient de la bibliothèque fabric.js? Pourriez-vous ajouter un [MCVE] avec quelques données minimales passées au lieu de ''? – Kaiido

+0

[{"objects": [], "background": "", "backgroundImage": {"type": "image", "originX": "gauche", "originY": "top", "left": 0, "top": 0, "width": 1200, "height": 960, "remplir": "rgb (0,0,0)", "stroke": null, "strokeWidth": 1, "strokeDashArray" : null, "strokeLineCap": "butt", "strokeLineJoin": "mitre", "strokeMiterLimit": 10, "scaleX": 1, "scaleY": 1, "angle": 0, "flipX": false, " flipY ": false}] – Harsh

+0

son trop grand tableau donc je ne pouvais pas mettre tout le contenu dans le tableau .. je viens de raccourcir le contenu du tableau. – Harsh

Répondre

1
// Wow ... Aftera lot of try i m done with this task 
///// working code 

var insert_arry = jq('#insert_arry').val(); 
canvas.loadFromJSON(insert_arry.substring(1, insert_arry .length-1)); 
var img = new Image(); img.onload = function() { 
opc_Canvas_Load(opc_View[opc_Current_View].path.replace(‌​'thumb', 'large'), 
opc_Current_View); responsive_slide('opc_Product_Slider', 'pWrapper'); 
jq(window).resize(function() { opc_Canvas_Load(opc_OverlayImg, opc_Current_View); }); } 

Nice !!!!!