1 // jQuery Autohide v1.0.2
 2 // (c) 2014 Alex Taujenis
 3 // MIT License
 4 
 5 (function($) {
 6   return $.fn.autohide = function(opts) {
 7     var Delay;
 8     Delay = (function() {
 9       Delay.prototype.timeout = 1000;
10 
11       function Delay(el, opts) {
12         this.el = el;
13         if ((opts != null) && ("timeout" in opts)) {
14           this.timeout = parseInt(opts["timeout"]);
15         }
16         $(window).mousemove(((function(_this) {
17           return function() {
18             return _this.mouseDelay();
19           };
20         })(this)));
21         this;
22       }
23 
24       Delay.prototype.mouseDelay = function() {
25         if (!this.shown) {
26           this.showMouse();
27         }
28         window.clearTimeout(this.mouse_timeout);
29         this.mouse_timeout = window.setTimeout(((function(_this) {
30           return function() {
31             return _this.hideMouse();
32           };
33         })(this)), this.timeout);
34       };
35 
36       Delay.prototype.showMouse = function() {
37         this.el.css("cursor", "default");
38         this.shown = true;
39       };
40 
41       Delay.prototype.hideMouse = function() {
42         this.el.css("cursor", "none");
43         this.shown = false;
44       };
45 
46       return Delay;
47 
48     })();
49     new Delay(this, opts);
50     return this;
51   };
52 })(jQuery);
jQuery-autohide源码

相关文章:

猜你喜欢
  • 2021-04-02
  • 2022-03-04
  • 2021-11-22
  • 2021-04-22
  • 2021-08-21
  • 2021-09-04
  • 2021-07-09
相关资源
相似解决方案