embla-carousel-class-names
Advanced tools
Comparing version
import { ClassNamesOptionsType, OptionsType } from './Options'; | ||
import { EmblaPluginType } from 'embla-carousel'; | ||
export declare type ClassNamesType = EmblaPluginType<OptionsType>; | ||
import { CreatePluginType } from 'embla-carousel/components/Plugins'; | ||
export declare type ClassNamesType = CreatePluginType<{}, OptionsType>; | ||
declare function ClassNames(userOptions?: ClassNamesOptionsType): ClassNamesType; | ||
@@ -5,0 +5,0 @@ declare namespace ClassNames { |
@@ -1,7 +0,8 @@ | ||
export declare type OptionsType = { | ||
import { CreateOptionsType } from 'embla-carousel/components/Options'; | ||
export declare type OptionsType = CreateOptionsType<{ | ||
selected: string; | ||
draggable: string; | ||
dragging: string; | ||
}; | ||
}>; | ||
export declare const defaultOptions: OptionsType; | ||
export declare type ClassNamesOptionsType = Partial<OptionsType>; |
@@ -0,2 +1,6 @@ | ||
import EmblaCarousel from 'embla-carousel'; | ||
var defaultOptions = { | ||
active: true, | ||
breakpoints: {}, | ||
selected: 'is-selected', | ||
@@ -17,14 +21,14 @@ draggable: 'is-draggable', | ||
function ClassNames(userOptions) { | ||
var options = Object.assign({}, defaultOptions, ClassNames.globalOptions, userOptions); | ||
var selected = options.selected, | ||
draggable = options.draggable, | ||
dragging = options.dragging; | ||
var selectedEvents = ['select', 'pointerUp']; | ||
var draggingEvents = ['pointerDown', 'pointerUp']; | ||
var optionsHandler = EmblaCarousel.optionsHandler(); | ||
var optionsBase = optionsHandler.merge(defaultOptions, ClassNames.globalOptions); | ||
var options; | ||
var carousel; | ||
var root; | ||
var slides; | ||
var selectedEvents = ['select', 'pointerUp']; | ||
var draggingEvents = ['pointerDown', 'pointerUp']; | ||
function init(embla) { | ||
carousel = embla; | ||
options = optionsHandler.atMedia(self.options); | ||
root = carousel.rootNode(); | ||
@@ -35,6 +39,6 @@ slides = carousel.slideNodes(); | ||
if (isDraggable) { | ||
addClass(root, draggable); | ||
addClass(root, options.draggable); | ||
} | ||
if (dragging) { | ||
if (options.dragging) { | ||
draggingEvents.forEach(function (evt) { | ||
@@ -45,3 +49,3 @@ return carousel.on(evt, toggleDraggingClass); | ||
if (selected) { | ||
if (options.selected) { | ||
selectedEvents.forEach(function (evt) { | ||
@@ -55,3 +59,3 @@ return carousel.on(evt, toggleSelectedClass); | ||
function destroy() { | ||
removeClass(root, draggable); | ||
removeClass(root, options.draggable); | ||
draggingEvents.forEach(function (evt) { | ||
@@ -64,3 +68,3 @@ return carousel.off(evt, toggleDraggingClass); | ||
slides.forEach(function (slide) { | ||
return removeClass(slide, selected); | ||
return removeClass(slide, options.selected); | ||
}); | ||
@@ -70,3 +74,3 @@ } | ||
function toggleDraggingClass(evt) { | ||
if (evt === 'pointerDown') addClass(root, dragging);else removeClass(root, dragging); | ||
if (evt === 'pointerDown') addClass(root, options.dragging);else removeClass(root, options.dragging); | ||
} | ||
@@ -78,6 +82,6 @@ | ||
notInView.forEach(function (index) { | ||
return removeClass(slides[index], selected); | ||
return removeClass(slides[index], options.selected); | ||
}); | ||
inView.forEach(function (index) { | ||
return addClass(slides[index], selected); | ||
return addClass(slides[index], options.selected); | ||
}); | ||
@@ -87,4 +91,4 @@ } | ||
var self = { | ||
name: 'ClassNames', | ||
options: options, | ||
name: 'classNames', | ||
options: optionsHandler.merge(optionsBase, userOptions), | ||
init: init, | ||
@@ -98,3 +102,3 @@ destroy: destroy | ||
export default ClassNames; | ||
export { ClassNames as default }; | ||
//# sourceMappingURL=embla-carousel-class-names.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).EmblaCarouselClassNames=e()}(this,(function(){"use strict";var n={selected:"is-selected",draggable:"is-draggable",dragging:"is-dragging"};function e(n,e){var o=n.classList;e&&o.contains(e)&&o.remove(e)}function o(n,e){var o=n.classList;e&&!o.contains(e)&&o.add(e)}function t(i){var r,s,a,f=Object.assign({},n,t.globalOptions,i),c=f.selected,u=f.draggable,d=f.dragging,l=["select","pointerUp"],g=["pointerDown","pointerUp"];function p(n){"pointerDown"===n?o(s,d):e(s,d)}function b(){var n=r.slidesInView(!0);r.slidesNotInView(!0).forEach((function(n){return e(a[n],c)})),n.forEach((function(n){return o(a[n],c)}))}return{name:"ClassNames",options:f,init:function(n){s=(r=n).rootNode(),a=r.slideNodes(),r.internalEngine().options.draggable&&o(s,u),d&&g.forEach((function(n){return r.on(n,p)})),c&&(l.forEach((function(n){return r.on(n,b)})),b())},destroy:function(){e(s,u),g.forEach((function(n){return r.off(n,p)})),l.forEach((function(n){return r.off(n,b)})),a.forEach((function(n){return e(n,c)}))}}}return t.globalOptions=void 0,t})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("embla-carousel")):"function"==typeof define&&define.amd?define(["embla-carousel"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).EmblaCarouselClassNames=n(e.EmblaCarousel)}(this,(function(e){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),t={active:!0,breakpoints:{},selected:"is-selected",draggable:"is-draggable",dragging:"is-dragging"};function i(e,n){var o=e.classList;n&&o.contains(n)&&o.remove(n)}function r(e,n){var o=e.classList;n&&!o.contains(n)&&o.add(n)}function a(e){var n,s,c,f,l=o.default.optionsHandler(),u=l.merge(t,a.globalOptions),d=["select","pointerUp"],g=["pointerDown","pointerUp"];function p(e){"pointerDown"===e?r(c,n.dragging):i(c,n.dragging)}function b(){var e=s.slidesInView(!0);s.slidesNotInView(!0).forEach((function(e){return i(f[e],n.selected)})),e.forEach((function(e){return r(f[e],n.selected)}))}var m={name:"classNames",options:l.merge(u,e),init:function(e){s=e,n=l.atMedia(m.options),c=s.rootNode(),f=s.slideNodes(),s.internalEngine().options.draggable&&r(c,n.draggable),n.dragging&&g.forEach((function(e){return s.on(e,p)})),n.selected&&(d.forEach((function(e){return s.on(e,b)})),b())},destroy:function(){i(c,n.draggable),g.forEach((function(e){return s.off(e,p)})),d.forEach((function(e){return s.off(e,b)})),f.forEach((function(e){return i(e,n.selected)}))}};return m}return a.globalOptions=void 0,a})); |
{ | ||
"name": "embla-carousel-class-names", | ||
"version": "6.2.0", | ||
"author": "David Cetinkaya", | ||
"version": "7.0.0-rc01", | ||
"author": "David Jerleke", | ||
"description": "A class name toggle 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-class-names.umd.js", | ||
"unpkg": "embla-carousel-class-names.umd.js", | ||
"main": "embla-carousel-class-names.cjs.js", | ||
"module": "embla-carousel-class-names.esm.js", | ||
"browser": "embla-carousel-class-names.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-class-names"><img src="https://img.shields.io/npm/v/embla-carousel-class-names.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-class-names@latest"><img src="https://img.shields.io/bundlephobia/minzip/embla-carousel-class-names?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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
26616
14.91%194
5.43%3
200%2
Infinity%