Developer forum

Forum » Rapido » Custom timeout on HideMiniCart

Custom timeout on HideMiniCart

Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

Is it possible to set a custom value on this code, without messing around in the master.js file?
Would like to extend this with custom code, and leave the default files untouched.

In the example below I would like to change the timeout from 1s (1000) to 5s (5000).

Cart.prototype.HideMiniCart = function (containerId, triggerId) {
    const self = this;
    let trigger = document.getElementById(triggerId);
    hideTimeOut = setTimeout(function () {
        if (self.showType == "dropdown" && document.getElementById(containerId)) {
            document.getElementById(containerId).style.display = "none";
        } else if (trigger) {
            trigger.checked = false;
        }
        if (trigger) {
            trigger.classList.remove('js-active');
        }
    }, self.showType == "dropdown" ? 1000 : 2000);
}

Replies

 
Konstantin Landyshev
Reply
This post has been marked as an answer

Hi

You can open "BaseWeb\Templates\Designs\Rapido\js\custom.min.js" file and write something like this:
 

document.addEventListener("DOMContentLoaded", function () {

    Cart.HideMiniCart = function (containerId, triggerId) {

        const self = this;

        let trigger = document.getElementById(triggerId);

        hideTimeOut = setTimeout(function () {

            if (self.showType == "dropdown" && document.getElementById(containerId)) {

                document.getElementById(containerId).style.display = "none";

            } else if (trigger) {

                trigger.checked = false;

            }

            if (trigger) {

                trigger.classList.remove('js-active');

            }

        }, self.showType == "dropdown" ? 5000 : 2000);

    }

});

This is working example

Votes for this answer: 1

 

You must be logged in to post in the forum