File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 153
153
// Create Raphael paper
154
154
self . paper = new Raphael ( self . $map [ 0 ] , self . mapConf . width , self . mapConf . height ) ;
155
155
156
+ // issue #135: Check if we are drawing on a hidden paper
157
+ // This is known to cause problem for Raphael and text element boundaries
158
+ if ( self . isPaperHidden ( ) === true ) {
159
+ throw new Error ( "Drawing on hidden paper is not supported (see src/doc for workaround)" ) ;
160
+ }
161
+
156
162
// add plugin class name on element
157
163
self . $container . addClass ( pluginName ) ;
158
164
1681
1687
} , interval
1682
1688
) ;
1683
1689
} ,
1690
+
1691
+ /*
1692
+ * Check for Raphael bug regarding drawing while beeing hidden (under display:none)
1693
+ * See https://github.com/neveldo/jQuery-Mapael/issues/135
1694
+ * @return true/false
1695
+ *
1696
+ * Wants to override this behavior? Use prototype overriding:
1697
+ * $.mapael.prototype.isPaperHidden = function() {return false;};
1698
+ */
1699
+ isPaperHidden : function ( ) {
1700
+ // Draw text, then get its boundaries
1701
+ var text_elem = self . paper . text ( - 50 , - 50 , "TEST" ) ;
1702
+ var text_elem_bbox = text_elem . getBBox ( ) ;
1703
+ // remove element
1704
+ text_elem . remove ( ) ;
1705
+ // If it has no height and width, then the paper is hidden
1706
+ if ( text_elem_bbox . width === 0 && text_elem_bbox . height === 0 ) {
1707
+ return true ;
1708
+ } else {
1709
+ return false ;
1710
+ }
1711
+ } ,
1684
1712
1685
1713
// Default map options
1686
1714
defaultOptions : {
You can’t perform that action at this time.
0 commit comments