@@ -212,14 +212,14 @@ function assembleCssText(tooltipModel: Model<TooltipOption>, enableTransition?:
212212}
213213
214214// If not able to make, do not modify the input `out`.
215- function makeStyleCoord ( out : number [ ] , zr : ZRenderType , container : HTMLElement | null , zrX : number , zrY : number ) {
215+ function makeStyleCoord ( out : number [ ] , zr : ZRenderType , customContainer : HTMLElement | null , zrX : number , zrY : number ) {
216216 const zrPainter = zr && zr . painter ;
217217
218- if ( container ) {
218+ if ( customContainer ) {
219219 const zrViewportRoot = zrPainter && zrPainter . getViewportRoot ( ) ;
220220 if ( zrViewportRoot ) {
221221 // Some APPs might use scale on body, so we support CSS transform here.
222- transformLocalCoord ( out , zrViewportRoot , container , zrX , zrY ) ;
222+ transformLocalCoord ( out , zrViewportRoot , customContainer , zrX , zrY ) ;
223223 }
224224 }
225225 else {
@@ -241,13 +241,11 @@ function makeStyleCoord(out: number[], zr: ZRenderType, container: HTMLElement |
241241
242242interface TooltipContentOption {
243243 /**
244- * Choose a DOM element which the tooltip element will be located in order to
245- * avoid some overflow clip but intrude outside of the container.
246- *
247- * this config can be either a DomElement, a function to choose a element
248- * or a selector string used by query delector to local a element
244+ * `false`: the DOM element will be inside the container. Default value.
245+ * `true`: the DOM element will be appended to HTML body, which avoid
246+ * some overflow clip but intrude outside of the container.
249247 */
250- appendTo : Function | HTMLElement | string
248+ appendToBody : boolean
251249}
252250
253251class TooltipHTMLContent {
@@ -294,14 +292,10 @@ class TooltipHTMLContent {
294292 const zr = this . _zr = api . getZr ( ) ;
295293
296294 let container : HTMLElement | null = null ;
297- if ( opt && opt . appendTo ) {
298- if ( typeof opt . appendTo === 'string' ) {
299- container = document . querySelector ( opt . appendTo )
300- } else if ( typeof opt . appendTo === 'function' ) {
301- container = opt . appendTo ( api . getDom ( ) )
302- } else if ( opt . appendTo instanceof HTMLElement ) {
303- container = opt . appendTo
304- }
295+ if ( opt && opt . appendToBody ) {
296+ container = this . _container = document . body
297+ } else if ( opt && opt . teleport ) {
298+ container = this . _customContainer = opt . teleport ( api . getDom ( ) ) || null ;
305299 }
306300
307301 makeStyleCoord ( this . _styleCoord , zr , container , api . getWidth ( ) / 2 , api . getHeight ( ) / 2 ) ;
0 commit comments