remove hoverIntent

more-scalatags
Thibault Duplessis 2019-04-08 09:30:26 +07:00
parent c001e14270
commit f835092d58
8 changed files with 0 additions and 173 deletions

View File

@ -1,153 +0,0 @@
/*!
* MODIFICATION OF hoverIntent v1.8.1 // 2014.08.11 // jQuery v1.9.1+
* http://cherne.net/brian/resources/jquery.hoverIntent.html
*
* You may use hoverIntent under the terms of the MIT license. Basically that
* means you are free to use hoverIntent as long as this header is left intact.
* Copyright 2007, 2014 Brian Cherne
*/
/* hoverIntent is similar to jQuery's built-in "hover" method except that
* instead of firing the handlerIn function immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the event. The handlerOut function is only
* called after a matching handlerIn.
*
* // basic usage ... just like .hover()
* .hoverIntent( handlerIn, handlerOut )
* .hoverIntent( handlerInOut )
*
* // basic usage ... with event delegation!
* .hoverIntent( handlerIn, handlerOut, selector )
* .hoverIntent( handlerInOut, selector )
*
* // using a basic configuration object
* .hoverIntent( config )
*
* @param handlerIn function OR configuration object
* @param handlerOut function OR selector for delegation OR undefined
* @param selector selector OR undefined
* @author Brian Cherne <brian(at)cherne(dot)net>
*/
(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (jQuery && !jQuery.fn.hoverIntent) {
factory(jQuery);
}
})(function($) {
'use strict';
// default configuration values
var _cfg = {
interval: 100,
sensitivity: 6,
timeout: 0
};
// counter used to generate an ID for each instance
var INSTANCE_COUNT = 0;
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
var cX, cY;
// saves the current pointer position coordinated based on the given mouse event
var track = function(ev) {
cX = ev.pageX;
cY = ev.pageY;
};
// compares current and previous mouse positions
var compare = function(ev,$el,s,cfg) {
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
$el.off('mousemove.hoverIntent'+s.namespace,track);
delete s.timeoutId;
// set hoverIntent state as active for this element (so `out` handler can eventually be called)
s.isActive = true;
// clear coordinate data
delete s.pX; delete s.pY;
return cfg.over.apply($el[0],[ev]);
} else {
// set previous coordinates for next comparison
s.pX = cX; s.pY = cY;
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
}
};
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
var delay = function(ev,$el,s,out) {
delete $el.data('hoverIntent')[s.id];
return out.apply($el[0],[ev]);
};
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
// instance ID, used as a key to store and retrieve state information on an element
var instanceId = INSTANCE_COUNT++;
// extend the default configuration and parse parameters
var cfg = $.extend({}, _cfg);
if ( $.isPlainObject(handlerIn) ) {
cfg = $.extend(cfg, handlerIn );
} else if ($.isFunction(handlerOut)) {
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
} else {
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
}
// A private function for handling mouse 'hovering'
var handleHover = function(e) {
// cloned event to pass to handlers (copy required for event object to be passed in IE)
var ev = $.extend({},e);
// the current target of the mouse event, wrapped in a jQuery object
var $el = $(this);
// read hoverIntent data from element (or initialize if not present)
var hoverIntentData = $el.data('hoverIntent');
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
// read per-instance state from element (or initialize if not present)
var state = hoverIntentData[instanceId];
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
// state properties:
// id = instance ID, used to clean up data
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
// isActive = plugin state, true after `over` is called just until `out` is called
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
// namespace = string used as namespace for per-instance event management
// clear any existing timeout
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
// event namespace, used to register and unregister mousemove tracking
var namespace = state.namespace = '.hoverIntent'+instanceId;
// handle the event, based on its type
if (e.type === 'mouseenter') {
// do nothing if already active or mouse left button is down
if (state.isActive || e.buttons === 1) { return; }
// set "previous" X and Y position based on initial entry point
state.pX = ev.pageX; state.pY = ev.pageY;
// update "current" X and Y position based on mousemove
$el.on('mousemove.hoverIntent'+namespace,track);
// start polling interval (self-calling timeout) to compare mouse coordinates over time
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
} else { // "mouseleave"
// do nothing if not already active
if (!state.isActive) { return; }
// unbind expensive mousemove event
$el.off('mousemove.hoverIntent'+namespace,track);
// if hoverIntent state is true, then call the mouseOut function after the specified delay
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
}
};
// listen for mouseenter and mouseleave
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
};
});

View File

@ -1 +0,0 @@
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):jQuery&&!jQuery.fn.hoverIntent&&e(jQuery)}(function(e){"use strict";var t,n,o={interval:100,sensitivity:6,timeout:0},i=0,r=function(e){t=e.pageX,n=e.pageY},u=function(e,o,i,s){if(Math.sqrt((i.pX-t)*(i.pX-t)+(i.pY-n)*(i.pY-n))<s.sensitivity)return o.off("mousemove.hoverIntent"+i.namespace,r),delete i.timeoutId,i.isActive=!0,delete i.pX,delete i.pY,s.over.apply(o[0],[e]);i.pX=t,i.pY=n,i.timeoutId=setTimeout(function(){u(e,o,i,s)},s.interval)},s=function(e,t,n,o){return delete t.data("hoverIntent")[n.id],o.apply(t[0],[e])};e.fn.hoverIntent=function(t,n,v){var a=i++,d=e.extend({},o);d=e.isPlainObject(t)?e.extend(d,t):e.isFunction(n)?e.extend(d,{over:t,out:n,selector:v}):e.extend(d,{over:t,out:t,selector:n});var f=function(t){var n=e.extend({},t),o=e(this),i=o.data("hoverIntent");i||o.data("hoverIntent",i={});var v=i[a];v||(i[a]=v={id:a}),v.timeoutId&&(v.timeoutId=clearTimeout(v.timeoutId));var f=v.namespace=".hoverIntent"+a;if("mouseenter"===t.type){if(v.isActive||1===t.buttons)return;v.pX=n.pageX,v.pY=n.pageY,o.on("mousemove.hoverIntent"+f,r),v.timeoutId=setTimeout(function(){u(n,o,v,d)},d.interval)}else{if(!v.isActive)return;o.off("mousemove.hoverIntent"+f,r),v.timeoutId=setTimeout(function(){s(n,o,v,d.out)},d.timeout)}};return this.on({"mouseenter.hoverIntent":f,"mouseleave.hoverIntent":f},d.selector)}});

View File

@ -38,7 +38,6 @@ interface Lichess {
challengeApp: any;
hopscotch: any;
makeChat(data: any, callback?: (chat: any) => void): void;
topnavIntent(): void;
timeago: {
render(nodes: HTMLElement | HTMLElement[]): void;
format(date: number | Date): string;

View File

@ -28,6 +28,4 @@ export default function(cfg: AnalyseOpts) {
cfg.element = element.querySelector('main.analyse') as HTMLElement;
cfg.socketSend = li.socket.send;
analyse = start(cfg);
li.topnavIntent();
};

View File

@ -87,8 +87,6 @@ export default function(opts: RoundOpts): void {
});
if (location.pathname.lastIndexOf('/round-next/', 0) === 0)
history.replaceState(null, '', '/' + data.game.id);
if (!data.player.spectator && data.game.status.id < 25) li.topnavIntent();
$('#zentog').click(li.pubsub.emit('zen'));
li.storage.make('reload-round-tabs').listen(li.reload);
}

View File

@ -1,2 +0,0 @@
/* MODIFICATION of hoverIntent v1.8.1 // 2014.08.11 // jQuery v1.9.1+ */
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):jQuery&&!jQuery.fn.hoverIntent&&e(jQuery)}(function(e){"use strict";var t,n,o={interval:100,sensitivity:6,timeout:0},i=0,r=function(e){t=e.pageX,n=e.pageY},u=function(e,o,i,s){if(Math.sqrt((i.pX-t)*(i.pX-t)+(i.pY-n)*(i.pY-n))<s.sensitivity)return o.off("mousemove.hoverIntent"+i.namespace,r),delete i.timeoutId,i.isActive=!0,delete i.pX,delete i.pY,s.over.apply(o[0],[e]);i.pX=t,i.pY=n,i.timeoutId=setTimeout(function(){u(e,o,i,s)},s.interval)},s=function(e,t,n,o){return delete t.data("hoverIntent")[n.id],o.apply(t[0],[e])};e.fn.hoverIntent=function(t,n,v){var a=i++,d=e.extend({},o);d=e.isPlainObject(t)?e.extend(d,t):e.isFunction(n)?e.extend(d,{over:t,out:n,selector:v}):e.extend(d,{over:t,out:t,selector:n});var f=function(t){var n=e.extend({},t),o=e(this),i=o.data("hoverIntent");i||o.data("hoverIntent",i={});var v=i[a];v||(i[a]=v={id:a}),v.timeoutId&&(v.timeoutId=clearTimeout(v.timeoutId));var f=v.namespace=".hoverIntent"+a;if("mouseenter"===t.type){if(v.isActive||1===t.buttons)return;v.pX=n.pageX,v.pY=n.pageY,o.on("mousemove.hoverIntent"+f,r),v.timeoutId=setTimeout(function(){u(n,o,v,d)},d.interval)}else{if(!v.isActive)return;o.off("mousemove.hoverIntent"+f,r),v.timeoutId=setTimeout(function(){s(n,o,v,d.out)},d.timeout)}};return this.on({"mouseenter.hoverIntent":f,"mouseleave.hoverIntent":f},d.selector)}});

View File

@ -88,7 +88,6 @@ function makeBundle(filename) {
'./dep/powertip.min.js',
'./dep/howler.min.js',
'./dep/mousetrap.min.js',
'./dep/hoverintent.min.js',
'./dist/' + filename,
...(abFile ? ['./dist/ab.js'] : []),
'./dist/consolemsg.js',

View File

@ -1,9 +1,3 @@
lichess.topnavIntent = function() {
$('#topnav.hover').removeClass('hover').hoverIntent(function() {
$(this).toggleClass('hover');
});
};
(function() {
/////////////
@ -952,7 +946,6 @@ lichess.topnavIntent = function() {
});
cfg.socketSend = lichess.socket.send;
analyse = LichessAnalyse.start(cfg);
lichess.topnavIntent();
}
////////////////
@ -981,7 +974,6 @@ lichess.topnavIntent = function() {
});
lichess.makeChat(cfg.chat);
}
lichess.topnavIntent();
}
////////////////
@ -1003,7 +995,6 @@ lichess.topnavIntent = function() {
});
cfg.socketSend = lichess.socket.send;
analyse = LichessAnalyse.start(cfg);
lichess.topnavIntent();
}
////////////////
@ -1032,7 +1023,6 @@ lichess.topnavIntent = function() {
});
lichess.makeChat(cfg.chat);
}
lichess.topnavIntent();
}
////////////////
@ -1052,7 +1042,6 @@ lichess.topnavIntent = function() {
});
cfg.socketSend = lichess.socket.send;
puzzle = LichessPuzzle.default(cfg);
lichess.topnavIntent();
}
})();