Browse Source

Upgrade nanoscroller

Fixed bug with invalid nano-content width
master
Igor Zhukov 10 years ago
parent
commit
59e4625b05
  1. 6
      app/vendor/jquery.nanoscroller/nanoscroller.css
  2. 61
      app/vendor/jquery.nanoscroller/nanoscroller.js

6
app/vendor/jquery.nanoscroller/nanoscroller.css vendored

@ -18,10 +18,10 @@
outline: thin dotted; outline: thin dotted;
} }
.nano > .nano-content::-webkit-scrollbar { .nano > .nano-content::-webkit-scrollbar {
visibility: hidden; display: none;
} }
.has-scrollbar > .nano-content::-webkit-scrollbar { .has-scrollbar > .nano-content::-webkit-scrollbar {
visibility: visible; display: block;
} }
.nano > .nano-pane { .nano > .nano-pane {
background : rgba(0,0,0,.25); background : rgba(0,0,0,.25);
@ -52,4 +52,4 @@
.nano:hover > .nano-pane, .nano-pane.active, .nano-pane.flashed { .nano:hover > .nano-pane, .nano-pane.active, .nano-pane.flashed {
visibility : visible\9; /* Target only IE7 and IE8 with this hack */ visibility : visible\9; /* Target only IE7 and IE8 with this hack */
opacity : 0.99; opacity : 0.99;
} }

61
app/vendor/jquery.nanoscroller/nanoscroller.js vendored

@ -1,9 +1,9 @@
/*! nanoScrollerJS - v0.8.0 - 2014 /*! nanoScrollerJS - v0.8.4 - 2014
* http://jamesflorentino.github.com/nanoScrollerJS/ * http://jamesflorentino.github.com/nanoScrollerJS/
* Copyright (c) 2014 James Florentino; Licensed MIT */ * Copyright (c) 2014 James Florentino; Licensed MIT */
(function($, window, document) { (function($, window, document) {
"use strict"; "use strict";
var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, cAF, defaults, getBrowserScrollbarWidth, hasTransform, isFFWithBuggyScrollbar, rAF, transform, _elementStyle, _prefixStyle, _vendor; var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, ENTER, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEENTER, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, cAF, defaults, getBrowserScrollbarWidth, hasTransform, isFFWithBuggyScrollbar, rAF, transform, _elementStyle, _prefixStyle, _vendor;
defaults = { defaults = {
/** /**
@ -130,6 +130,14 @@
*/ */
MOUSEDOWN = 'mousedown'; MOUSEDOWN = 'mousedown';
/**
@property MOUSEENTER
@type String
@final
@private
*/
MOUSEENTER = 'mouseenter';
/** /**
@property MOUSEMOVE @property MOUSEMOVE
@type String @type String
@ -173,6 +181,15 @@
*/ */
DRAG = 'drag'; DRAG = 'drag';
/**
@property ENTER
@type String
@static
@final
@private
*/
ENTER = 'enter';
/** /**
@property UP @property UP
@type String @type String
@ -338,6 +355,7 @@
this.$el = $(this.el); this.$el = $(this.el);
this.doc = $(this.options.documentContext || document); this.doc = $(this.options.documentContext || document);
this.win = $(this.options.windowContext || window); this.win = $(this.options.windowContext || window);
this.body = this.doc.find('body');
this.$content = this.$el.children("." + options.contentClass); this.$content = this.$el.children("." + options.contentClass);
this.$content.attr('tabindex', this.options.tabIndex || 0); this.$content.attr('tabindex', this.options.tabIndex || 0);
this.content = this.$content[0]; this.content = this.$content[0];
@ -443,14 +461,15 @@
}; };
} }
if (rAF) { if (rAF) {
if (!this.scrollRAF) { if (cAF && this.scrollRAF) {
this.scrollRAF = rAF((function(_this) { cAF(this.scrollRAF);
return function() {
_this.scrollRAF = null;
_this.slider.css(cssValue);
};
})(this));
} }
this.scrollRAF = rAF((function(_this) {
return function() {
_this.scrollRAF = null;
return _this.slider.css(cssValue);
};
})(this));
} else { } else {
this.slider.css(cssValue); this.slider.css(cssValue);
} }
@ -469,14 +488,18 @@
return function(e) { return function(e) {
_this.isBeingDragged = true; _this.isBeingDragged = true;
_this.offsetY = e.pageY - _this.slider.offset().top; _this.offsetY = e.pageY - _this.slider.offset().top;
if (!_this.slider.is(e.target)) {
_this.offsetY = 0;
}
_this.pane.addClass('active'); _this.pane.addClass('active');
_this.doc.bind(MOUSEMOVE, _this.events[DRAG]).bind(MOUSEUP, _this.events[UP]); _this.doc.bind(MOUSEMOVE, _this.events[DRAG]).bind(MOUSEUP, _this.events[UP]);
_this.body.bind(MOUSEENTER, _this.events[ENTER]);
return false; return false;
}; };
})(this), })(this),
drag: (function(_this) { drag: (function(_this) {
return function(e) { return function(e) {
_this.sliderY = e.pageY - _this.$el.offset().top - _this.offsetY; _this.sliderY = e.pageY - _this.$el.offset().top - _this.paneTop - (_this.offsetY || _this.sliderHeight * 0.5);
_this.scroll(); _this.scroll();
if (_this.contentScrollTop >= _this.maxScrollTop && _this.prevScrollTop !== _this.maxScrollTop) { if (_this.contentScrollTop >= _this.maxScrollTop && _this.prevScrollTop !== _this.maxScrollTop) {
_this.$el.trigger('scrollend'); _this.$el.trigger('scrollend');
@ -491,6 +514,7 @@
_this.isBeingDragged = false; _this.isBeingDragged = false;
_this.pane.removeClass('active'); _this.pane.removeClass('active');
_this.doc.unbind(MOUSEMOVE, _this.events[DRAG]).unbind(MOUSEUP, _this.events[UP]); _this.doc.unbind(MOUSEMOVE, _this.events[DRAG]).unbind(MOUSEUP, _this.events[UP]);
_this.body.unbind(MOUSEENTER, _this.events[ENTER]);
return false; return false;
}; };
})(this), })(this),
@ -550,6 +574,17 @@
_this.scroll(); _this.scroll();
return false; return false;
}; };
})(this),
enter: (function(_this) {
return function(e) {
var _ref;
if (!_this.isBeingDragged) {
return;
}
if ((e.buttons || e.which) !== 1) {
return (_ref = _this.events)[UP].apply(_ref, arguments);
}
};
})(this) })(this)
}; };
}; };
@ -611,7 +646,7 @@
this.pane = this.$el.children("." + paneClass); this.pane = this.$el.children("." + paneClass);
this.slider = this.pane.find("." + sliderClass); this.slider = this.pane.find("." + sliderClass);
if (BROWSER_SCROLLBAR_WIDTH === 0 && isFFWithBuggyScrollbar()) { if (BROWSER_SCROLLBAR_WIDTH === 0 && isFFWithBuggyScrollbar()) {
currentPadding = window.getComputedStyle(this.content, null).getPropertyValue('padding-right').replace(/\D+/g, ''); currentPadding = window.getComputedStyle(this.content, null).getPropertyValue('padding-right').replace(/[^0-9.]+/g, '');
cssRule = { cssRule = {
right: -14, right: -14,
paddingRight: +currentPadding + 14 paddingRight: +currentPadding + 14
@ -695,6 +730,7 @@
this.paneHeight = paneHeight; this.paneHeight = paneHeight;
this.paneOuterHeight = paneOuterHeight; this.paneOuterHeight = paneOuterHeight;
this.sliderHeight = sliderHeight; this.sliderHeight = sliderHeight;
this.paneTop = paneTop;
this.slider.height(sliderHeight); this.slider.height(sliderHeight);
this.events.scroll(); this.events.scroll();
this.pane.show(); this.pane.show();
@ -738,7 +774,7 @@
} }
this.sliderY = Math.max(0, this.sliderY); this.sliderY = Math.max(0, this.sliderY);
this.sliderY = Math.min(this.maxSliderTop, this.sliderY); this.sliderY = Math.min(this.maxSliderTop, this.sliderY);
this.$content.scrollTop((this.paneHeight - this.contentHeight + BROWSER_SCROLLBAR_WIDTH) * this.sliderY / this.maxSliderTop * -1); this.$content.scrollTop(this.maxScrollTop * this.sliderY / this.maxSliderTop);
if (!this.iOSNativeScrolling) { if (!this.iOSNativeScrolling) {
this.updateScrollValues(); this.updateScrollValues();
this.setOnScrollStyles(); this.setOnScrollStyles();
@ -926,3 +962,4 @@
}; };
$.fn.nanoScroller.Constructor = NanoScroll; $.fn.nanoScroller.Constructor = NanoScroll;
})(jQuery, window, document); })(jQuery, window, document);

Loading…
Cancel
Save