Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

embla-carousel-autoplay

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel-autoplay - npm Package Compare versions

Comparing version 6.2.0 to 7.0.0-rc01

embla-carousel-autoplay.cjs.js

8

components/index.d.ts
import { AutoplayOptionsType, OptionsType } from './Options';
import { EmblaPluginType } from 'embla-carousel';
export declare type AutoplayType = EmblaPluginType<OptionsType> & {
import { CreatePluginType } from 'embla-carousel/components/Plugins';
export declare type AutoplayType = CreatePluginType<{
play: () => void;
stop: () => void;
reset: () => void;
};
declare function Autoplay(userOptions?: AutoplayOptionsType, userNode?: (emblaRoot: HTMLElement) => HTMLElement | null): AutoplayType;
}, OptionsType>;
declare function Autoplay(userOptions?: AutoplayOptionsType): AutoplayType;
declare namespace Autoplay {

@@ -10,0 +10,0 @@ var globalOptions: Partial<OptionsType> | undefined;

@@ -1,2 +0,3 @@

export declare type OptionsType = {
import { CreateOptionsType } from 'embla-carousel/components/Options';
export declare type OptionsType = CreateOptionsType<{
delay: number;

@@ -7,4 +8,5 @@ playOnInit: boolean;

stopOnLastSnap: boolean;
};
rootNode: ((emblaRoot: HTMLElement) => HTMLElement | null) | null;
}>;
export declare const defaultOptions: OptionsType;
export declare type AutoplayOptionsType = Partial<OptionsType>;

@@ -0,2 +1,6 @@

import EmblaCarousel from 'embla-carousel';
var defaultOptions = {
active: true,
breakpoints: {},
delay: 4000,

@@ -6,14 +10,12 @@ playOnInit: true,

stopOnMouseEnter: false,
stopOnLastSnap: false
stopOnLastSnap: false,
rootNode: null
};
function Autoplay(userOptions, userNode) {
var options = Object.assign({}, defaultOptions, Autoplay.globalOptions, userOptions);
var playOnInit = options.playOnInit,
stopOnInteraction = options.stopOnInteraction,
stopOnMouseEnter = options.stopOnMouseEnter,
stopOnLastSnap = options.stopOnLastSnap,
delay = options.delay;
var interaction = stopOnInteraction ? destroy : stop;
function Autoplay(userOptions) {
var optionsHandler = EmblaCarousel.optionsHandler();
var optionsBase = optionsHandler.merge(defaultOptions, Autoplay.globalOptions);
var options;
var carousel;
var interaction;
var timer = 0;

@@ -23,11 +25,13 @@

carousel = embla;
options = optionsHandler.atMedia(self.options);
interaction = options.stopOnInteraction ? destroy : stop;
var eventStore = carousel.internalEngine().eventStore;
var emblaRoot = carousel.rootNode();
var root = userNode && userNode(emblaRoot) || emblaRoot;
var root = options.rootNode && options.rootNode(emblaRoot) || emblaRoot;
carousel.on('pointerDown', interaction);
if (!stopOnInteraction) carousel.on('pointerUp', reset);
if (!options.stopOnInteraction) carousel.on('pointerUp', reset);
if (stopOnMouseEnter) {
if (options.stopOnMouseEnter) {
eventStore.add(root, 'mouseenter', interaction);
if (!stopOnInteraction) eventStore.add(root, 'mouseleave', reset);
if (!options.stopOnInteraction) eventStore.add(root, 'mouseleave', reset);
}

@@ -42,3 +46,3 @@

});
if (playOnInit) play();
if (options.playOnInit) play();
}

@@ -48,3 +52,3 @@

carousel.off('pointerDown', interaction);
if (!stopOnInteraction) carousel.off('pointerUp', reset);
if (!options.stopOnInteraction) carousel.off('pointerUp', reset);
stop();

@@ -56,3 +60,3 @@ timer = 0;

stop();
timer = window.setTimeout(next, delay);
timer = window.setTimeout(next, options.delay);
}

@@ -73,3 +77,3 @@

var index = carousel.internalEngine().index;
var kill = stopOnLastSnap && index.get() === index.max;
var kill = options.stopOnLastSnap && index.get() === index.max;
if (kill) return destroy();

@@ -87,4 +91,4 @@

var self = {
name: 'Autoplay',
options: options,
name: 'autoplay',
options: optionsHandler.merge(optionsBase, userOptions),
init: init,

@@ -101,3 +105,3 @@ destroy: destroy,

export default Autoplay;
export { Autoplay as default };
//# sourceMappingURL=embla-carousel-autoplay.esm.js.map

@@ -1,1 +0,1 @@

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselAutoplay=e()}(this,(function(){"use strict";var n={delay:4e3,playOnInit:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1};function e(t,o){var i,a=Object.assign({},n,e.globalOptions,t),r=a.playOnInit,s=a.stopOnInteraction,d=a.stopOnMouseEnter,l=a.stopOnLastSnap,u=a.delay,p=s?c:m,f=0;function c(){i.off("pointerDown",p),s||i.off("pointerUp",O),m(),f=0}function y(){m(),f=window.setTimeout(g,u)}function m(){f&&window.clearTimeout(f)}function O(){f&&(m(),y())}function g(){var n=i.internalEngine().index;if(l&&n.get()===n.max)return c();i.canScrollNext()?i.scrollNext():i.scrollTo(0),y()}return{name:"Autoplay",options:a,init:function(n){var e=(i=n).internalEngine().eventStore,t=i.rootNode(),a=o&&o(t)||t;i.on("pointerDown",p),s||i.on("pointerUp",O),d&&(e.add(a,"mouseenter",p),s||e.add(a,"mouseleave",O)),e.add(document,"visibilitychange",(function(){if("hidden"===document.visibilityState)return m();O()})),e.add(window,"pagehide",(function(n){n.persisted&&m()})),r&&y()},destroy:c,play:y,stop:m,reset:O}}return e.globalOptions=void 0,e}));
!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}));
{
"name": "embla-carousel-autoplay",
"version": "6.2.0",
"author": "David Cetinkaya",
"version": "7.0.0-rc01",
"author": "David Jerleke",
"description": "An autoplay plugin for Embla Carousel",
"repository": {
"type": "git",
"url": "git+https://github.com/davidcetinkaya/embla-carousel"
"url": "git+https://github.com/davidjerleke/embla-carousel"
},
"bugs": {
"url": "https://github.com/davidcetinkaya/embla-carousel/issues"
"url": "https://github.com/davidjerleke/embla-carousel/issues"
},

@@ -26,5 +26,6 @@ "homepage": "https://www.embla-carousel.com",

],
"main": "embla-carousel-autoplay.umd.js",
"unpkg": "embla-carousel-autoplay.umd.js",
"main": "embla-carousel-autoplay.cjs.js",
"module": "embla-carousel-autoplay.esm.js",
"browser": "embla-carousel-autoplay.umd.js",
"types": "index.d.ts",

@@ -45,17 +46,17 @@ "sideEffects": false,

"devDependencies": {
"@types/jest": "^26.0.22",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rollup": "^2.45.2",
"ts-jest": "^26.5.5",
"typescript": "^4.2.4"
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.0",
"prettier": "2.5.1",
"rollup": "^2.68.0",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
},
"peerDependencies": {
"embla-carousel": "6.2.0"
"embla-carousel": "7.0.0-rc01"
}
}
}

@@ -11,3 +11,3 @@ <br />

<a href="https://www.npmjs.com/package/embla-carousel-autoplay"><img src="https://img.shields.io/npm/v/embla-carousel-autoplay.svg?color=%23c1a8e2"></a>
<a href="https://github.com/davidcetinkaya/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/workflow/status/davidcetinkaya/embla-carousel/Continuous%20Integration?color=%238ab4f8"></a>
<a href="https://github.com/davidjerleke/embla-carousel/actions?query=workflow%3A%22Continuous+Integration%22"><img src="https://img.shields.io/github/workflow/status/davidjerleke/embla-carousel/Continuous%20Integration?color=%238ab4f8"></a>
<a href="https://prettier.io"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat&color=%23c1a8e2"></a>

@@ -52,4 +52,4 @@ <a href="https://bundlephobia.com/result?p=embla-carousel-autoplay@latest"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel-autoplay?color=%238ab4f8&label=gzip%20size">

<p align="center">
<sup>Copyright © 2019-present, David Cetinkaya.</sup><br>
Embla is <a href="https://github.com/davidcetinkaya/embla-carousel/blob/master/LICENSE">MIT licensed</a> 💖.
<sup>Copyright © 2019-present, David Jerleke.</sup><br>
Embla is <a href="https://github.com/davidjerleke/embla-carousel/blob/master/LICENSE">MIT licensed</a> 💖.
</p>

@@ -56,0 +56,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc