0

I have not much knowlege on JavaScript and only use a little in combination with Tumult Hype. In this case I've got a small script which allows to control the timeline with MouseScroll. Eventually it does not work on mobile device, so I would like to add touchmove (or any better ideas?).

I would be really grateful if anyone could tell me what to add to control the timeline with touch swipe on mobile devices.

Thanks so much Uli

window.timelineNameToControl = 'Main Timeline';
duration = hypeDocument.durationForTimelineNamed(timelineNameToControl);
window.step = duration / 100;

if (window.addEventListener) {
        window.addEventListener("mousewheel", getScrollDir, false);
        //FF
        window.addEventListener("DOMMouseScroll", getScrollDir, false);
    }


    function getScrollDir(e) {

        var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));

        if (delta === -1) {
            newTime = hypeDocument.currentTimeInTimelineNamed(timelineNameToControl) + step;
            hypeDocument.goToTimeInTimelineNamed(newTime, timelineNameToControl);

        } else {
            newTime = hypeDocument.currentTimeInTimelineNamed(timelineNameToControl) - step;
            hypeDocument.goToTimeInTimelineNamed(newTime, timelineNameToControl);
        }


    }


Uli
  • 1

0 Answers0