-1

I have this config on my page:

<script>
    var elem = document.getElementById('mySwipe');
    window.mySwipe = Swipe(elem, {
        continuous: false,
        disableTouch: false,
    });
</script>

I was wondering is it possible to make it so 10 seconds after the page has finished loading to change the value of disableTouch to true?

Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50

2 Answers2

1

It's a slow day. I'll help :)

var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
  continuous: false,
  disableTouch: false,
});

function setDisableTouchToTrue(){
  window.mySwipe = Swipe(elem, {
    continuous: false,
    disableTouch: true,
  });
}

window.onload = setTimeout(setDisableTouchToTrue, 10000);

Maybe you can even do:

function setDisableTouchToTrue(){
  window.mySwipe.disableTouch = true;
}

Not sure.

James Hibbard
  • 16,490
  • 14
  • 62
  • 74
1

Altho it's a possible duplicate, i will suggest this since you'r new. Use setTimeout() on document ready() as follows:

jQuery(document).ready(function() { setTimeout(function() {
        var elem = document.getElementById('mySwipe');
        window.mySwipe = Swipe(elem, {
            continuous: false,
            disableTouch: true,
        });
    }, 10 * 1000);
});
Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50