@@ -89,7 +89,7 @@ var defaults = {
8989 hasTransitions : transitionSupport ( ) ,
9090 IE : false ,
9191 // don't set manually, it will be updated by a build task after the manifest
92- semVer : '4.1.6 ' ,
92+ semVer : '4.1.7 ' ,
9393 window : win
9494 } ,
9595 core = function ( ) {
@@ -1194,106 +1194,111 @@ $.Tooltipster.prototype = {
11941194 }
11951195 else {
11961196
1197- // if the scroll happened on the window
1198- if ( event . target === env . window . document ) {
1197+ // if the origin or tooltip have been removed: do nothing, the tracker will
1198+ // take care of it later
1199+ if ( bodyContains ( self . _$origin ) && bodyContains ( self . _$tooltip ) ) {
11991200
1200- // if the origin has a fixed lineage, window scroll will have no
1201- // effect on its position nor on the position of the tooltip
1202- if ( ! self . __Geometry . origin . fixedLineage ) {
1201+ // if the scroll happened on the window
1202+ if ( event . target === env . window . document ) {
12031203
1204- // we don't need to do anything unless repositionOnScroll is true
1205- // because the tooltip will already have moved with the window
1206- // (and of course with the origin)
1207- if ( self . __options . repositionOnScroll ) {
1208- self . reposition ( event ) ;
1204+ // if the origin has a fixed lineage, window scroll will have no
1205+ // effect on its position nor on the position of the tooltip
1206+ if ( ! self . __Geometry . origin . fixedLineage ) {
1207+
1208+ // we don't need to do anything unless repositionOnScroll is true
1209+ // because the tooltip will already have moved with the window
1210+ // (and of course with the origin)
1211+ if ( self . __options . repositionOnScroll ) {
1212+ self . reposition ( event ) ;
1213+ }
12091214 }
12101215 }
1211- }
1212- // if the scroll happened on another parent of the tooltip, it means
1213- // that it's in a scrollable area and now needs to have its position
1214- // adjusted or recomputed, depending ont the repositionOnScroll
1215- // option. Also, if the origin is partly hidden due to a parent that
1216- // hides its overflow, we'll just hide (not close) the tooltip.
1217- else {
1218-
1219- var g = self . __geometry ( ) ,
1220- overflows = false ;
1221-
1222- // a fixed position origin is not affected by the overflow hiding
1223- // of a parent
1224- if ( self . _$origin . css ( 'position' ) != 'fixed' ) {
1216+ // if the scroll happened on another parent of the tooltip, it means
1217+ // that it's in a scrollable area and now needs to have its position
1218+ // adjusted or recomputed, depending ont the repositionOnScroll
1219+ // option. Also, if the origin is partly hidden due to a parent that
1220+ // hides its overflow, we'll just hide (not close) the tooltip.
1221+ else {
12251222
1226- self . __$originParents . each ( function ( i , el ) {
1227-
1228- var $el = $ ( el ) ,
1229- overflowX = $el . css ( 'overflow-x' ) ,
1230- overflowY = $el . css ( 'overflow-y' ) ;
1223+ var g = self . __geometry ( ) ,
1224+ overflows = false ;
1225+
1226+ // a fixed position origin is not affected by the overflow hiding
1227+ // of a parent
1228+ if ( self . _$origin . css ( 'position' ) != 'fixed' ) {
12311229
1232- if ( overflowX != 'visible' || overflowY != 'visible' ) {
1230+ self . __$originParents . each ( function ( i , el ) {
12331231
1234- var bcr = el . getBoundingClientRect ( ) ;
1232+ var $el = $ ( el ) ,
1233+ overflowX = $el . css ( 'overflow-x' ) ,
1234+ overflowY = $el . css ( 'overflow-y' ) ;
12351235
1236- if ( overflowX != 'visible' ) {
1236+ if ( overflowX != 'visible' || overflowY != 'visible' ) {
1237+
1238+ var bcr = el . getBoundingClientRect ( ) ;
12371239
1238- if ( g . origin . windowOffset . left < bcr . left
1239- || g . origin . windowOffset . right > bcr . right
1240- ) {
1241- overflows = true ;
1242- return false ;
1240+ if ( overflowX != 'visible' ) {
1241+
1242+ if ( g . origin . windowOffset . left < bcr . left
1243+ || g . origin . windowOffset . right > bcr . right
1244+ ) {
1245+ overflows = true ;
1246+ return false ;
1247+ }
12431248 }
1244- }
1245-
1246- if ( overflowY != 'visible' ) {
12471249
1248- if ( g . origin . windowOffset . top < bcr . top
1249- || g . origin . windowOffset . bottom > bcr . bottom
1250- ) {
1251- overflows = true ;
1252- return false ;
1250+ if ( overflowY != 'visible' ) {
1251+
1252+ if ( g . origin . windowOffset . top < bcr . top
1253+ || g . origin . windowOffset . bottom > bcr . bottom
1254+ ) {
1255+ overflows = true ;
1256+ return false ;
1257+ }
12531258 }
12541259 }
1255- }
1256-
1257- // no need to go further if fixed, for the same reason as above
1258- if ( $el . css ( 'position' ) == 'fixed' ) {
1259- return false ;
1260- }
1261- } ) ;
1262- }
1263-
1264- if ( overflows ) {
1265- self . _$tooltip . css ( 'visibility' , 'hidden' ) ;
1266- }
1267- else {
1268- self . _$tooltip . css ( 'visibility' , 'visible' ) ;
1260+
1261+ // no need to go further if fixed, for the same reason as above
1262+ if ( $el . css ( 'position' ) == 'fixed' ) {
1263+ return false ;
1264+ }
1265+ } ) ;
1266+ }
12691267
1270- // reposition
1271- if ( self . __options . repositionOnScroll ) {
1272- self . reposition ( event ) ;
1268+ if ( overflows ) {
1269+ self . _$tooltip . css ( 'visibility' , 'hidden' ) ;
12731270 }
1274- // or just adjust offset
12751271 else {
1272+ self . _$tooltip . css ( 'visibility' , 'visible' ) ;
12761273
1277- // we have to use offset and not windowOffset because this way,
1278- // only the scroll distance of the scrollable areas are taken into
1279- // account (the scrolltop value of the main window must be
1280- // ignored since the tooltip already moves with it)
1281- var offsetLeft = g . origin . offset . left - self . __Geometry . origin . offset . left ,
1282- offsetTop = g . origin . offset . top - self . __Geometry . origin . offset . top ;
1283-
1284- // add the offset to the position initially computed by the display plugin
1285- self . _$tooltip . css ( {
1286- left : self . __lastPosition . coord . left + offsetLeft ,
1287- top : self . __lastPosition . coord . top + offsetTop
1288- } ) ;
1274+ // reposition
1275+ if ( self . __options . repositionOnScroll ) {
1276+ self . reposition ( event ) ;
1277+ }
1278+ // or just adjust offset
1279+ else {
1280+
1281+ // we have to use offset and not windowOffset because this way,
1282+ // only the scroll distance of the scrollable areas are taken into
1283+ // account (the scrolltop value of the main window must be
1284+ // ignored since the tooltip already moves with it)
1285+ var offsetLeft = g . origin . offset . left - self . __Geometry . origin . offset . left ,
1286+ offsetTop = g . origin . offset . top - self . __Geometry . origin . offset . top ;
1287+
1288+ // add the offset to the position initially computed by the display plugin
1289+ self . _$tooltip . css ( {
1290+ left : self . __lastPosition . coord . left + offsetLeft ,
1291+ top : self . __lastPosition . coord . top + offsetTop
1292+ } ) ;
1293+ }
12891294 }
12901295 }
1296+
1297+ self . _trigger ( {
1298+ type : 'scroll' ,
1299+ event : event
1300+ } ) ;
12911301 }
1292-
1293- self . _trigger ( {
1294- type : 'scroll' ,
1295- event : event
1296- } ) ;
12971302 }
12981303
12991304 return self ;
0 commit comments