Skip to content

Commit fc34490

Browse files
authored
Merge pull request #62 from yifaneye/dev
v0.2.7
2 parents 205bc3a + 3e90451 commit fc34490

File tree

8 files changed

+26
-20
lines changed

8 files changed

+26
-20
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
[![NPM](https://img.shields.io/npm/v/react-gallery-carousel.svg)](https://www.npmjs.com/package/react-gallery-carousel)
44

5+
6+
## v0.2.7 (2021-12-18)
7+
8+
### Enhancements
9+
10+
- Fix "invalid or unexpected token" issue in Next.js.
11+
([Issue #51](https://github.com/yifaneye/react-gallery-carousel/issues/51))
12+
13+
- Remove request to "object Object"
14+
([Issue #52](https://github.com/yifaneye/react-gallery-carousel/issues/52))
15+
516
## v0.2.6 (2021-12-06)
617

718
### Enhancements

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ I have **used and carefully analyzed a lot of carousel/slider components**. I su
4343
13. Some of them disable pinching to zoom, while some others glitch when pinching with 2 fingers. Besides, when the window is zoomed in, most of them still detect for touch swiping to move to the previous, or the next slide, while the intention of most users in this scenario is panning to see other parts of the current slide.
4444
14. Some of them will cause the slides to stuck its position on window resize or on mobile device orientation change, until another user interaction.
4545
15. Some of them can only have predetermined images (i.e. before the carousel component mounts).
46-
16. Most of them do not provide a solution for fallback image (for when an image is not available).
46+
16. Most of them do not provide a solution for fallback/placeholder image (for when an image is not available).
4747
17. Some of them get zoomed in when the user double taps on the control, while the intention of most users in this scenario is to quickly go to the next after the next slide.
4848
18. Some of them remove the left or right button to indicate that there are no more slides in that direction. However, user is likely to click that spot where the button used to be, which causes undesired behaviours e.g. clicking on a link or button which is also at that spot.
4949
19. Some of them use the method of cloning the first, and the last slide to achieve looping (or infinite mode). I think that method is not great semantically.

example/src/components/Footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Footer = () => {
55
return (
66
<footer className='section'>
77
<div className='action-container'>
8-
<strong>react-gallery-carousel (v0.2.6)</strong>
8+
<strong>react-gallery-carousel (v0.2.7)</strong>
99
<div className='star-button-container'>
1010
<GitHubButton
1111
href='https://github.com/yifaneye/react-gallery-carousel'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-gallery-carousel",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "Mobile-friendly Carousel with batteries included (supporting touch, mouse emulation, lazy loading, thumbnails, fullscreen, RTL, keyboard navigation and customisations).",
55
"author": "yifaneye",
66
"license": "MIT",

react-gallery-carousel-nextjs/components/Carousel4.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useEffect, useState } from 'react';
22
import Carousel from 'react-gallery-carousel';
3-
import 'react-gallery-carousel/dist/index.css';
43

54
const Carousel4 = ({ images }) => {
65
const [dynamicImages, setDynamicImages] = useState([]);

src/components/Image/Image.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Fragment, useRef, useState } from 'react';
22
import styles from './Image.module.css';
3-
import placeholderImage from 'placeholder.jpg';
4-
import fallbackImage from 'fallback.png';
3+
import { PLACEHOLDER_IMAGE } from './constants';
54
import { Caption } from '../Widgets';
65
import useIntersectionObserver from '../../utils/useIntersectionObserver';
76
import PropTypes from 'prop-types';
@@ -13,7 +12,7 @@ import {
1312
} from '../../utils/validators';
1413

1514
const handleError = (event) => {
16-
event.target.src = fallbackImage;
15+
event.target.src = PLACEHOLDER_IMAGE;
1716
};
1817

1918
const LazyLoadedImage = (props) => {
@@ -22,7 +21,7 @@ const LazyLoadedImage = (props) => {
2221
imageRef,
2322
props.slidesContainerRef,
2423
'0px 101% 0px 101%'
25-
// preload 2 images on either side of the slides container (viewport)
24+
// preload 2 images on either side of the slides' container (viewport)
2625
);
2726
const [shouldShowThumbnail, setShouldShowThumbnail] = useState(
2827
props.image.thumbnail
@@ -40,13 +39,9 @@ const LazyLoadedImage = (props) => {
4039

4140
let { src, srcset, alt, thumbnail, ...otherImageProps } = props.image;
4241

43-
src = isInViewport ? (hasError ? fallbackImage : src) : placeholderImage;
44-
srcset = isInViewport ? (hasError ? null : srcset) : null;
45-
thumbnail = isInViewport
46-
? hasError
47-
? fallbackImage
48-
: thumbnail
49-
: placeholderImage;
42+
src = isInViewport && !hasError ? src : PLACEHOLDER_IMAGE;
43+
srcset = isInViewport && !hasError ? srcset : null;
44+
thumbnail = isInViewport && !hasError ? thumbnail : PLACEHOLDER_IMAGE;
5045

5146
return (
5247
<>

src/components/Image/ImageThumbnail.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React, { useRef } from 'react';
22
import styles from './Image.module.css';
3-
import placeholderImage from 'placeholder.jpg';
4-
import fallbackImage from 'fallback.png';
3+
import { PLACEHOLDER_IMAGE } from './constants';
54
import useIntersectionObserver from '../../utils/useIntersectionObserver';
65
import PropTypes from 'prop-types';
76
import { elementRef, imageObject } from '../../utils/validators';
87

98
const handleError = (event) => {
109
// permanently replace the image with the fallback image
11-
event.target.src = fallbackImage;
10+
event.target.src = PLACEHOLDER_IMAGE;
1211
};
1312

1413
const LazyLoadedImageThumbnail = (props) => {
@@ -17,12 +16,12 @@ const LazyLoadedImageThumbnail = (props) => {
1716
imageRef,
1817
props.thumbnailsContainerRef,
1918
'0px 20% 0px 20%'
20-
// preload approximately 2 image thumbnails on either side of the thumbnails container (viewport)
19+
// preload approximately 2 image thumbnails on either side of the thumbnails' container (viewport)
2120
// 'approximately' is due to the presence of margin between adjacent images
2221
);
2322

2423
// temporarily replace the image with the placeholder image
25-
const src = isInViewport ? props.src : placeholderImage;
24+
const src = isInViewport ? props.src : PLACEHOLDER_IMAGE;
2625

2726
return (
2827
<img

src/components/Image/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const PLACEHOLDER_IMAGE =
2+
'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg==';

0 commit comments

Comments
 (0)