-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathjQueryMixin.js
More file actions
82 lines (71 loc) · 1.76 KB
/
Copy pathjQueryMixin.js
File metadata and controls
82 lines (71 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function call_show_method ($node, props) {
$node[props.showMethod]({
duration: props.showDuration,
easing: props.showEasing
});
}
module.exports = {
getDefaultProps () {
return {
style: {
display: "none" // effective $.hide()
},
showMethod: "fadeIn", //, slideDown, and show are built into jQuery
showDuration: 300,
showEasing: "swing", // and linear are built into jQuery
hideMethod: "fadeOut",
hideDuration: 1000,
hideEasing: "swing",
//
timeOut: 5000,
extendedTimeOut: 1000
};
},
getInitialState () {
return {
intervalId: null,
isHiding: false
};
},
componentDidMount () {
var {props} = this;
call_show_method(this._get_$_node(), props);
if (props.timeOut > 0) {
this._set_interval_id(
setTimeout(this.hideToast, props.timeOut)
);
}
},
handleMouseEnter () {
clearTimeout(this.state.intervalId);
this._set_interval_id(null);
call_show_method(this._get_$_node().stop(true, true), this.props);
},
handleMouseLeave () {
var {props} = this;
if (!this.state.isHiding &&
(props.timeOut > 0 || props.extendedTimeOut > 0)) {
this._set_interval_id(
setTimeout(this.hideToast, props.extendedTimeOut)
);
}
},
hideToast (override) {
var {state, props} = this;
if (state.isHiding || (state.intervalId == null && !override)) return;
this.setState({isHiding: true});
this._get_$_node()[props.hideMethod]({
duration: props.hideDuration,
easing: props.hideEasing,
complete: this._handle_remove
});
},
_get_$_node () {
return $(this.getDOMNode());
},
_set_interval_id (intervalId) {
this.setState({
intervalId
});
}
};