Unload JavaScript


(Janis) #1

Hi guys, please im using HypePro, and a try to make “Contact” with scroll. Im using this script:

	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);
}

Sometimes i need it but sometimes i need just scroll down without this. How can i unload this script?

Thank you! SRY for bad EN.


(Andrew) #2

You can remove a listener like this:

window. removeEventListener("DOMMouseScroll", wheel2, false);

document.onmousewheel = function(){ stopWheel(); }