embla-carousel-class-names
Advanced tools
Comparing version 7.1.0 to 8.0.0-rc01
@@ -8,2 +8,1 @@ import { CreateOptionsType } from 'embla-carousel/components/Options'; | ||
export declare const defaultOptions: OptionsType; | ||
export type ClassNamesOptionsType = 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, | ||
@@ -18,25 +12,29 @@ breakpoints: {}, | ||
function removeClass(node, className) { | ||
var cl = node.classList; | ||
const cl = node.classList; | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
const cl = node.classList; | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
function ClassNames(userOptions) { | ||
var optionsHandler = EmblaCarousel__default["default"].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) { | ||
function ClassNames(userOptions = {}) { | ||
let options; | ||
let carousel; | ||
let root; | ||
let slides; | ||
const selectedEvents = ['select', 'pointerUp']; | ||
const draggingEvents = ['pointerDown', 'pointerUp']; | ||
function init(embla, optionsHandler) { | ||
carousel = embla; | ||
options = optionsHandler.atMedia(self.options); | ||
const { | ||
mergeOptions, | ||
optionsAtMedia | ||
} = optionsHandler; | ||
const optionsBase = mergeOptions(defaultOptions, ClassNames.globalOptions); | ||
const allOptions = mergeOptions(optionsBase, userOptions); | ||
options = optionsAtMedia(allOptions); | ||
root = carousel.rootNode(); | ||
slides = carousel.slideNodes(); | ||
var isDraggable = carousel.internalEngine().options.draggable; | ||
const isDraggable = !!carousel.internalEngine().options.watchDrag; | ||
if (isDraggable) { | ||
@@ -46,10 +44,6 @@ addClass(root, options.draggable); | ||
if (options.dragging) { | ||
draggingEvents.forEach(function (evt) { | ||
return carousel.on(evt, toggleDraggingClass); | ||
}); | ||
draggingEvents.forEach(evt => carousel.on(evt, toggleDraggingClass)); | ||
} | ||
if (options.selected) { | ||
selectedEvents.forEach(function (evt) { | ||
return carousel.on(evt, toggleSelectedClass); | ||
}); | ||
selectedEvents.forEach(evt => carousel.on(evt, toggleSelectedClass)); | ||
toggleSelectedClass(); | ||
@@ -60,30 +54,20 @@ } | ||
removeClass(root, options.draggable); | ||
draggingEvents.forEach(function (evt) { | ||
return carousel.off(evt, toggleDraggingClass); | ||
}); | ||
selectedEvents.forEach(function (evt) { | ||
return carousel.off(evt, toggleSelectedClass); | ||
}); | ||
slides.forEach(function (slide) { | ||
return removeClass(slide, options.selected); | ||
}); | ||
draggingEvents.forEach(evt => carousel.off(evt, toggleDraggingClass)); | ||
selectedEvents.forEach(evt => carousel.off(evt, toggleSelectedClass)); | ||
slides.forEach(slide => removeClass(slide, options.selected)); | ||
} | ||
function toggleDraggingClass(evt) { | ||
function toggleDraggingClass(_, evt) { | ||
if (evt === 'pointerDown') addClass(root, options.dragging);else removeClass(root, options.dragging); | ||
} | ||
function toggleSelectedClass() { | ||
var inView = carousel.slidesInView(true); | ||
var notInView = carousel.slidesNotInView(true); | ||
notInView.forEach(function (index) { | ||
return removeClass(slides[index], options.selected); | ||
}); | ||
inView.forEach(function (index) { | ||
return addClass(slides[index], options.selected); | ||
}); | ||
const inView = carousel.slidesInView(true); | ||
const notInView = carousel.slidesNotInView(true); | ||
notInView.forEach(index => removeClass(slides[index], options.selected)); | ||
inView.forEach(index => addClass(slides[index], options.selected)); | ||
} | ||
var self = { | ||
const self = { | ||
name: 'classNames', | ||
options: optionsHandler.merge(optionsBase, userOptions), | ||
init: init, | ||
destroy: destroy | ||
options: userOptions, | ||
init, | ||
destroy | ||
}; | ||
@@ -90,0 +74,0 @@ return self; |
@@ -1,4 +0,2 @@ | ||
import EmblaCarousel from 'embla-carousel'; | ||
var defaultOptions = { | ||
const defaultOptions = { | ||
active: true, | ||
@@ -12,25 +10,29 @@ breakpoints: {}, | ||
function removeClass(node, className) { | ||
var cl = node.classList; | ||
const cl = node.classList; | ||
if (className && cl.contains(className)) cl.remove(className); | ||
} | ||
function addClass(node, className) { | ||
var cl = node.classList; | ||
const cl = node.classList; | ||
if (className && !cl.contains(className)) cl.add(className); | ||
} | ||
function ClassNames(userOptions) { | ||
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) { | ||
function ClassNames(userOptions = {}) { | ||
let options; | ||
let carousel; | ||
let root; | ||
let slides; | ||
const selectedEvents = ['select', 'pointerUp']; | ||
const draggingEvents = ['pointerDown', 'pointerUp']; | ||
function init(embla, optionsHandler) { | ||
carousel = embla; | ||
options = optionsHandler.atMedia(self.options); | ||
const { | ||
mergeOptions, | ||
optionsAtMedia | ||
} = optionsHandler; | ||
const optionsBase = mergeOptions(defaultOptions, ClassNames.globalOptions); | ||
const allOptions = mergeOptions(optionsBase, userOptions); | ||
options = optionsAtMedia(allOptions); | ||
root = carousel.rootNode(); | ||
slides = carousel.slideNodes(); | ||
var isDraggable = carousel.internalEngine().options.draggable; | ||
const isDraggable = !!carousel.internalEngine().options.watchDrag; | ||
if (isDraggable) { | ||
@@ -40,10 +42,6 @@ addClass(root, options.draggable); | ||
if (options.dragging) { | ||
draggingEvents.forEach(function (evt) { | ||
return carousel.on(evt, toggleDraggingClass); | ||
}); | ||
draggingEvents.forEach(evt => carousel.on(evt, toggleDraggingClass)); | ||
} | ||
if (options.selected) { | ||
selectedEvents.forEach(function (evt) { | ||
return carousel.on(evt, toggleSelectedClass); | ||
}); | ||
selectedEvents.forEach(evt => carousel.on(evt, toggleSelectedClass)); | ||
toggleSelectedClass(); | ||
@@ -54,30 +52,20 @@ } | ||
removeClass(root, options.draggable); | ||
draggingEvents.forEach(function (evt) { | ||
return carousel.off(evt, toggleDraggingClass); | ||
}); | ||
selectedEvents.forEach(function (evt) { | ||
return carousel.off(evt, toggleSelectedClass); | ||
}); | ||
slides.forEach(function (slide) { | ||
return removeClass(slide, options.selected); | ||
}); | ||
draggingEvents.forEach(evt => carousel.off(evt, toggleDraggingClass)); | ||
selectedEvents.forEach(evt => carousel.off(evt, toggleSelectedClass)); | ||
slides.forEach(slide => removeClass(slide, options.selected)); | ||
} | ||
function toggleDraggingClass(evt) { | ||
function toggleDraggingClass(_, evt) { | ||
if (evt === 'pointerDown') addClass(root, options.dragging);else removeClass(root, options.dragging); | ||
} | ||
function toggleSelectedClass() { | ||
var inView = carousel.slidesInView(true); | ||
var notInView = carousel.slidesNotInView(true); | ||
notInView.forEach(function (index) { | ||
return removeClass(slides[index], options.selected); | ||
}); | ||
inView.forEach(function (index) { | ||
return addClass(slides[index], options.selected); | ||
}); | ||
const inView = carousel.slidesInView(true); | ||
const notInView = carousel.slidesNotInView(true); | ||
notInView.forEach(index => removeClass(slides[index], options.selected)); | ||
inView.forEach(index => addClass(slides[index], options.selected)); | ||
} | ||
var self = { | ||
const self = { | ||
name: 'classNames', | ||
options: optionsHandler.merge(optionsBase, userOptions), | ||
init: init, | ||
destroy: destroy | ||
options: userOptions, | ||
init, | ||
destroy | ||
}; | ||
@@ -84,0 +72,0 @@ return self; |
@@ -1,1 +0,1 @@ | ||
!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})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).EmblaCarouselClassNames=n()}(this,(function(){"use strict";const e={active:!0,breakpoints:{},selected:"is-selected",draggable:"is-draggable",dragging:"is-dragging"};function n(e,n){const o=e.classList;n&&o.contains(n)&&o.remove(n)}function o(e,n){const o=e.classList;n&&!o.contains(n)&&o.add(n)}function t(i={}){let s,a,c,d;const r=["select","pointerUp"],l=["pointerDown","pointerUp"];function f(e,t){"pointerDown"===t?o(c,s.dragging):n(c,s.dragging)}function g(){const e=a.slidesInView(!0);a.slidesNotInView(!0).forEach((e=>n(d[e],s.selected))),e.forEach((e=>o(d[e],s.selected)))}return{name:"classNames",options:i,init:function(n,p){a=n;const{mergeOptions:u,optionsAtMedia:b}=p,h=u(e,t.globalOptions),m=u(h,i);s=b(m),c=a.rootNode(),d=a.slideNodes(),!!a.internalEngine().options.watchDrag&&o(c,s.draggable),s.dragging&&l.forEach((e=>a.on(e,f))),s.selected&&(r.forEach((e=>a.on(e,g))),g())},destroy:function(){n(c,s.draggable),l.forEach((e=>a.off(e,f))),r.forEach((e=>a.off(e,g))),d.forEach((e=>n(e,s.selected)))}}}return t.globalOptions=void 0,t})); |
@@ -1,3 +0,2 @@ | ||
export { ClassNamesType } from './components'; | ||
export { ClassNamesOptionsType } from './components/Options'; | ||
export { default } from './components'; | ||
export { ClassNamesType, ClassNamesOptionsType } from './components/ClassNames'; | ||
export { default } from './components/ClassNames'; |
{ | ||
"name": "embla-carousel-class-names", | ||
"version": "7.1.0", | ||
"version": "8.0.0-rc01", | ||
"author": "David Jerleke", | ||
@@ -58,4 +58,4 @@ "description": "A class name toggle 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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
11504
173
1