'touchend' event triggering RightMouseButton?
https://idyllic-raindrop-f32a0c.netlify.app/
I have this weird thing happening when I go to mobile view, click "add to cart" and then hold "+"/"-" button so that it start incrementing number on hold, at the end it triggers RMB window with "inspect" and other options.
Anyone knows the reason?
incrementNumber[i].addEventListener('touchstart', e => {
pressed = true;
scoreIn = Number(ammount[i].innerText);
intervalIn = setTimeout(function(){
intervalIn = setInterval(() => {
scoreIn++;
ammount[i].innerText = scoreIn;
}, 100);
},500)
});
incrementNumber[i].addEventListener('touchend', e => {
clearTimeout(intervalIn);
clearInterval(intervalIn);
if(pressed === true) {
cardName = cardLongName[i];
itemAmmount = scoreIn;
incrementAmmount();
pressed = false;
}
});
incrementNumber[i].addEventListener('touchstart', e => {
pressed = true;
scoreIn = Number(ammount[i].innerText);
intervalIn = setTimeout(function(){
intervalIn = setInterval(() => {
scoreIn++;
ammount[i].innerText = scoreIn;
}, 100);
},500)
});
incrementNumber[i].addEventListener('touchend', e => {
clearTimeout(intervalIn);
clearInterval(intervalIn);
if(pressed === true) {
cardName = cardLongName[i];
itemAmmount = scoreIn;
incrementAmmount();
pressed = false;
}
});
1 Reply
This is the 'touchstart' and 'touchend' function
This is the incrtement inside of touchend event
Don't think they matter, but justso that you have it if needed
function totalPrice() {
const cartTotalItemPrice = document.querySelectorAll(".total-item-price-span")
const cartItemsNumber = document.querySelector(".cart-items-number")
cartItemsNumber.innerText = cartTotalItemPrice.length;
let fullPrcie = 0;
for(let i=0;i<cartTotalItemPrice.length;i++) {
let price = Number(cartTotalItemPrice[i].innerText);
fullPrcie += price;
totalPriceSpan.innerText = fullPrcie.toFixed(2);
}
}
function incrementAmmount() {
const itemCartName = document.querySelectorAll(".item-name");
const itemAmmountSpan = document.querySelectorAll(".item-ammount-span")
const totalItemPrice = document.querySelectorAll(".total-item-price-span")
for(let i=0;i<itemCartName.length;i++) {
if(itemCartName[i].innerText === cardName.innerText) {
itemAmmountSpan[i].innerText = itemAmmount;
totalCartItemPrice = Number(Number(itemAmmount)*Number(itemPrice)).toFixed(2);
totalItemPrice[i].innerText = totalCartItemPrice;
totalPrice();
}
}
}
function totalPrice() {
const cartTotalItemPrice = document.querySelectorAll(".total-item-price-span")
const cartItemsNumber = document.querySelector(".cart-items-number")
cartItemsNumber.innerText = cartTotalItemPrice.length;
let fullPrcie = 0;
for(let i=0;i<cartTotalItemPrice.length;i++) {
let price = Number(cartTotalItemPrice[i].innerText);
fullPrcie += price;
totalPriceSpan.innerText = fullPrcie.toFixed(2);
}
}
function incrementAmmount() {
const itemCartName = document.querySelectorAll(".item-name");
const itemAmmountSpan = document.querySelectorAll(".item-ammount-span")
const totalItemPrice = document.querySelectorAll(".total-item-price-span")
for(let i=0;i<itemCartName.length;i++) {
if(itemCartName[i].innerText === cardName.innerText) {
itemAmmountSpan[i].innerText = itemAmmount;
totalCartItemPrice = Number(Number(itemAmmount)*Number(itemPrice)).toFixed(2);
totalItemPrice[i].innerText = totalCartItemPrice;
totalPrice();
}
}
}