Socket
Socket
Sign inDemoInstall

embla-carousel-auto-height

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embla-carousel-auto-height - npm Package Compare versions

Comparing version 7.1.0 to 8.0.0-rc01

components/AutoHeight.d.ts

1

components/Options.d.ts

@@ -6,2 +6,1 @@ import { CreateOptionsType } from 'embla-carousel/components/Options';

export declare const defaultOptions: OptionsType;
export type AutoHeightOptionsType = 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,

@@ -15,55 +9,53 @@ breakpoints: {},

function AutoHeight(userOptions) {
var optionsHandler = EmblaCarousel__default["default"].optionsHandler();
var optionsBase = optionsHandler.merge(defaultOptions, AutoHeight.globalOptions);
var options;
var carousel;
var slideBounds = [];
var slideHeights = [];
var heightEvents = ['select', 'pointerUp'];
var inViewThreshold = 0.5;
function init(embla) {
function AutoHeight(userOptions = {}) {
let options;
let carousel;
let slideBounds = [];
let slideHeights = [];
const heightEvents = ['select', 'pointerUp'];
const inViewThreshold = 0.5;
function init(embla, optionsHandler) {
carousel = embla;
options = optionsHandler.atMedia(self.options);
var _a = carousel.internalEngine(),
axis = _a.options.axis,
slidesInView = _a.slidesInView,
slideRects = _a.slideRects;
const {
mergeOptions,
optionsAtMedia
} = optionsHandler;
const optionsBase = mergeOptions(defaultOptions, AutoHeight.globalOptions);
const allOptions = mergeOptions(optionsBase, userOptions);
options = optionsAtMedia(allOptions);
const {
options: {
axis
},
slidesInView,
slideRects
} = carousel.internalEngine();
if (axis === 'y') return;
slideBounds = slidesInView.findSlideBounds(undefined, inViewThreshold);
slideHeights = slideRects.map(function (rect) {
return rect.height;
});
heightEvents.forEach(function (evt) {
return carousel.on(evt, setContainerHeight);
});
slideHeights = slideRects.map(rect => rect.height);
heightEvents.forEach(evt => carousel.on(evt, setContainerHeight));
setContainerHeight();
}
function destroy() {
heightEvents.forEach(function (evt) {
return carousel.off(evt, setContainerHeight);
});
setContainerHeight('destroy');
heightEvents.forEach(evt => carousel.off(evt, setContainerHeight));
setContainerHeight(undefined, 'destroy');
}
function highestInView() {
var _a = carousel.internalEngine(),
slidesInView = _a.slidesInView,
target = _a.target;
var inViewIndexes = slidesInView.check(target.get(), slideBounds);
var heights = inViewIndexes.map(function (index) {
return slideHeights[index];
});
return heights.reduce(function (a, b) {
return Math.max(a, b);
}, 0);
const {
slidesInView,
target
} = carousel.internalEngine();
const inViewIndexes = slidesInView.check(target.get(), slideBounds);
const heights = inViewIndexes.map(index => slideHeights[index]);
return heights.reduce((a, b) => Math.max(a, b), 0);
}
function setContainerHeight(evt) {
var height = evt === 'destroy' ? options.destroyHeight : "".concat(highestInView(), "px");
function setContainerHeight(_, evt) {
const height = evt === 'destroy' ? options.destroyHeight : `${highestInView()}px`;
carousel.containerNode().style.height = height;
}
var self = {
const self = {
name: 'autoHeight',
options: optionsHandler.merge(optionsBase, userOptions),
init: init,
destroy: destroy
options: userOptions,
init,
destroy
};

@@ -70,0 +62,0 @@ return self;

@@ -1,4 +0,2 @@

import EmblaCarousel from 'embla-carousel';
var defaultOptions = {
const defaultOptions = {
active: true,

@@ -9,55 +7,53 @@ breakpoints: {},

function AutoHeight(userOptions) {
var optionsHandler = EmblaCarousel.optionsHandler();
var optionsBase = optionsHandler.merge(defaultOptions, AutoHeight.globalOptions);
var options;
var carousel;
var slideBounds = [];
var slideHeights = [];
var heightEvents = ['select', 'pointerUp'];
var inViewThreshold = 0.5;
function init(embla) {
function AutoHeight(userOptions = {}) {
let options;
let carousel;
let slideBounds = [];
let slideHeights = [];
const heightEvents = ['select', 'pointerUp'];
const inViewThreshold = 0.5;
function init(embla, optionsHandler) {
carousel = embla;
options = optionsHandler.atMedia(self.options);
var _a = carousel.internalEngine(),
axis = _a.options.axis,
slidesInView = _a.slidesInView,
slideRects = _a.slideRects;
const {
mergeOptions,
optionsAtMedia
} = optionsHandler;
const optionsBase = mergeOptions(defaultOptions, AutoHeight.globalOptions);
const allOptions = mergeOptions(optionsBase, userOptions);
options = optionsAtMedia(allOptions);
const {
options: {
axis
},
slidesInView,
slideRects
} = carousel.internalEngine();
if (axis === 'y') return;
slideBounds = slidesInView.findSlideBounds(undefined, inViewThreshold);
slideHeights = slideRects.map(function (rect) {
return rect.height;
});
heightEvents.forEach(function (evt) {
return carousel.on(evt, setContainerHeight);
});
slideHeights = slideRects.map(rect => rect.height);
heightEvents.forEach(evt => carousel.on(evt, setContainerHeight));
setContainerHeight();
}
function destroy() {
heightEvents.forEach(function (evt) {
return carousel.off(evt, setContainerHeight);
});
setContainerHeight('destroy');
heightEvents.forEach(evt => carousel.off(evt, setContainerHeight));
setContainerHeight(undefined, 'destroy');
}
function highestInView() {
var _a = carousel.internalEngine(),
slidesInView = _a.slidesInView,
target = _a.target;
var inViewIndexes = slidesInView.check(target.get(), slideBounds);
var heights = inViewIndexes.map(function (index) {
return slideHeights[index];
});
return heights.reduce(function (a, b) {
return Math.max(a, b);
}, 0);
const {
slidesInView,
target
} = carousel.internalEngine();
const inViewIndexes = slidesInView.check(target.get(), slideBounds);
const heights = inViewIndexes.map(index => slideHeights[index]);
return heights.reduce((a, b) => Math.max(a, b), 0);
}
function setContainerHeight(evt) {
var height = evt === 'destroy' ? options.destroyHeight : "".concat(highestInView(), "px");
function setContainerHeight(_, evt) {
const height = evt === 'destroy' ? options.destroyHeight : `${highestInView()}px`;
carousel.containerNode().style.height = height;
}
var self = {
const self = {
name: 'autoHeight',
options: optionsHandler.merge(optionsBase, userOptions),
init: init,
destroy: destroy
options: userOptions,
init,
destroy
};

@@ -64,0 +60,0 @@ return self;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("embla-carousel")):"function"==typeof define&&define.amd?define(["embla-carousel"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).EmblaCarouselAutoHeight=t(e.EmblaCarousel)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),o={active:!0,breakpoints:{},destroyHeight:"auto"};function i(e){var t,r,a=n.default.optionsHandler(),u=a.merge(o,i.globalOptions),s=[],f=[],l=["select","pointerUp"];function d(e){var n,o,i,a="destroy"===e?t.destroyHeight:"".concat((n=r.internalEngine(),o=n.slidesInView,i=n.target,o.check(i.get(),s).map((function(e){return f[e]})).reduce((function(e,t){return Math.max(e,t)}),0)),"px");r.containerNode().style.height=a}var c={name:"autoHeight",options:a.merge(u,e),init:function(e){r=e,t=a.atMedia(c.options);var n=r.internalEngine(),o=n.options.axis,i=n.slidesInView,u=n.slideRects;"y"!==o&&(s=i.findSlideBounds(void 0,.5),f=u.map((function(e){return e.height})),l.forEach((function(e){return r.on(e,d)})),d())},destroy:function(){l.forEach((function(e){return r.off(e,d)})),d("destroy")}};return c}return i.globalOptions=void 0,i}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).EmblaCarouselAutoHeight=t()}(this,(function(){"use strict";const e={active:!0,breakpoints:{},destroyHeight:"auto"};function t(n={}){let o,i,s=[],d=[];const c=["select","pointerUp"];function r(e,t){const n="destroy"===t?o.destroyHeight:`${function(){const{slidesInView:e,target:t}=i.internalEngine();return e.check(t.get(),s).map((e=>d[e])).reduce(((e,t)=>Math.max(e,t)),0)}()}px`;i.containerNode().style.height=n}return{name:"autoHeight",options:n,init:function(a,f){i=a;const{mergeOptions:l,optionsAtMedia:u}=f,p=l(e,t.globalOptions),g=l(p,n);o=u(g);const{options:{axis:h},slidesInView:y,slideRects:m}=i.internalEngine();"y"!==h&&(s=y.findSlideBounds(void 0,.5),d=m.map((e=>e.height)),c.forEach((e=>i.on(e,r))),r())},destroy:function(){c.forEach((e=>i.off(e,r))),r(void 0,"destroy")}}}return t.globalOptions=void 0,t}));

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

export { AutoHeightType } from './components';
export { AutoHeightOptionsType } from './components/Options';
export { default } from './components';
export { AutoHeightType, AutoHeightOptionsType } from './components/AutoHeight';
export { default } from './components/AutoHeight';
{
"name": "embla-carousel-auto-height",
"version": "7.1.0",
"version": "8.0.0-rc01",
"author": "David Jerleke",

@@ -58,4 +58,4 @@ "description": "An auto height 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

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