Duder-onomy / svgpan

Automatically exported from code.google.com/p/svgpan
0 stars 0 forks source link

Does not find first g-element, only works with id="viewport" attribute #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Using the sample lion.svg, remove the 'id="viewport"' attribute. 

What is the expected output? What do you see instead?
When the element with id="viewport" is not found, the library should find the 
first g-element, and the functionality should still be available. But zooming 
and panning is not available.

What version of the product are you using? On what operating system?
Version 1.2.2 in Firefox 15.0.1 on Mac OS 10.6.8.

Please provide any additional information below.
Resolved by modifying function getRoot():
Original:
    var r = root.getElementById("viewport") ? root.getElementById("viewport") : root.documentElement, t = r;
Fixed:
    var r = root.getElementById("viewport");
    if (!r) r = root.documentElement.getElementsByTagName ('g')[0];
    var t = r;

Original issue reported on code.google.com by rdu...@mcmillan-mcgee.com on 2 Oct 2012 at 4:56