Skip to content

Commit

Permalink
The product update delay vary depending on what has been modified, bl…
Browse files Browse the repository at this point in the history
…ock url update on homepage by checking the presence of quickview modal
  • Loading branch information
jolelievre committed Feb 6, 2019
1 parent d824fee commit 4234261
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions themes/_core/js/product.js
Expand Up @@ -123,6 +123,13 @@ function updateProduct(event, eventType, updateUrl) {
clearTimeout(currentRequestDelayedId);
}

// Most update need to occur (almost) instantly, but in some cases (like keyboard actions)
// we need to delay the update a bit more
let updateDelay = 30;
if ('updatedProductQuantity' === eventType) {
updateDelay = 750;
}

currentRequestDelayedId = setTimeout(function updateProductRequest() {

if (formSerialized === '') {
Expand Down Expand Up @@ -182,7 +189,7 @@ function updateProduct(event, eventType, updateUrl) {
currentRequestDelayedId = null;
}
});
}.bind(currentRequest, currentRequestDelayedId), 1500);
}.bind(currentRequest, currentRequestDelayedId), updateDelay);
}

/**
Expand Down Expand Up @@ -321,7 +328,10 @@ $(document).ready(() => {
return;
}

// If quickview modal is present we are not on product page, so we don't change the url nor title
/*
* If quickview modal is present we are not on product page, so
* we don't change the url nor title
*/
const quickView = $('.modal.quickview');
if (quickView.length) {
return;
Expand Down

0 comments on commit 4234261

Please sign in to comment.