Lets say i have the following code:
function addScrollEvent(scrollElement, direction) {
$(scrollElement).mouseover(function(){
var maxStreckeY = $("#viewport div").height() - $("#viewport").innerHeight();
var currentPos = $("#viewport").scrollTop();
if (direction == "down") {
var restStrecke = maxStreckeY - currentPos;
var timer = restStrecke / maxStreckeY * namespace.config.autoScrollSpeed;
$(element).stop().animate({scrollTop: maxStreckeY}, timer);
}
if (direction == "right") {
var width = $("#viewport div").width();
$(element).stop().animate({scrollLeft: width - $("#viewport").innerWidth()}, namespace.config.autoScrollSpeed);
}
if (direction == "up") {
var timer = currentPos / maxStreckeY * namespace.config.autoScrollSpeed;
$(element).stop().animate({scrollTop: 0}, timer);
}
if (direction == "left") {
$(element).stop().animate({scrollLeft: 0}, namespace.config.autoScrollSpeed);
}
});
$(scrollElement).mouseleave(function(){
$(element).stop();
checkScrollElements();
});
How do i append multiple events to the scrollElement? i would like to do the exact code on tabhold (at the mouseover part) and also on tableave (at the mouseleave part)
I already tried to do something like this :
$(scrollElement).on("mouseover tabhold", function(){
... the function
});
which did not really work since the console gave me the following error :
"on is not a function"
Anybody got a solution for this without copying the same code for another event block? Thanks in advance
live()instead ofon()