Fixed IE10 issue

pull/556/head^2
Abdullah Almsaeed 2015-02-16 12:56:28 -05:00
parent 174be54e9b
commit f84eb88bcf
2 changed files with 204 additions and 199 deletions

View File

@ -11,70 +11,48 @@
slimScroll: function (options) {
var defaults = {
// width in pixels of the visible scroll area
width: 'auto',
// height in pixels of the visible scroll area
height: '250px',
// width in pixels of the scrollbar and rail
size: '7px',
// scrollbar color, accepts any hex/color value
color: '#000',
// scrollbar position - left/right
position: 'right',
// distance in pixels between the side edge and the scrollbar
distance: '1px',
// default scroll position on load - top / bottom / $('selector')
start: 'top',
// sets scrollbar opacity
opacity: .4,
// enables always-on mode for the scrollbar
alwaysVisible: false,
// check if we should hide the scrollbar when user is hovering over
disableFadeOut: false,
// sets visibility of the rail
railVisible: false,
// sets rail color
railColor: '#333',
// sets rail opacity
railOpacity: .2,
// whether we should use jQuery UI Draggable to enable bar dragging
railDraggable: true,
// defautlt CSS class of the slimscroll rail
railClass: 'slimScrollRail',
// defautlt CSS class of the slimscroll bar
barClass: 'slimScrollBar',
// defautlt CSS class of the slimscroll wrapper
wrapperClass: 'slimScrollDiv',
// check if mousewheel should scroll the window if we reach top/bottom
allowPageScroll: false,
// scroll amount applied to each mouse wheel step
wheelStep: 20,
// scroll amount applied when user is using gestures
touchScrollStep: 200,
// sets border radius
borderRadius: '7px',
// sets border radius of the rail
railBorderRadius: '7px'
};
@ -167,7 +145,9 @@
me.css({
overflow: 'hidden',
width: o.width,
height: o.height
height: o.height,
//Fix for IE10
"-ms-touch-action": "none"
});
// create scrollbar rail
@ -229,7 +209,8 @@
});
$doc.bind("mouseup.slimscroll", function (e) {
isDragg = false;hideBar();
isDragg = false;
hideBar();
$doc.unbind('.slimscroll');
});
return false;
@ -264,6 +245,30 @@
hideBar();
});
if (window.navigator.msPointerEnabled) {
// support for mobile
me.bind('MSPointerDown', function (e, b) {
if (e.originalEvent.targetTouches.length)
{
// record where touch started
touchDif = e.originalEvent.targetTouches[0].pageY;
}
});
me.bind('MSPointerMove', function (e) {
// prevent scrolling the page if necessary
e.originalEvent.preventDefault();
if (e.originalEvent.targetTouches.length)
{
// see how far user swiped
var diff = (touchDif - e.originalEvent.targetTouches[0].pageY) / o.touchScrollStep;
// scroll content
scrollContent(diff, true);
touchDif = e.originalEvent.targetTouches[0].pageY;
}
});
} else {
// support for mobile
me.bind('touchstart', function (e, b) {
if (e.originalEvent.touches.length)
@ -288,6 +293,7 @@
touchDif = e.originalEvent.touches[0].pageY;
}
});
}
// set up initial height
getBarHeight();
@ -305,7 +311,9 @@
scrollContent($(o.start).position().top, null, true);
// make sure bar stays hidden
if (!o.alwaysVisible) { bar.hide(); }
if (!o.alwaysVisible) {
bar.hide();
}
}
// attach scroll events
@ -314,13 +322,19 @@
function _onWheel(e)
{
// use mouse wheel only when mouse is over
if (!isOverPanel) { return; }
if (!isOverPanel) {
return;
}
var e = e || window.event;
var delta = 0;
if (e.wheelDelta) { delta = -e.wheelDelta/120; }
if (e.detail) { delta = e.detail / 3; }
if (e.wheelDelta) {
delta = -e.wheelDelta / 120;
}
if (e.detail) {
delta = e.detail / 3;
}
var target = e.target || e.srcTarget || e.srcElement;
if ($(target).closest('.' + o.wrapperClass).is(me.parent())) {
@ -329,8 +343,12 @@
}
// stop window scroll
if (e.preventDefault && !releaseScroll) { e.preventDefault(); }
if (!releaseScroll) { e.returnValue = false; }
if (e.preventDefault && !releaseScroll) {
e.preventDefault();
}
if (!releaseScroll) {
e.returnValue = false;
}
}
function scrollContent(y, isWheel, isJump)
@ -438,7 +456,9 @@
return;
}
bar.stop(true, true).fadeIn('fast');
if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); }
if (o.railVisible) {
rail.stop(true, true).fadeIn('fast');
}
}
function hideBar()

File diff suppressed because one or more lines are too long