embla-carousel-autoplay
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -9,3 +9,3 @@ import { AutoplayOptionsType, OptionsType } from './Options'; | ||
export declare type AutoplayType = CreatePluginType<{ | ||
play: () => void; | ||
play: (jump?: boolean) => void; | ||
stop: () => void; | ||
@@ -12,0 +12,0 @@ reset: () => void; |
import { CreateOptionsType } from 'embla-carousel/components/Options'; | ||
export declare type OptionsType = CreateOptionsType<{ | ||
delay: number; | ||
jump: boolean; | ||
playOnInit: boolean; | ||
@@ -5,0 +6,0 @@ stopOnInteraction: boolean; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
delay: 4000, | ||
jump: false, | ||
playOnInit: true, | ||
@@ -28,2 +29,3 @@ stopOnInteraction: true, | ||
var timer = 0; | ||
var jump = false; | ||
@@ -33,2 +35,3 @@ function init(embla) { | ||
options = optionsHandler.atMedia(self.options); | ||
jump = options.jump; | ||
interaction = options.stopOnInteraction ? destroy : stop; | ||
@@ -63,4 +66,5 @@ var eventStore = carousel.internalEngine().eventStore; | ||
function play() { | ||
function play(jumpOverride) { | ||
stop(); | ||
if (typeof jumpOverride !== 'undefined') jump = jumpOverride; | ||
timer = window.setTimeout(next, options.delay); | ||
@@ -86,5 +90,5 @@ } | ||
if (carousel.canScrollNext()) { | ||
carousel.scrollNext(); | ||
carousel.scrollNext(jump); | ||
} else { | ||
carousel.scrollTo(0); | ||
carousel.scrollTo(0, jump); | ||
} | ||
@@ -91,0 +95,0 @@ |
@@ -7,2 +7,3 @@ import EmblaCarousel from 'embla-carousel'; | ||
delay: 4000, | ||
jump: false, | ||
playOnInit: true, | ||
@@ -22,2 +23,3 @@ stopOnInteraction: true, | ||
var timer = 0; | ||
var jump = false; | ||
@@ -27,2 +29,3 @@ function init(embla) { | ||
options = optionsHandler.atMedia(self.options); | ||
jump = options.jump; | ||
interaction = options.stopOnInteraction ? destroy : stop; | ||
@@ -57,4 +60,5 @@ var eventStore = carousel.internalEngine().eventStore; | ||
function play() { | ||
function play(jumpOverride) { | ||
stop(); | ||
if (typeof jumpOverride !== 'undefined') jump = jumpOverride; | ||
timer = window.setTimeout(next, options.delay); | ||
@@ -80,5 +84,5 @@ } | ||
if (carousel.canScrollNext()) { | ||
carousel.scrollNext(); | ||
carousel.scrollNext(jump); | ||
} else { | ||
carousel.scrollTo(0); | ||
carousel.scrollTo(0, jump); | ||
} | ||
@@ -85,0 +89,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("embla-carousel")):"function"==typeof define&&define.amd?define(["embla-carousel"],e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselAutoplay=e(n.EmblaCarousel)}(this,(function(n){"use strict";function e(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var o=e(n),t={active:!0,breakpoints:{},delay:4e3,playOnInit:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function i(n){var e,a,r,l=o.default.optionsHandler(),s=l.merge(t,i.globalOptions),u=0;function d(){a.off("pointerDown",r),e.stopOnInteraction||a.off("pointerUp",c),f(),u=0}function p(){f(),u=window.setTimeout(m,e.delay)}function f(){u&&window.clearTimeout(u)}function c(){u&&(f(),p())}function m(){var n=a.internalEngine().index;if(e.stopOnLastSnap&&n.get()===n.max)return d();a.canScrollNext()?a.scrollNext():a.scrollTo(0),p()}var y={name:"autoplay",options:l.merge(s,n),init:function(n){a=n,e=l.atMedia(y.options),r=e.stopOnInteraction?d:f;var o=a.internalEngine().eventStore,t=a.rootNode(),i=e.rootNode&&e.rootNode(t)||t;a.on("pointerDown",r),e.stopOnInteraction||a.on("pointerUp",c),e.stopOnMouseEnter&&(o.add(i,"mouseenter",r),e.stopOnInteraction||o.add(i,"mouseleave",c)),o.add(document,"visibilitychange",(function(){if("hidden"===document.visibilityState)return f();c()})),o.add(window,"pagehide",(function(n){n.persisted&&f()})),e.playOnInit&&p()},destroy:d,play:p,stop:f,reset:c};return y}return i.globalOptions=void 0,i})); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("embla-carousel")):"function"==typeof define&&define.amd?define(["embla-carousel"],e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselAutoplay=e(n.EmblaCarousel)}(this,(function(n){"use strict";function e(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var o=e(n),t={active:!0,breakpoints:{},delay:4e3,jump:!1,playOnInit:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function i(n){var e,a,r,l=o.default.optionsHandler(),u=l.merge(t,i.globalOptions),s=0,d=!1;function p(){a.off("pointerDown",r),e.stopOnInteraction||a.off("pointerUp",m),c(),s=0}function f(n){c(),void 0!==n&&(d=n),s=window.setTimeout(y,e.delay)}function c(){s&&window.clearTimeout(s)}function m(){s&&(c(),f())}function y(){var n=a.internalEngine().index;if(e.stopOnLastSnap&&n.get()===n.max)return p();a.canScrollNext()?a.scrollNext(d):a.scrollTo(0,d),f()}var b={name:"autoplay",options:l.merge(u,n),init:function(n){a=n,e=l.atMedia(b.options),d=e.jump,r=e.stopOnInteraction?p:c;var o=a.internalEngine().eventStore,t=a.rootNode(),i=e.rootNode&&e.rootNode(t)||t;a.on("pointerDown",r),e.stopOnInteraction||a.on("pointerUp",m),e.stopOnMouseEnter&&(o.add(i,"mouseenter",r),e.stopOnInteraction||o.add(i,"mouseleave",m)),o.add(document,"visibilitychange",(function(){if("hidden"===document.visibilityState)return c();m()})),o.add(window,"pagehide",(function(n){n.persisted&&c()})),e.playOnInit&&f()},destroy:p,play:f,stop:c,reset:m};return b}return i.globalOptions=void 0,i})); |
{ | ||
"name": "embla-carousel-autoplay", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"author": "David Jerleke", | ||
@@ -60,4 +60,4 @@ "description": "An autoplay plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "7.0.1" | ||
"embla-carousel": "7.0.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27792
218