{"id":18052602,"url":"https://github.com/opensrc0/gallery_in_react","last_synced_at":"2025-04-05T07:24:01.431Z","repository":{"id":88965180,"uuid":"148200571","full_name":"opensrc0/gallery_in_react","owner":"opensrc0","description":null,"archived":false,"fork":false,"pushed_at":"2018-09-10T18:32:32.000Z","size":30600,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T15:14:53.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opensrc0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-09-10T18:27:57.000Z","updated_at":"2024-04-10T04:19:00.000Z","dependencies_parsed_at":"2023-06-13T08:45:24.379Z","dependency_job_id":null,"html_url":"https://github.com/opensrc0/gallery_in_react","commit_stats":null,"previous_names":["hg-arch/gallery_in_react","opensrc0/gallery_in_react"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensrc0%2Fgallery_in_react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensrc0%2Fgallery_in_react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensrc0%2Fgallery_in_react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opensrc0%2Fgallery_in_react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opensrc0","download_url":"https://codeload.github.com/opensrc0/gallery_in_react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247301718,"owners_count":20916566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T23:12:27.532Z","updated_at":"2025-04-05T07:24:01.409Z","avatar_url":"https://github.com/opensrc0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"React Carousel Image Gallery\n===\n\n[![npm version](https://badge.fury.io/js/react-image-gallery.svg)](https://badge.fury.io/js/react-image-gallery)\n[![Download Count](http://img.shields.io/npm/dm/react-image-gallery.svg?style=flat)](http://www.npmjs.com/package/react-image-gallery)\n\n## Live Demo (try it on mobile for swipe support)\nLive demo: [`linxtion.com/demo/react-image-gallery`](http://linxtion.com/demo/react-image-gallery)\n\n![demo gif](https://github.com/xiaolin/react-image-gallery/raw/master/static/image_gallery.gif)\n\nReact image gallery is a React component for building image galleries and carousels\n\nFeatures of `react-image-gallery`\n* Mobile Swipe Gestures\n* Thumbnail Navigation\n* Fullscreen Support\n* Custom Rendered Slides\n* Responsive Design\n* Tons of customization options (see props below)\n* Lightweight ~8kb (gzipped, excluding react)\n\n## Getting started\n\n```\nnpm install react-image-gallery\n```\n\n### Style import\n\n```\n# SCSS\n@import \"node_modules/react-image-gallery/styles/scss/image-gallery.scss\";\n\n# CSS\n@import \"node_modules/react-image-gallery/styles/css/image-gallery.css\";\n\n# Webpack\nimport \"react-image-gallery/styles/css/image-gallery.css\";\n\n# Stylesheet with no icons\nnode_modules/react-image-gallery/styles/scss/image-gallery-no-icon.scss\nnode_modules/react-image-gallery/styles/css/image-gallery-no-icon.css\n```\n\n\n### Example\nNeed more example? See [`example/app.js`](https://github.com/xiaolin/react-image-gallery/blob/master/example/app.js)\n```js\nimport ImageGallery from 'react-image-gallery';\n\nclass MyComponent extends React.Component {\n\n  render() {\n\n    const images = [\n      {\n        original: 'http://lorempixel.com/1000/600/nature/1/',\n        thumbnail: 'http://lorempixel.com/250/150/nature/1/',\n      },\n      {\n        original: 'http://lorempixel.com/1000/600/nature/2/',\n        thumbnail: 'http://lorempixel.com/250/150/nature/2/'\n      },\n      {\n        original: 'http://lorempixel.com/1000/600/nature/3/',\n        thumbnail: 'http://lorempixel.com/250/150/nature/3/'\n      }\n    ]\n\n    return (\n      \u003cImageGallery items={images} /\u003e\n    );\n  }\n\n}\n```\n\n# Props\n\n* `items`: (required) Array of objects, see example above,\n  * Available Properties\n    * `original` - image src url\n    * `thumbnail` - image thumbnail src url\n    * `originalClass` - custom image class\n    * `thumbnailClass` - custom thumbnail class\n    * `renderItem` - Function for custom renderer (see renderItem below)\n    * `renderThumbInner` - Function for custom thumbnail renderer (see renderThumbInner below)\n    * `originalAlt` - image alt\n    * `thumbnailAlt` - thumbnail image alt\n    * `originalTitle` - image title\n    * `thumbnailTitle` - thumbnail image title\n    * `thumbnailLabel` - label for thumbnail\n    * `description` - description for image\n    * `imageSet` - array of `\u003csource\u003e` using `\u003cpicture\u003e` element (see [`app.js`](https://github.com/xiaolin/react-image-gallery/blob/master/example/app.js) for example)\n    * `srcSet` - image srcset (html5 attribute)\n    * `sizes` - image sizes (html5 attribute)\n    * `bulletClass` - extra class for the bullet of the item\n    * `bulletOnClick` - `callback({item, itemIndex, currentIndex})`\n        * A function that will be called upon bullet click.\n* `infinite`: Boolean, default `true`\n  * infinite sliding\n* `lazyLoad`: Boolean, default `false`\n* `showNav`: Boolean, default `true`\n* `showThumbnails`: Boolean, default `true`\n* `thumbnailPosition`: String, default `bottom`\n  * available positions: `top, right, bottom, left`\n* `showFullscreenButton`: Boolean, default `true`\n* `useBrowserFullscreen`: Boolean, default `true`\n  * if false, fullscreen will be done via css within the browser\n* `useTranslate3D`: Boolean, default `true`\n  * if false, will use `translate` instead of `translate3d` css property to transition slides\n* `showPlayButton`: Boolean, default `true`\n* `showBullets`: Boolean, default `false`\n* `showIndex`: Boolean, default `false`\n* `autoPlay`: Boolean, default `false`\n* `disableThumbnailScroll`: Boolean, default `false`\n  * disables the thumbnail container from adjusting\n* `slideOnThumbnailHover`: Boolean, default `false`\n  * slides to the currently hovered thumbnail\n* `disableArrowKeys`: Boolean, default `false`\n* `disableSwipe`: Boolean, default `false`\n* `defaultImage`: String, default `undefined`\n  * an image src pointing to your default image if an image fails to load\n  * handles both slide image, and thumbnail image\n* `indexSeparator`: String, default `' / '`, ignored if `showIndex` is false\n* `slideDuration`: Number, default `450`\n  * transition duration during image slide in milliseconds\n* `swipingTransitionDuration`: Number, default `0`\n  * transition duration while swiping in milliseconds\n* `slideInterval`: Number, default `3000`\n* `flickThreshold`: Number (float), default `0.4`\n  * Determines the max velocity of a swipe before it's considered a flick (lower = more sensitive)\n* `swipeThreshold`: Number, default `30`\n  * A percentage of how far the offset of the current slide is swiped to trigger a slide event.\n    e.g. If the current slide is swiped less than 30% to the left or right, it will not trigger a slide event.\n* `stopPropagation`: Boolean, default `false`\n    * Automatically calls stopPropagation on all 'swipe' events.\n* `preventDefaultTouchmoveEvent`: Boolean, default `false`\n    * An option to prevent the browser's touchmove event (stops the gallery from scrolling up or down when swiping)\n* `startIndex`: Number, default `0`\n* `onImageError`: Function, `callback(event)`\n  * overrides defaultImage\n* `onThumbnailError`: Function, `callback(event)`\n  * overrides defaultImage\n* `onThumbnailClick`: Function, `callback(event, index)`\n* `onImageLoad`: Function, `callback(event)`\n* `onSlide`: Function, `callback(currentIndex)`\n* `onScreenChange`: Function, `callback(fullscreenElement)`\n* `onPause`: Function, `callback(currentIndex)`\n* `onPlay`: Function, `callback(currentIndex)`\n* `onClick`: Function, `callback(event)`\n* `onTouchMove`: Function, `callback(event) on gallery slide`\n* `onTouchEnd`: Function, `callback(event) on gallery slide`\n* `onTouchStart`: Function, `callback(event) on gallery slide`\n* `onMouseOver`: Function, `callback(event) on gallery slide`\n* `onMouseLeave`: Function, `callback(event) on gallery slide`\n* `additionalClass`: String,\n    * Additional class that will be added to the root node of the component.\n* `renderCustomControls`: Function, custom controls rendering\n  * Use this to render custom controls or other elements on the currently displayed image (like the fullscreen button)\n  ```javascript\n    _renderCustomControls() {\n      return \u003ca href='' className='image-gallery-custom-action' onClick={this._customAction.bind(this)}/\u003e\n    }\n  ```\n* `renderItem`: Function, custom item rendering\n  * On a specific item `[{thumbnail: '...', renderItem: this.myRenderItem}]`\n  or\n  * As a prop passed into `ImageGallery` to completely override `_renderItem`, see source for reference\n* `renderThumbInner`: Function, custom thumbnail rendering\n  * On a specific item `[{thumbnail: '...', renderThumbInner: this.myRenderThumbInner}]`\n  or\n  * As a prop passed into `ImageGallery` to completely override `_renderThumbInner`, see source for reference\n\n* `renderLeftNav`: Function, custom left nav component\n  * Use this to render a custom left nav control\n  * Passes `onClick` callback that will slide to the previous item and `disabled` argument for when to disable the nav\n  ```javascript\n    renderLeftNav(onClick, disabled) {\n      return (\n        \u003cbutton\n          className='image-gallery-custom-left-nav'\n          disabled={disabled}\n          onClick={onClick}/\u003e\n      )\n    }\n  ```\n* `renderRightNav`: Function, custom right nav component\n  * Use this to render a custom right nav control\n  * Passes `onClick` callback that will slide to the next item and `disabled` argument for when to disable the nav\n  ```javascript\n    renderRightNav(onClick, disabled) {\n      return (\n        \u003cbutton\n          className='image-gallery-custom-right-nav'\n          disabled={disabled}\n          onClick={onClick}/\u003e\n      )\n    }\n  ```\n* `renderPlayPauseButton`: Function, play pause button component\n  * Use this to render a custom play pause button\n  * Passes `onClick` callback that will toggle play/pause and `isPlaying` argument for when gallery is playing\n  ```javascript\n    renderPlayPauseButton: (onClick, isPlaying) =\u003e {\n      return (\n        \u003cbutton\n          type='button'\n          className={\n            `image-gallery-play-button${isPlaying ? ' active' : ''}`}\n          onClick={onClick}\n        /\u003e\n      );\n    }\n  ```\n* `renderFullscreenButton`: Function, custom fullscreen button component\n  * Use this to render a custom fullscreen button\n  * Passes `onClick` callback that will toggle fullscreen and `isFullscreen` argument for when fullscreen is active\n  ```javascript\n    renderFullscreenButton: (onClick, isFullscreen) =\u003e {\n      return (\n        \u003cbutton\n          type='button'\n          className={\n            `image-gallery-fullscreen-button${isFullscreen ? ' active' : ''}`}\n          onClick={onClick}\n        /\u003e\n      );\n    },\n  ```\n\n\n# Functions\n\n* `play()`: plays the slides\n* `pause()`: pauses the slides\n* `fullScreen()`: activates full screen\n* `exitFullScreen()`: deactivates full screen\n* `slideToIndex(index)`: slides to a specific index\n* `getCurrentIndex()`: returns the current index\n\n# Contributing\n\n* Follow eslint provided\n* Comment your code\n* Describe your feature/implementation in the pullrequest\n* Write [clean](https://github.com/ryanmcdermott/clean-code-javascript) code\n\n# Build the example locally\n\n```\ngit clone https://github.com/xiaolin/react-image-gallery.git\ncd react-image-gallery\nnpm install\nnpm start\n```\n\nThen open [`localhost:8001`](http://localhost:8001) in a browser.\n\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensrc0%2Fgallery_in_react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopensrc0%2Fgallery_in_react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensrc0%2Fgallery_in_react/lists"}