diff --git a/README.md b/README.md
index f9b9c6b3..8c7a4dd2 100644
--- a/README.md
+++ b/README.md
@@ -116,15 +116,16 @@ const Gallery = () => {
}
}
```
-
+- `syncStateOnPropsUpdate`: Boolean, default `true` - Sync some props (like `activeIndex`) with carousel state while new props passed. This allows you to avoid resetting the carousel position while updating the props (e.g.: `children` or `items`).
- `swipeDelta`: Number, default `20` - Set minimum distance to the start of the swiping (px).
- `swipeExtraPadding`: Number, default `200` - Set maximum distance from initial place before swipe action will be stopped (px).
- `ssrSilentMode`: Boolean, default `true` - Disable classnames modifiers for server side rendering.
- `touchTracking`: Boolean, default `true` - Enable touch move animation.
- `touchMoveDefaultEvents`: Boolean, default `true` - Enable touch move default events on swiping. If `false` was specified, this prevents vertical scrolling of the parent elements during the swipe.
- `onInitialized(e: EventObject)`: Function - Fired as callback after the gallery was created.
-- `onResizeEvent(e: Event)`: Function - Fired during the "resize" event to determine whether to call the event handler. Default result of `() => true`;
+- `onResizeEvent(e: Event)`: Function, default `shouldProcessResizeEvent` method - Fired during the "resize" event to determine whether to call the event handler. Default method checks is the root element width has changed.
- `onResized(e: EventObject)`: Function - Fired as callback after the gallery was resized.
+- `onUpdated(e: EventObject)`: Function - Fired as callback after updating the gallery props.
- `onSlideChange(e: EventObject)`: Function - Fired before the event object changes.
- `onSlideChanged(e: EventObject)`: Function - Fired after the event object was changed.
- `renderSlideInfo(e: SlideInfo)`: Rendering function - create a custom component.
@@ -133,7 +134,7 @@ const Gallery = () => {
- `renderNextButton({ isDisabled })`: Rendering function - create a custom component.
- `renderPlayPauseButton({ isPlaying })`: Rendering function - create a custom component.
-#### Methods
+#### Methods (Refs [example](https://maxmarinich.github.io/react-alice-carousel/#custom-components-refs))
- `slidePrev(e: Event) => void` : Go to the prev slide.
- `slideNext(e: Event) => void` : Go to the next slide.
- `slideTo(activeIndex?: number) => void` : Go to the specified slide.
@@ -163,7 +164,7 @@ enum EventType {
ACTION = 'action', // used if a general user action (button click or swipe)
INIT = 'init', // used if the initial event was triggered
RESIZE = 'resize', // used if the gallery size was changed
- UPDATE = 'update', // used if the gallery was updated with props (activeIndex)
+ UPDATE = 'update', // used if the gallery was updated with props
}
```
diff --git a/package-lock.json b/package-lock.json
index 1e2a1a71..458dda51 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "react-alice-carousel",
- "version": "2.7.1",
+ "version": "2.8.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "react-alice-carousel",
- "version": "2.7.1",
+ "version": "2.8.0",
"license": "MIT",
"dependencies": {
"vanilla-swipe": "^2.4.1"
diff --git a/package.json b/package.json
index b93be317..ea154a01 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-alice-carousel",
- "version": "2.7.1",
+ "version": "2.8.0",
"description": "React image gallery, react slideshow carousel, react content rotator",
"main": "./lib/react-alice-carousel.js",
"types": "./lib/react-alice-carousel.d.ts",
diff --git a/src/components/app.tsx b/src/components/app.tsx
index ead34b7a..f25a08a9 100644
--- a/src/components/app.tsx
+++ b/src/components/app.tsx
@@ -3,12 +3,13 @@ import Header from './header';
import Navigation from './navigation';
import getPageComponent from './pages';
import scheme from './scheme';
+import { scrollTo } from '../hooks/useScroll';
import '../main.scss';
import '../lib/scss/alice-carousel.scss';
export default function App() {
const [defaultPage] = scheme;
- const [{ id, title }, setPage] = useState(defaultPage);
+ const [page, setPage] = useState(defaultPage);
useEffect(() => {
const { hash = '#' } = window.location;
@@ -16,7 +17,13 @@ export default function App() {
const page = scheme.find(({ id }) => id === hashId || hashId.includes(id));
if (page) setPage(page);
- }, []);
+
+ requestAnimationFrame(() => {
+ if (hash.length > 1) {
+ scrollTo(hash);
+ }
+ });
+ }, [page]);
return (