Could anyone tell me why this function won't execute in Firefox. The rest of the Javascript functions throughout the file work successfully except for this one (it flat out won't execute, no errors in the console). I suspected it was the pageX
property, however that doesn't seem to be the case.
var prevX = 0;
var i = 0;
var drgleft = 0;
var drgright = 0;
function sequence_1(event){
if(prevX == 0){
prevX = event.pageX;
return false;
}
//drag left
if(prevX > event.pageX){
console.log('dragged left');
drgleft++;
if(drgleft == 2){
drgleft = 0;
i--;
if(i < 0){
i = 30; //for optimization reasons, input the cache.length value manually (this avoids unnecessary errors in the console and laggy framerate as a result).
}
document.getElementById("TheBigOne").src = cache[i].src; //use console.log(i); as a method of verifying that the code is executing correctly
}
}
else if(prevX < event.pageX){
console.log('dragged right');
drgright++;
if(drgright == 2){
drgright = 0;
i++;
if(i > 30){ //for optimization reasons, input the cache.length value manually (this avoids unnecessary errors in the console and laggy framerate as a result).
i=0;
}
document.getElementById("TheBigOne").src = cache[i].src;
}
}
else{
}
prevX = event.pageX
}
EDIT:
In my first post I didn't include the relevent HTML code that calls the function, for that I apologise and will implement it below.
<!DOCTYPE html>
<html>
<body>
<div class="The_main_event" draggable = "true" ondrag="sequence_1(event)" id = "GD">
<img src="file:///C:/Users/Harry/Desktop/Website/Web_aeroplane/Web%20Test.0031.png" id="TheBigOne">
</div>
</body>
</html>