loryjs/lory

How to play automatically

Closed this issue · 2 comments

How to play automatically

setTimeout(()=>lory.next(), 1000);

or it you want it to stop automatically calling next during touch interaction or mouseover use something like the following :

stopAutoTimer() {
   clearInterval(this.timeout)
 },

 resetAutoTimer() {
   this.stopAutoTimer()
   this.timeout = setInterval(()=>this.next(), 2000)
 },

subscribeTo('on.lory.touchstart', ()=>this.stopAutoTimer());
subscribeTo('on.lory.touchend',  ()=>this.resetAutoTimer());
subscribeTo('mouseover',  ()=>this.stopAutoTimer());
subscribeTo('mouseout',  ()=>this.resetAutoTimer());
this.resetAutoTimer()

This has been answered, closing it.