From 77ecf3bc540d5530f7549064529e7f4ccd0acb31 Mon Sep 17 00:00:00 2001 From: Morven Lewis-Everley Date: Thu, 16 Jan 2020 17:53:18 +0000 Subject: [PATCH] Ensure timer for delay starts on intial load (not after interaction) --- client/dist/js/SMModal.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/dist/js/SMModal.js b/client/dist/js/SMModal.js index d565526..e71c39b 100644 --- a/client/dist/js/SMModal.js +++ b/client/dist/js/SMModal.js @@ -21,8 +21,11 @@ DelayTime = $(this).attr('data-delay'); $object = $(this); if (DelayTime > 0) { - var idleTimer = null; - $('*').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () { + var idleTimer = setTimeout(function () { + SMModal($object); + }, DelayTime * 1000); + + $('*').bind('click mouseup mousedown keydown keypress keyup submit change scroll resize dblclick', function () { clearTimeout(idleTimer); idleTimer = setTimeout(function () { SMModal($object);