mirror of
https://github.com/atom/atom.git
synced 2026-02-13 08:04:56 -05:00
Merge pull request #13095 from atom/fb-vj-follow-through
Introduce follow through behavior for tooltips
This commit is contained in:
@@ -7,6 +7,8 @@ const listen = require('./delegated-listener')
|
||||
// This tooltip class is derived from Bootstrap 3, but modified to not require
|
||||
// jQuery, which is an expensive dependency we want to eliminate.
|
||||
|
||||
var followThroughTimer = null
|
||||
|
||||
var Tooltip = function (element, options, viewRegistry) {
|
||||
this.options = null
|
||||
this.enabled = null
|
||||
@@ -21,7 +23,7 @@ var Tooltip = function (element, options, viewRegistry) {
|
||||
|
||||
Tooltip.VERSION = '3.3.5'
|
||||
|
||||
Tooltip.TRANSITION_DURATION = 150
|
||||
Tooltip.FOLLOW_THROUGH_DURATION = 300
|
||||
|
||||
Tooltip.DEFAULTS = {
|
||||
animation: true,
|
||||
@@ -151,7 +153,11 @@ Tooltip.prototype.enter = function (event) {
|
||||
|
||||
this.hoverState = 'in'
|
||||
|
||||
if (!this.options.delay || !this.options.delay.show) return this.show()
|
||||
if (!this.options.delay ||
|
||||
!this.options.delay.show ||
|
||||
followThroughTimer) {
|
||||
return this.show()
|
||||
}
|
||||
|
||||
this.timeout = setTimeout(function () {
|
||||
if (this.hoverState === 'in') this.show()
|
||||
@@ -343,6 +349,14 @@ Tooltip.prototype.hide = function (callback) {
|
||||
|
||||
this.hoverState = null
|
||||
|
||||
clearTimeout(followThroughTimer)
|
||||
followThroughTimer = setTimeout(
|
||||
function () {
|
||||
followThroughTimer = null
|
||||
},
|
||||
Tooltip.FOLLOW_THROUGH_DURATION
|
||||
)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user