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

use-carousel-hook

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-carousel-hook - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

CHANGELOG.md
# Changelog
## [0.0.9]
- Update current and inView values on scroll.
## [0.0.8]

@@ -4,0 +8,0 @@

@@ -51,8 +51,22 @@ "use strict";

};
const updateCurrentOnScroll = () => {
const carouselEl = ref.current;
for (let index = 0; index < carouselEl.children.length; index++) {
const child = carouselEl.children[index];
if (child.offsetLeft >= carouselEl.scrollLeft) {
if (index !== current) {
setCurrent(index);
}
break;
}
}
};
react_1.useEffect(() => {
window.addEventListener('resize', updateMaxIndex);
window.addEventListener('resize', updateInView);
ref.current.addEventListener('scroll', updateCurrentOnScroll);
return () => {
window.removeEventListener('resize', updateMaxIndex);
window.removeEventListener('resize', updateInView);
ref.current.removeEventListener('scroll', updateCurrentOnScroll);
};

@@ -59,0 +73,0 @@ }, []);

@@ -46,8 +46,22 @@ import { useState, useRef, useEffect, useReducer, useCallback } from 'react';

};
const updateCurrentOnScroll = () => {
const carouselEl = ref.current;
for (let index = 0; index < carouselEl.children.length; index++) {
const child = carouselEl.children[index];
if (child.offsetLeft >= carouselEl.scrollLeft) {
if (index !== current) {
setCurrent(index);
}
break;
}
}
};
useEffect(() => {
window.addEventListener('resize', updateMaxIndex);
window.addEventListener('resize', updateInView);
ref.current.addEventListener('scroll', updateCurrentOnScroll);
return () => {
window.removeEventListener('resize', updateMaxIndex);
window.removeEventListener('resize', updateInView);
ref.current.removeEventListener('scroll', updateCurrentOnScroll);
};

@@ -54,0 +68,0 @@ }, []);

2

package.json
{
"name": "use-carousel-hook",
"version": "0.0.8",
"version": "0.0.9",
"description": "Adds functionality for carousels using React hooks",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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