refactor: 侧边栏滚动条更改为 overlayScrollbars

This commit is contained in:
Argo Zhang 2019-08-15 18:57:44 +08:00
parent 56cb6e5277
commit c19b76a8fd
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
21 changed files with 6076 additions and 3990 deletions

View File

@ -9,11 +9,13 @@
<span class="d-inline-block font-weight-bold flex-fill">@Model.DisplayName</span>
</div>
<!-- sidebar menu start-->
<ul class="sidebar nav nav-pills flex-column flex-nowrap">
@foreach (var menu in Model.Navigations)
{
@await Html.PartialAsync("SubNavItem", menu)
}
</ul>
<div class="sidebar">
<ul class="nav nav-pills flex-column flex-nowrap">
@foreach (var menu in Model.Navigations)
{
@await Html.PartialAsync("SubNavItem", menu)
}
</ul>
</div>
<!-- sidebar menu end-->
</aside>

View File

@ -6,28 +6,26 @@
<link href="~/lib/toastr.js/toastr.css" rel="stylesheet" />
<link href="~/lib/nprogress/nprogress.css" rel="stylesheet" />
<link href="~/lib/sweetalert/sweetalert2.css" rel="stylesheet" />
<link href="~/lib/scrollbar/jquery.mCustomScrollbar.css" rel="stylesheet" />
<link href="~/lib/overlayscrollbars/OverlayScrollbars.css" rel="stylesheet" />
</environment>
<environment exclude="Development">
<link href="~/lib/toastr.js/toastr.min.css" rel="stylesheet" />
<link href="~/lib/nprogress/nprogress.min.css" rel="stylesheet" />
<link href="~/lib/sweetalert/sweetalert2.min.css" rel="stylesheet" />
<link href="~/lib/scrollbar/jquery.mCustomScrollbar.min.css" rel="stylesheet" />
<link href="~/lib/overlayscrollbars/OverlayScrollbars.min.css" rel="stylesheet" />
</environment>
@RenderSection("css", false)
}
@section javascript {
<environment include="Development">
<script src="~/lib/scrollbar/jquery.mousewheel.js"></script>
<script src="~/lib/scrollbar/jquery.mCustomScrollbar.js"></script>
<script src="~/lib/overlayscrollbars/jquery.overlayScrollbars.js"></script>
<script src="~/lib/signalr/dist/browser/signalr.js"></script>
<script src="~/lib/dcjqaccordion/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="~/lib/sweetalert/sweetalert2.js" rel="stylesheet"></script>
<script src="~/lib/nprogress/nprogress.js"></script>
</environment>
<environment exclude="Development">
<script src="~/lib/scrollbar/jquery.mousewheel.min.js"></script>
<script src="~/lib/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="~/lib/overlayscrollbars/jquery.overlayScrollbars.min.js"></script>
<script src="~/lib/signalr/dist/browser/signalr.min.js"></script>
<script src="~/lib/dcjqaccordion/js/jquery.dcjqaccordion.2.7.min.js"></script>
<script src="~/lib/sweetalert/sweetalert2.min.js" rel="stylesheet"></script>

View File

@ -134,7 +134,7 @@ aside {
}
aside .sidebar {
padding-top: 0;
top: 139px;
}
aside .nav-brand, aside .nav-header {

View File

@ -99,6 +99,15 @@
overflow: hidden;
bottom: 40px;
}
aside .sidebar {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
}
}
@media (min-width: 940px) {

View File

@ -241,12 +241,12 @@ body, .form-control, .dropdown-menu, .btn:not(.btn-lg):not(.btn-xs), .input-grou
}
.sidebar {
padding: 20px 0;
padding: 0;
background: inherit;
}
.sidebar .nav-item {
margin: 5px 10px;
margin: 2px 10px;
}
.sidebar .nav-item .nav-link:hover, .sidebar .nav-item .nav-link:focus {
@ -258,6 +258,14 @@ body, .form-control, .dropdown-menu, .btn:not(.btn-lg):not(.btn-xs), .input-grou
color: #FF6C60;
}
.sidebar ul {
margin: 5px 0;
}
.sidebar ul ul {
margin: 0;
}
.sidebar .nav-link {
color: #aeb2b7;
padding: 10px 10px;

View File

@ -130,7 +130,7 @@
})(jQuery);
$(function () {
var $sideMenu = $(".sidebar");
var $sideMenu = $(".sidebar ul");
// 临时使用脚本解决多层菜单收缩问题
// Issue https://gitee.com/LongbowEnterprise/dashboard/issues?id=I1067G
@ -139,6 +139,7 @@ $(function () {
var $li = $activeLink.parent('li').addClass('active');
$activeLink = $li.parent().prev().addClass('active');
}
$sideMenu.dcAccordion({
autoExpand: true,
saveState: false
@ -174,23 +175,21 @@ $(function () {
return this;
},
addNiceScroll: function () {
if ($.browser.versions.ios && $(window).width() > 768) {
this.css('overflow', 'auto');
}
else if (!$.browser.versions.ios && $(window).width() > 768) {
this.mCustomScrollbar({ theme: 'minimal', mouseWheel: { scrollAmount: 60 } });
if (!$.browser.versions.ios && $(window).width() > 768) {
this.overlayScrollbars({ className: 'os-theme-light', scrollbars: { autoHide: 'leave' } });
}
else {
this.mCustomScrollbar('destroy');
this.css('overflow', 'auto');
}
return this;
}
});
// custom scrollbar
var $sidebar = $('aside').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 });
var $sidebar = $('.sidebar').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 });
$sideMenu.on('click', 'a.dcjq-parent', function () {
return;
var $this = $(this);
if (!$.browser.versions.ios && $(window).width() > 768) {
setTimeout(function () {
@ -300,6 +299,6 @@ $(function () {
});
$(window).on('resize', function () {
$sidebar.addNiceScroll();
//$sidebar.addNiceScroll();
});
});

View File

@ -16,7 +16,7 @@
$('#main-content').scrollspy({ offset: 150, target: '.fa-nav' });
if (!$.browser.versions.ios) $html.find('.fa-nav .nav').mCustomScrollbar({ theme: 'minimal-dark' });
if (!$.browser.versions.ios) $html.find('.fa-nav .nav').overlayScrollbars({ className: 'os-theme-light', scrollbars: { autoHide: 'leave' } });
}
}
});

View File

@ -277,7 +277,7 @@ $(function () {
$(this).scrollspy({ target: $(this).attr('data-target') });
});
if (!$.browser.versions.ios) $scroll = $html.find('.fa-nav .nav').mCustomScrollbar({ theme: 'minimal-dark' });
if (!$.browser.versions.ios) $scroll = $html.find('.fa-nav .nav').overlayScrollbars({ className: 'os-theme-light', scrollbars: { autoHide: 'leave' } });
}
}
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,221 +0,0 @@
/*!
* jQuery Mousewheel 3.1.13
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*/
(function (factory) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
}
}
var special = $.event.special.mousewheel = {
version: '3.1.12',
setup: function() {
if ( this.addEventListener ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
// Store the line height and page height for this particular element
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
// Clean up the data we added to the element
$.removeData(this, 'mousewheel-line-height');
$.removeData(this, 'mousewheel-page-height');
},
getLineHeight: function(elem) {
var $elem = $(elem),
$parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
if (!$parent.length) {
$parent = $('body');
}
return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
},
getPageHeight: function(elem) {
return $(elem).height();
},
settings: {
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
normalizeOffset: true // calls getBoundingClientRect for each event
}
};
$.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,
deltaX = 0,
deltaY = 0,
absDelta = 0,
offsetX = 0,
offsetY = 0;
event = $.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}
// No change actually happened, no reason to go any further
if ( deltaY === 0 && deltaX === 0 ) { return; }
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if ( orgEvent.deltaMode === 1 ) {
var lineHeight = $.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if ( orgEvent.deltaMode === 2 ) {
var pageHeight = $.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
// Normalise offsetX and offsetY properties
if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
var boundingRect = this.getBoundingClientRect();
offsetX = event.clientX - boundingRect.left;
offsetY = event.clientY - boundingRect.top;
}
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
event.offsetX = offsetX;
event.offsetY = offsetY;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
}));

View File

@ -1,8 +0,0 @@
/*!
* jQuery Mousewheel 3.1.13
*
* Copyright 2015 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 B