mirror of https://github.com/zulip/zulip.git
Use throttling on our handling of scroll events.
This actually is a bit cleaner than our last approach, because (I believe) we run our scroll handler code even after the final scroll event, which prevents the pointer from getting hidden by rapid scrolls. (imported from commit 3bde4e8f067cd2406f90c04425c6e4ffb81ea784)
This commit is contained in:
parent
8333d44f31
commit
0c3ace82d5
|
@ -27,6 +27,7 @@
|
||||||
<script type="text/javascript" src="/static/third/handlebars/handlebars-1.0.rc.1.js"></script>
|
<script type="text/javascript" src="/static/third/handlebars/handlebars-1.0.rc.1.js"></script>
|
||||||
<script type="text/javascript" src="/static/third/spin/spin.min.js"></script>
|
<script type="text/javascript" src="/static/third/spin/spin.min.js"></script>
|
||||||
<script type="text/javascript" src="/static/third/jquery-mousewheel/jquery.mousewheel.js"></script>
|
<script type="text/javascript" src="/static/third/jquery-mousewheel/jquery.mousewheel.js"></script>
|
||||||
|
<script type="text/javascript" src="/static/third/jquery-throttle-debounce/jquery.ba-throttle-debounce.min.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/setup.js"></script>
|
<script type="text/javascript" src="/static/js/setup.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/dom_access.js"></script>
|
<script type="text/javascript" src="/static/js/dom_access.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/narrow.js"></script>
|
<script type="text/javascript" src="/static/js/narrow.js"></script>
|
||||||
|
|
|
@ -124,18 +124,13 @@ $(function () {
|
||||||
sub_from_home(compose_class_name(), $('#class-nosub'));
|
sub_from_home(compose_class_name(), $('#class-nosub'));
|
||||||
});
|
});
|
||||||
|
|
||||||
var last_mousewheel_or_scroll = 0;
|
var throttled_scrollhandler = $.throttle(50, function() {
|
||||||
function do_mousewheel_or_scroll () {
|
|
||||||
if ($('#home').hasClass('active')) {
|
if ($('#home').hasClass('active')) {
|
||||||
var time = $.now();
|
|
||||||
if (time - last_mousewheel_or_scroll > 50) {
|
|
||||||
keep_pointer_in_view();
|
keep_pointer_in_view();
|
||||||
last_mousewheel_or_scroll = time;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
$(window).mousewheel(do_mousewheel_or_scroll);
|
$(window).mousewheel(throttled_scrollhandler);
|
||||||
$(window).scroll(do_mousewheel_or_scroll);
|
$(window).scroll(throttled_scrollhandler);
|
||||||
|
|
||||||
$('#sidebar a[data-toggle="pill"]').on('show', function (e) {
|
$('#sidebar a[data-toggle="pill"]').on('show', function (e) {
|
||||||
// Save the position of our old tab away, before we switch
|
// Save the position of our old tab away, before we switch
|
||||||
|
|
Loading…
Reference in New Issue