Refactor to delete mousewheel.js.

This old third party library added support
for a "mousewheel" event to detect scrolling.
However, it is not compatible with jQuery 3
and is obsolete now that there is a standard
"wheel" event that accomplishes the same thing.
This commit is contained in:
Cory Lynch
2017-07-02 19:53:36 -04:00
committed by showell
parent ca14292334
commit 802ea9abf5
6 changed files with 13 additions and 100 deletions

View File

@@ -154,10 +154,6 @@ Copyright: 2011-2013 Henrique Boaventura
License: Expat
Comment: The software has been modified.
Files: static/third/jquery-mousewheel/jquery.mousewheel.js
Copyright: 2011 Brandon Aaron
License: Expat
Files: static/third/jquery-throttle-debounce/*
Copyright: 2010 "Cowboy" Ben Alman
License: Expat or GPL

View File

@@ -691,7 +691,7 @@ exports.all = new exports.MessageList(
// doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events.
$(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', function () {
$(document).on('message_selected.zulip zuliphashchange.zulip wheel', function () {
message_viewport.stop_auto_scrolling();
});

View File

@@ -54,11 +54,11 @@ $(function () {
// scroll handler, but when we're at the top or bottom of the
// page, the pointer may still need to move.
if (delta > 0) {
if (delta < 0) {
if (message_viewport.at_top()) {
navigate.up();
}
} else if (delta < 0) {
} else if (delta > 0) {
if (message_viewport.at_bottom()) {
navigate.down();
}
@@ -67,7 +67,8 @@ $(function () {
message_viewport.last_movement_direction = delta;
});
message_viewport.message_pane.mousewheel(function (e, delta) {
message_viewport.message_pane.on('wheel', function (e) {
var delta = e.originalEvent.deltaY;
if (!overlays.is_active()) {
// In the message view, we use a throttled mousewheel handler.
throttled_mousewheelhandler(e, delta);
@@ -83,23 +84,24 @@ $(function () {
// propagation in all cases. Also, ignore the event if the
// element is already at the top or bottom. Otherwise we get a
// new scroll event on the parent (?).
$('.modal-body, .scrolling_list, input, textarea').mousewheel(function (e, delta) {
$('.modal-body, .scrolling_list, input, textarea').on('wheel', function (e) {
var self = $(this);
var scroll = self.scrollTop();
var delta = e.originalEvent.deltaY;
// The -1 fudge factor is important here due to rounding errors. Better
// to err on the side of not scrolling.
var max_scroll = this.scrollHeight - self.innerHeight() - 1;
e.stopPropagation();
if ( ((delta > 0) && (scroll <= 0))
|| ((delta < 0) && (scroll >= max_scroll))) {
if ( ((delta < 0) && (scroll <= 0))
|| ((delta > 0) && (scroll >= max_scroll))) {
e.preventDefault();
}
});
// Ignore wheel events in the compose area which weren't already handled above.
$('#compose').mousewheel(function (e) {
$('#compose').on('wheel', function (e) {
e.stopPropagation();
e.preventDefault();
});

View File

@@ -41,14 +41,14 @@
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
**/
(function( $ ){
$.fn.idle = function(options) {
var defaults = {
idle: 60000, //idle time in ms
events: 'mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove', //events that will trigger the idle resetter
events: 'mousemove keydown DOMMouseScroll mousedown touchstart touchmove wheel', //events that will trigger the idle resetter
onIdle: function(){}, //callback function to be executed after idle time
onActive: function(){}, //callback function to be executed after back from idleness
keepTracking: false //if you want to keep tracking user even after the first time, set this to true
@@ -117,5 +117,5 @@
elem.on(settings.events, handler);
return control;
};
};
})( jQuery );

View File

@@ -1,84 +0,0 @@
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/
(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},
unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});
function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";
// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
// New school multidimensional scroll (touchpads) deltas
deltaY = delta;
// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
})(jQuery);

View File

@@ -819,7 +819,6 @@ JS_SPECS = {
'third/jquery-filedrop/jquery.filedrop.js',
'third/jquery-caret/jquery.caret.1.5.2.js',
'node_modules/xdate/src/xdate.js',
'third/jquery-mousewheel/jquery.mousewheel.js',
'third/jquery-throttle-debounce/jquery.ba-throttle-debounce.js',
'third/jquery-idle/jquery.idle.js',
'third/jquery-autosize/jquery.autosize.js',