title: sweetalert2 cancel timer/timeout
body: <p>I wanted to make a cancelable self-closing modal after 5 seconds with SweetAlert2 but I could't find a way to stop the timer, please help! Here's the js code:</p>
  
  <pre><code>$(document).on('click', '#view_more_trigger', function(e) { 
      e.preventDefault();
      var div = document.getElementById('view_more');
      div.style.display = div.style.display == 'none' ? 'block' : 'none';
      $(this).html( div.style.display == 'none' ? "View Moar" : "View Less");
  });
  
  var closeInSeconds=10,
      timerInterval;
  
  var my_swal = swal({
      type:   'success',
      html:   '&lt;div id="view_more" style="display: none;"&gt;'+
                  $('#details').html() +
              '&lt;/div&gt;'+
              '&lt;a href="javascript:;" id="view_more_trigger" &gt;View more&lt;/a&gt;'+
              '&lt;p id="show_timeout" style="display: none;"&gt;&lt;/p&gt;',
      timer: closeInSeconds * 1000,
  
      onOpen: () =&gt; {
  
          $('#show_timeout').show();
          timerInterval = setInterval(function() {
  
              $(document).on('click', '#view_more_trigger', function(e) { 
                  e.preventDefault();
  
                  console.log('trying desperately to cancel the damn timer!');
                  //swal.stop();                //  error, function !exists
                  //my_swal.timeout.stop();     //  Cannot read property 'stop' of undefined
                  //my_swal.timer.stop();       //  Cannot read property 'stop' of undefined
  
  
                  // ..or to increase it
                  if(closeInSeconds&lt;1000) {
                      console.log('incrementing closeInSeconds by 1000');
                      closeInSeconds +=1000;
                  }
                  //swal.timer = closeInSeconds * 1000;
  
                  swal.timer = closeInSeconds * 1000;
                  my_swal.timer = closeInSeconds * 1000;
  
                  clearInterval(timerInterval);
              });
  
              closeInSeconds--;
              if (closeInSeconds &lt; 0) {
                  clearInterval(timerInterval);
              }
  
              swal.getContent().querySelector('#show_timeout').textContent = (Math.round(swal.getTimerLeft()/1000)*1000)/1000 + 's';
  
          }, 1000);
      },
      onClose: () =&gt; {
          clearInterval(timerInterval)
      },
  
      showConfirmButton: false,
  });
  </code></pre>
  
  <p>The only function to work with timer I found is Swal.getTimerLeft().</p>
  
  <p>I created a pen in <a href="https://codepen.io/teoui/pen/MzdzWy" rel="nofollow noreferrer">https://codepen.io/teoui/pen/MzdzWy</a> to play with</p>
  
  <p>Thanks!</p>