Created
July 15, 2015 20:27
-
-
Save mattrothenberg/090f93f16d49ce4c0389 to your computer and use it in GitHub Desktop.
Ionic Framework - Bidirectional Scroll Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fixScroll(handleName) { | |
$timeout(function(){ | |
var sv = $ionicScrollDelegate.$getByHandle(handleName).getScrollView(); | |
var container = sv.__container; | |
var originaltouchStart = sv.touchStart; | |
var originalmouseDown = sv.mouseDown; | |
var originaltouchMove = sv.touchMove; | |
var originalmouseMove = sv.mouseMove; | |
container.removeEventListener('touchstart', sv.touchStart); | |
container.removeEventListener('mousedown', sv.mouseDown); | |
document.removeEventListener('touchmove', sv.touchMove); | |
document.removeEventListener('mousemove', sv.mousemove); | |
sv.touchStart = function(e) { | |
e.preventDefault = function(){} | |
originaltouchStart.apply(sv, [e]); | |
} | |
sv.touchMove = function(e) { | |
e.preventDefault = function(){} | |
originaltouchMove.apply(sv, [e]); | |
} | |
sv.mouseDown = function(e) { | |
e.preventDefault = function(){} | |
originalmouseDown.apply(sv, [e]); | |
} | |
sv.mouseMove = function(e) { | |
e.preventDefault = function(){} | |
originalmouseMove.apply(sv, [e]); | |
} | |
container.addEventListener("touchstart", sv.touchStart, false); | |
container.addEventListener("mousedown", sv.mouseDown, false); | |
document.addEventListener("touchmove", sv.touchMove, false); | |
document.addEventListener("mousemove", sv.mouseMove, false); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the following
delegate-handle
parameter to your<ion-scroll>
element that is limited to horizontal scrolling only.Then, call the
fixScroll()
function, passing"horizontal"
as the main parameter.