-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Hello,
I needed some mobile scrolling and made the following code.
Functions to add:
onTouchStart : function(e){
this.touch = {
start : {
y : e.touches[0].pageY
}
};
},
onTouchMove: function(e){
// calculate new handle position
this.handle.top += (e.touches[0].pageY - this.touch.start.y) * 0.01;
this.setHandlePosition();
this.setContentPosition();
// prevent default scrolling of the entire document if handle is within [min, max]-range
if(this.handle.top > this.props.handlePosition.min && this.handle.top < this.props.handlePosition.max){
e.preventDefault();
}
},
Add the following code to the function appendEvents:
// Touch events
var _this = this;
this.container[0].addEventListener("touchstart", function(e){
_this.onTouchStart(e);
}, false);
this.container[0].addEventListener("touchmove", function(e){
e.preventDefault();
_this.onTouchMove(e);
}, false);
Good luck!
Tsukasa
Metadata
Metadata
Assignees
Labels
No labels