embla-carousel-autoplay
Advanced tools
Comparing version 7.1.0 to 8.0.0-rc01
@@ -12,2 +12,1 @@ import { CreateOptionsType } from 'embla-carousel/components/Options'; | ||
export declare const defaultOptions: OptionsType; | ||
export type AutoplayOptionsType = Partial<OptionsType>; |
'use strict'; | ||
var EmblaCarousel = require('embla-carousel'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var EmblaCarousel__default = /*#__PURE__*/_interopDefaultLegacy(EmblaCarousel); | ||
var defaultOptions = { | ||
const defaultOptions = { | ||
active: true, | ||
@@ -21,18 +15,24 @@ breakpoints: {}, | ||
function Autoplay(userOptions) { | ||
var optionsHandler = EmblaCarousel__default["default"].optionsHandler(); | ||
var optionsBase = optionsHandler.merge(defaultOptions, Autoplay.globalOptions); | ||
var options; | ||
var carousel; | ||
var interaction; | ||
var timer = 0; | ||
var jump = false; | ||
function init(embla) { | ||
function Autoplay(userOptions = {}) { | ||
let options; | ||
let carousel; | ||
let interaction; | ||
let timer = 0; | ||
let jump = false; | ||
function init(embla, optionsHandler) { | ||
carousel = embla; | ||
options = optionsHandler.atMedia(self.options); | ||
const { | ||
mergeOptions, | ||
optionsAtMedia | ||
} = optionsHandler; | ||
const optionsBase = mergeOptions(defaultOptions, Autoplay.globalOptions); | ||
const allOptions = mergeOptions(optionsBase, userOptions); | ||
options = optionsAtMedia(allOptions); | ||
jump = options.jump; | ||
interaction = options.stopOnInteraction ? destroy : stop; | ||
var eventStore = carousel.internalEngine().eventStore; | ||
var emblaRoot = carousel.rootNode(); | ||
var root = options.rootNode && options.rootNode(emblaRoot) || emblaRoot; | ||
const { | ||
eventStore | ||
} = carousel.internalEngine(); | ||
const emblaRoot = carousel.rootNode(); | ||
const root = options.rootNode && options.rootNode(emblaRoot) || emblaRoot; | ||
carousel.on('pointerDown', interaction); | ||
@@ -44,7 +44,7 @@ if (!options.stopOnInteraction) carousel.on('pointerUp', reset); | ||
} | ||
eventStore.add(document, 'visibilitychange', function () { | ||
eventStore.add(document, 'visibilitychange', () => { | ||
if (document.visibilityState === 'hidden') return stop(); | ||
reset(); | ||
}); | ||
eventStore.add(window, 'pagehide', function (event) { | ||
eventStore.add(window, 'pagehide', event => { | ||
if (event.persisted) stop(); | ||
@@ -75,4 +75,6 @@ }); | ||
function next() { | ||
var index = carousel.internalEngine().index; | ||
var kill = options.stopOnLastSnap && index.get() === index.max; | ||
const { | ||
index | ||
} = carousel.internalEngine(); | ||
const kill = options.stopOnLastSnap && index.get() === index.max; | ||
if (kill) return destroy(); | ||
@@ -86,10 +88,10 @@ if (carousel.canScrollNext()) { | ||
} | ||
var self = { | ||
const self = { | ||
name: 'autoplay', | ||
options: optionsHandler.merge(optionsBase, userOptions), | ||
init: init, | ||
destroy: destroy, | ||
play: play, | ||
stop: stop, | ||
reset: reset | ||
options: userOptions, | ||
init, | ||
destroy, | ||
play, | ||
stop, | ||
reset | ||
}; | ||
@@ -96,0 +98,0 @@ return self; |
@@ -1,4 +0,2 @@ | ||
import EmblaCarousel from 'embla-carousel'; | ||
var defaultOptions = { | ||
const defaultOptions = { | ||
active: true, | ||
@@ -15,18 +13,24 @@ breakpoints: {}, | ||
function Autoplay(userOptions) { | ||
var optionsHandler = EmblaCarousel.optionsHandler(); | ||
var optionsBase = optionsHandler.merge(defaultOptions, Autoplay.globalOptions); | ||
var options; | ||
var carousel; | ||
var interaction; | ||
var timer = 0; | ||
var jump = false; | ||
function init(embla) { | ||
function Autoplay(userOptions = {}) { | ||
let options; | ||
let carousel; | ||
let interaction; | ||
let timer = 0; | ||
let jump = false; | ||
function init(embla, optionsHandler) { | ||
carousel = embla; | ||
options = optionsHandler.atMedia(self.options); | ||
const { | ||
mergeOptions, | ||
optionsAtMedia | ||
} = optionsHandler; | ||
const optionsBase = mergeOptions(defaultOptions, Autoplay.globalOptions); | ||
const allOptions = mergeOptions(optionsBase, userOptions); | ||
options = optionsAtMedia(allOptions); | ||
jump = options.jump; | ||
interaction = options.stopOnInteraction ? destroy : stop; | ||
var eventStore = carousel.internalEngine().eventStore; | ||
var emblaRoot = carousel.rootNode(); | ||
var root = options.rootNode && options.rootNode(emblaRoot) || emblaRoot; | ||
const { | ||
eventStore | ||
} = carousel.internalEngine(); | ||
const emblaRoot = carousel.rootNode(); | ||
const root = options.rootNode && options.rootNode(emblaRoot) || emblaRoot; | ||
carousel.on('pointerDown', interaction); | ||
@@ -38,7 +42,7 @@ if (!options.stopOnInteraction) carousel.on('pointerUp', reset); | ||
} | ||
eventStore.add(document, 'visibilitychange', function () { | ||
eventStore.add(document, 'visibilitychange', () => { | ||
if (document.visibilityState === 'hidden') return stop(); | ||
reset(); | ||
}); | ||
eventStore.add(window, 'pagehide', function (event) { | ||
eventStore.add(window, 'pagehide', event => { | ||
if (event.persisted) stop(); | ||
@@ -69,4 +73,6 @@ }); | ||
function next() { | ||
var index = carousel.internalEngine().index; | ||
var kill = options.stopOnLastSnap && index.get() === index.max; | ||
const { | ||
index | ||
} = carousel.internalEngine(); | ||
const kill = options.stopOnLastSnap && index.get() === index.max; | ||
if (kill) return destroy(); | ||
@@ -80,10 +86,10 @@ if (carousel.canScrollNext()) { | ||
} | ||
var self = { | ||
const self = { | ||
name: 'autoplay', | ||
options: optionsHandler.merge(optionsBase, userOptions), | ||
init: init, | ||
destroy: destroy, | ||
play: play, | ||
stop: stop, | ||
reset: reset | ||
options: userOptions, | ||
init, | ||
destroy, | ||
play, | ||
stop, | ||
reset | ||
}; | ||
@@ -90,0 +96,0 @@ return self; |
@@ -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,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})); | ||
!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselAutoplay=o()}(this,(function(){"use strict";const n={active:!0,breakpoints:{},delay:4e3,jump:!1,playOnInit:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function o(t={}){let e,i,s,a=0,r=!1;function p(){i.off("pointerDown",s),e.stopOnInteraction||i.off("pointerUp",u),l(),a=0}function d(n){l(),void 0!==n&&(r=n),a=window.setTimeout(c,e.delay)}function l(){a&&window.clearTimeout(a)}function u(){a&&(l(),d())}function c(){const{index:n}=i.internalEngine();if(e.stopOnLastSnap&&n.get()===n.max)return p();i.canScrollNext()?i.scrollNext(r):i.scrollTo(0,r),d()}return{name:"autoplay",options:t,init:function(a,c){i=a;const{mergeOptions:f,optionsAtMedia:m}=c,y=f(n,o.globalOptions),O=f(y,t);e=m(O),r=e.jump,s=e.stopOnInteraction?p:l;const{eventStore:g}=i.internalEngine(),b=i.rootNode(),w=e.rootNode&&e.rootNode(b)||b;i.on("pointerDown",s),e.stopOnInteraction||i.on("pointerUp",u),e.stopOnMouseEnter&&(g.add(w,"mouseenter",s),e.stopOnInteraction||g.add(w,"mouseleave",u)),g.add(document,"visibilitychange",(()=>{if("hidden"===document.visibilityState)return l();u()})),g.add(window,"pagehide",(n=>{n.persisted&&l()})),e.playOnInit&&d()},destroy:p,play:d,stop:l,reset:u}}return o.globalOptions=void 0,o})); |
@@ -1,3 +0,2 @@ | ||
export { AutoplayType } from './components'; | ||
export { AutoplayOptionsType } from './components/Options'; | ||
export { default } from './components'; | ||
export { AutoplayType, AutoplayOptionsType } from './components/Autoplay'; | ||
export { default } from './components/Autoplay'; |
{ | ||
"name": "embla-carousel-autoplay", | ||
"version": "7.1.0", | ||
"version": "8.0.0-rc01", | ||
"author": "David Jerleke", | ||
@@ -58,4 +58,4 @@ "description": "An autoplay plugin for Embla Carousel", | ||
"peerDependencies": { | ||
"embla-carousel": "7.1.0" | ||
"embla-carousel": "8.0.0-rc01" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
228
12146