2

i would like to serialize only visible elements on my paper.

i have done some research about checking if an element is visible or not andi found an answer on How to know if raphael object is hidden?

i changed raphael.serialize.js file and on line 16 i made this change:

if (node && node.type) {

to

if (node && node.type && node.style.display !== "none") {

but in this way i get null content.

how can i get this working?

update: what i need is to convert a paper to svg. based on: http://www.benbarnett.net/2010/06/04/export-svg-from-raphael-js-to-create-a-png-bitmap/

Community
  • 1
  • 1
gerpaick
  • 801
  • 2
  • 13
  • 36
  • Based on what you said, this makes sense. What exact error are you getting? – hayesgm Aug 14 '11 at 08:04
  • i have no error. after serialize my paper and conerting to svg i get empty svg file (only definition), and $jsnser variable is empty. – gerpaick Aug 14 '11 at 09:32

2 Answers2

1

i found a soltion. i have notices on git that there are some pulls requests, so after checking in one of them was an anwser for my question. here are details: https://github.com/jspies/raphael.serialize/pull/3/commits

however what is needed to be added is:

 if( node.node.style.display == "none" ) break;

under every case of node.type

gerpaick
  • 801
  • 2
  • 13
  • 36
0

I'm not familiar with Raphaël, but maybe some of the nodes don't have a style property.

Try something like:

if (node && node.type && (node.style || {}).display !== "none") {
    // ...
}
Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • i have tried but i still get elemets on my svg that should be hidden. i checked raphael.js source and there is property style. Line 1547, 1551, 1572 – gerpaick Aug 14 '11 at 09:34