/    Sign up×
Community /Pin to ProfileBookmark

How to combine eventhandlers for mouse and touchscreen (iPad)

Hello everyone.

I’m using a small script to scroll some text. The triggers are in two arrow-images.

The original script uses onMouseOver and onMouseOut. Hence touchscreens ignore these (don’t function right) I added onTouchStart and onTouchEnd, but simply adding these eventhandler won’t do the trick.

I found a clue but I don’t know how to properly integrate it in one piece of proper code.

original:

[CODE] <img src=”../images/btn_arrowup_orange.png” class=”scrollbar-up” id=”arrowup” onmouseover=”scroller.startScroll(0, 5);” onmouseout=”scroller.stopScroll();” />
<img src=”../images/btn_arrowdown_orange.png” class=”scrollbar-down” id=”arrowdown” onmouseover=”scroller.startScroll(0, -5);” onmouseout=”scroller.stopScroll();” />[/CODE]

changed it into:

[CODE] <img src=”../images/btn_arrowup_orange.png” class=”scrollbar-up” id=”arrowup” onTouchStart=”scroller.startScroll(0, 5);” onMouseOver=”scroller.startScroll(0, 5);” onMouseOut=”scroller.stopScroll();” onTouchEnd=”scroller.stopScroll();” />
<img src=”../images/btn_arrowdown_orange.png” class=”scrollbar-down” id=”arrowdown” onTouchStart=”scroller.startScroll(0, -5);” onMouseOver=”scroller.startScroll(0, -5);” onMouseOut=”scroller.stopScroll();” onTouchEnd=”scroller.stopScroll();” />[/CODE]

see link:
[URL=”http://bertienvanmanen.nl/pages/cv.html#”]http://bertienvanmanen.nl/pages/cv.html#[/URL]

and the clue might be:

[CODE] element.onmousedown = function (e) {
document.onmouse = etc.
document.onmouseup = etc.
}

element.ontouchstart = funtion (e) {
element.onmousedown = null;
document.ontouchmove = etc.
document.ontouchend = etc.
}[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Jongen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...