"on layout load" function issues


(Alex) #1

Hi Hype community!

I’ve run into a problem with one of my websites:

I’m using the following code to allow the scroll function on a mouse to “start” and “continue” the main timeline of my project.

function wheel2(event) { // other browsers
		event.preventDefault();
		if (event.detail < 0 && (hypeDocument.currentTimeInTimelineNamed('Main Timeline') > 2)) {
			hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionReverse);
		} else {
			hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward)		}
	}
	function wheel(event) { // Firefox
		event.preventDefault();
		if (event.wheelDeltaY > 0 && (hypeDocument.currentTimeInTimelineNamed('Main Timeline') > 2)) {
			hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionReverse);
		} else {
			hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward)		}
	}
	window.onmousewheel = document.onmousewheel = wheel;
	window.addEventListener("DOMMouseScroll", wheel2, false);
	document.addEventListener("DOMMouseScroll", wheel2, false);

I’ve set this function to trigger on “on layout load” of certain layouts of certain scenes. The problem is that the function is effecting layouts of scenes in which I haven’t set the function to trigger. This problem only seems to occur on tablet screens and smaller, never on desktop screens.

Is this a common problem when it comes to loading functions on select layouts? has anyone come across this before?
Any help or advice would be great!

Cheers,
Alex


#2

I recommend setting this up to modify a timeline other than ‘Main Timeline’ – Since there are Main Timeline(s) on each scene, any scene will be affected. Use a timeline like ‘scrollTimeline’ or something else.


(Alex) #3

As usual, in retrospect it seems obvious :sunglasses:
Thanks for the help!