Closed SoyDiego closed 4 years ago
Hi,
Auto-play stopping once the carousel has been interacted with is the default behaviour for Flickity. There currently isn't an option to change this, but it can be done with code...
Option one detects when the mouse cursor leaves the carousel and then re-starts auto-play:
$(".main-carousel").on("mouseleave", function() { $(this).flickity("playPlayer"); });
Option two overwrites the default behaviour and in my opinion the better one of the two as unlike above, it also works well with touchscreen devices:
['play', 'stop', 'pause', 'unpause'].forEach(function(action) { var methodName = action + 'Player'; Flickity.prototype[methodName] = function() { this.player[action](); this.dispatchEvent(methodName); }; });
// Overwrite 'stopPlayer' Method
Flickity.prototype.stopPlayer = function() { this.player.stop(); // Always Resume Play After 3 Seconds setTimeout(() => { this.player.play(); }, 3000) };
Hope this helps,
Mike
Hi,
Auto-play stopping once the carousel has been interacted with is the default behaviour for Flickity. There currently isn't an option to change this, but it can be done with code...
Option one detects when the mouse cursor leaves the carousel and then re-starts auto-play:
$(".main-carousel").on("mouseleave", function() { $(this).flickity("playPlayer"); });
Option two overwrites the default behaviour and in my opinion the better one of the two as unlike above, it also works well with touchscreen devices:
['play', 'stop', 'pause', 'unpause'].forEach(function(action) { var methodName = action + 'Player'; Flickity.prototype[methodName] = function() { this.playeraction; this.dispatchEvent(methodName); }; });
// Overwrite 'stopPlayer' Method
Flickity.prototype.stopPlayer = function() { this.player.stop(); // Always Resume Play After 3 Seconds setTimeout(() => { this.player.play(); }, 3000) };
Hope this helps,
Mike
Great!! MikeyJN works perfectly the second option!! :) Thanks for your time :+1:
Hi, i like flickity but i don't know how can i do to continue playing after you touch it. On hover is perfect, stopped and then when you remove hover start playing again, but when you move or touch, stopped but then never start playing again.
Someone can help me? Thanks and sorry for my english