Code Monkey home page Code Monkey logo

react-image-lightbox's People

Contributors

c00kiemon5ter avatar dependabot-preview[bot] avatar dependabot[bot] avatar fritz-c avatar horat1us avatar leoek avatar lexich avatar metzgegu avatar mmarkelov avatar nicoqh avatar nnishimura avatar ohtake avatar pborawski78 avatar psrebniak avatar rajesh-kumar-r avatar sbking avatar stby4 avatar sugarshin avatar webcarrot avatar will-ks avatar wuweiweiwu avatar zanedb avatar zlyfenek avatar zslabs avatar zyclotrop-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-image-lightbox's Issues

Allow background color for image to be set

There doesn't seem to be a way to specify the background color for the image inside the lightbox. This would be helpful so that images with a transparent background could have a background to contrast to.

Browser support

Do you happen to know what browsers this is compatible with?

Warning: Failed prop type: ...

Hi~.
I want to use this lightbox simply.

But I got this error message.

Warning: Failed prop type: The prop `contentLabel` is marked as required in `Modal`, but its value is `undefined`.

Works well. Just an error message.

my components is..

        <div
          className="details__body"
          style={styles.body}
        >
          <div style={styles.imgWrap}>
            <img
              style={styles.img}
              src={data.preview}
              alt=""
              onClick={(e) => {
                e.stopPropagation();
                this.setState({ isImgOpen: true });
              }}
            />
            {
              this.state.isImgOpen &&
                <Lightbox
                  mainSrc={data.preview}
                  onCloseRequest={() => this.setState({ isImgOpen: false })}
                />
            }
          </div>
        </div>

Thanks you for cool package anyway,

Non browser env incompatible

react-image-lightbox is incompatible with non browser env.

It cannot be used in a module bundler like Webpack that uses use strict.

When I include the script in my project with import Lightbox from "react-image-lightbox"

and I try to build my project (it execute the javascript in a non browser env) I have this error: window is not defined

You use the window variable in src/util.js and src/react-image-lightbox.js.

I think the problem could be resolve surrounding all windowuses by

if(typeof window != 'undefined'){

So I did and after I had the same problem with document var.

For more explanations, please read this article, in particular the section Wait, you tried to run my code where?
https://nolanlawson.com/2015/10/19/the-struggles-of-publishing-a-javascript-library/

Mobile support

Hi Chris! Great work overall!
It would be nice if you add mobile browsers support (touch).
Right now component does not move zoomed image but scrolls the page underneath.

Opening Lightbox always scrolls to top of page

I'm using masonry to show images on my page. Every click on each image opens Lightbox. When I have many images, I have to scroll page down. Then, when I open Lightbox, it scrolls (moves) to the top of page. IMO it's not desired behavior. I think it is caused by hardcoded position of react-modal component (position: absolute, top: 0, etc). Maybe Lightbox should take current position to show modal, or maybe simply have position: fixed?

React 15.5.0 support

Hi! Was wondering if React 15.5.0 support was on your radar. Not that it's technically broken, but because of the separation of the PropTypes separation, using your package in newer projects shows a lot of warnings. Happy to work on a PR for this, but wasn't sure what else was tied up that may be targeting older versions.

Close button invisible

I have dropped the example code provided with react-image-lightbox v3.1.0 in my project, all works fine, but the close button is invisible. The zoom buttons are visible (and functional) though.

From the browser element inspector:

<li class="ril-toolbar__item toolbarItem___3WbMb">
    <button type="button" class="close ril-close ril-toolbar__item__child toolbarItemChild___2U_MP builtinButton___1zqo6 closeButton___3BdAF"></button>
</li>

Am I missing something, any clue?

Edit: I can click the close button, but there's no icon.

setAppElement from react-modal

Hi everybody,

I have integrated react-image-lightbox however I have the following error message: "Uncaught Error: react-modal: You must set an element with Modal.setAppElement(el) to make this accessible"

Anyone know how could I fix it? I am using "react-modal": "^1.3.0" dependency.

Thanks a lot for your help.

Warning: PropTypes validators

Hello,

I tried your react component and it work really well. However using it generates a warning in the console:

warning.js:36 Warning: Failed prop type: Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types
    in ReactImageLightbox (at App.js:43)
    in App (at index.js:7)

I'm new to react to perhaps I am missing something. I created my application using
create-react-app and it uses react V15.4.2. Should I upgrade to react 15.5 ?

Thanks


The following code reproduces the issue:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Lightbox from 'react-image-lightbox';


class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      isOpen: false,
      photoIndex: 0
    };
  }


  render() {
    const {isOpen, photoIndex} = this.state;


    const images = [
      '//placekitten.com/1500/500',
      '//placekitten.com/4000/3000',
      '//placekitten.com/800/1200',
      '//placekitten.com/1500/1500'
    ];

    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>

        <button onClick={() => this.setState({ isOpen: true })}>Open lightbox</button>


        {isOpen &&
                <Lightbox
                  mainSrc={images[photoIndex]}
                  nextSrc={images[(photoIndex + 1) % images.length]}
                  prevSrc={images[(photoIndex + images.length - 1) % images.length]}

                  onCloseRequest={() => this.setState({ isOpen: false })}
                  onMovePrevRequest={() => this.setState({
                    photoIndex: (photoIndex + images.length - 1) % images.length,
                  })}
                  onMoveNextRequest={() => this.setState({
                    photoIndex: (photoIndex + 1) % images.length,
                  })}
                />
                }
      </div>
    );
  }
}

export default App;

Related package.json:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-image-lightbox": "^3.4.3",
    "sinon": "^2.1.0"
  },
  "devDependencies": {
    "react-scripts": "0.9.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Fetch images after lightbox shown up

Hi.. In my case I want to fetch the images after the lightbox shown up, but I've got this warning.
The prop 'mainSrc' is marked as required in 'ReactImageLightbox', but its value is 'undefined'

I want to include loading indicator as my default mainSrc, but you already provide it before the data fetched.
How can I use your loading indicator as my default mainSrc? or do you have any suggestion to solve this problem?

Dynamic <canvas> support

Hi all!
I'm using PDF.js which in my implementation, returns a <canvas> element for each page of the PDF on request. Does this library support showing dynamically generated canvas images? Wanted to check before I go diving in as it's a bit outside of the normal examples. Thanks!

[Question] preferred way of styling the component or setting custom zIndex

Hi,

thanks for this component,

just started using it and although base styles work just fine I need to change the z-index of the lightbox for it to be placed above another box that I can't change the z-index of (also might have to tweak other styles as well to match some other styles in my app)

so I was wondering if there was a preferred way of modifying the styles, apart from overriding with important in my own style sheets

thanks for your time

SSR support

Unfortunately, this component doesn't seem to work with server side rendering. Upon being imported it tries to immediately access the window object thereby crashing the SSR build process. Ideally, it should access window global only after React component instantiation. That way it can be used in componentDidMount method, for example. Isomorphic or universal rendering is becoming really popular these days, so it really should be a must have feature.
If I had to guess what is causing then it'd be this line
https://github.com/fritz-c/react-image-lightbox/blob/5272072f349d2d7172f327c1c373ff3705b847da/src/react-image-lightbox.js#L29

Saving images on iOS

Hey @fritz-c,
Thanks for all your hard work on this! Having a bit of difficulty saving images on iOS. I'm not using the downloadBlocker option and it does appear to be working fine in Chrome on iOS. Have you run into this yourself at all? It looks like normally this is done on iOS with user-select: none; and touch-callout: none; but I'm not sure if I'm seeing that -- only touch-action: none;

Close button styles are overridden by Twitter Bootstrap

Hello!

Thanks a lot for this component!
We use it in our React project with Twitter Bootstrap and webpack. Unfortunately we found that, .close css class styles are overridden by Twitter Bootstrap. Is it possible to replace them by something more specific (like ril-close or react-image-lightbox-close), to keep ability to customize component and not to be overridden accidentally?

Fix zoom out behavior

When zooming in on one point in an image and then zooming out from another, the image can start to slide outside of the viewport. I've tried to reduce the effects with max offset settings, but the result (and current implementation) is jerky and not at all eye-pleasing.

zoomout

I'm certain that the right computations will provide both smooth zooming in and out from any point on the image, but after a couple hours trying out different things, I'm still at a loss. If anyone could offer some advice on how to handle this, I would be very grateful. The relevant code can be found here: https://github.com/fritz-c/react-image-lightbox/blob/master/src/react-image-lightbox.js#L212-L246

Getting two console warnings

Everything is working as expected, but I'm wondering why I'm getting these two warnings in chrome dev tools' console:

Warning: Unknown prop `portalId` on <div> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
    in div

Warning: Unknown prop `_radiumDidResolveStyles` on <div> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
    in div (created by StyleRoot)
    in StyleRoot (created by ReactImageLightbox)
    in div

reactModalStyle not working

const customStyles = {
    overlay: {
        backgroundColor: 'rgba(255, 255, 255, 0.5)'
    }
}

<Lightbox
    mainSrc={this.props.images[this.state.index]}
    nextSrc={this.props.images[(this.state.index + 1) % this.props.images.length]}
    prevSrc={this.props.images[(this.state.index + this.props.images.length - 1) % this.props.images.length]}

    reactModalStyle={customStyles}     /* NOT WORKING */   

    onCloseRequest={this.closeLightbox.bind(this)}
    onMovePrevRequest={this.movePrev.bind(this)}
    onMoveNextRequest={this.moveNext.bind(this)}
/>

Can someone point me if I'm doing something wrong?

Immersive mouse control when zoomed-in, Flickr-inspired

I think the UX on the Flickr lightbox is really fantastic on desktop and would love to see something similar here.

The functionality I refer to is when you have a image larger than the viewport (e.g. viewing it at original size) and the user is moving the cursor, the image will move in response to show more.

The algorithm is equivalent to directly mapping cursor to background-position as a % of where it is on the screen. E.g. if cursor is at top of screen, then you can see the top of the image.

It is a really nice and slick way of immersively viewing content.

How change icon from toolbar ?

Hello,
I would like to change the icons on the toolbar because I changed the CSS and my background is white, I can't change the icons as they are image.
Do you have a solution ?

I would either use the icons or materials are-awesome power or coloring

Best regards,

Broken images can overlay spinner

Right now if there is an invalid image in the lightbox, the spinner can overlap the other images; depending on where it falls in the ordering. Right now there is a onImageLoadError prop that can be used, but it currently doesn't have a default as far as how to handle the UI. In the gif below I added in a small snippet to take care of not degrading the other images, but ideally we would not even show the loader and instead have some error text that could be shown/customized.

lightbox

Feature: Closing lightbox on click outside of image

Hi,

It could be nice (to my mind), to add the possibility of closing the lightbox when the user clicks outside of the image (i.e the gray overlay).
Clicking on the cross at the top right-hand corner does the job perferctly, but it could be more user-friendly to also be able to close by clicking on the overlay.

This could of course be optional, for instance by passing the appropriate prop to the Lightbox component.

Just a quick suggestion :)

Thanks for this great component anyway,

Update `react-modal`

Hi @fritz-c,
In doing some testing to see if I can upgrade an app to React 16, it looks like this library is using react-modal which is using an unsupported API to interact with portals in newer version of React. It looks like there's an update available that may solve the issue and wanted to know if this was something on your plate already or if you needed some assistance. Thanks!

Images blurry in iOS Safari

On iOS Safari, the images are extremely blurry. You can see this on the demo page on an iPhone with iOS 10.3. I believe this is happening because of how the images are scaled.

Right now, the image is given a width/height to fit in the browser viewport, and then a transform is used to scale the image based on that. This means that on iOS Safari, a 2000x2000 image might be rendered initially at, say, 750x750. When it is transformed, iOS Safari seems to keep the initially rendered snapshot and transform that, so you get a blurry version of the image when zoomed in.

To fix this, I think it could be possible to change the logic so that it initially displays the image at the full image resolution, and then applies a transform to that to adjust it to the viewport size, and continue to use the full image resolution as the basis for calculating the transforms.

Router update?

Hi @fritz-c! Thanks for the component! Is is possible to have it update the url as one opens the lightbox and moves from one image to another? If not, is it something you've considered adding?

Thank you!

Tab Focus moves in the background

Tab Focus moves out of the lightbox after the close icon instead of rotating within the lightbox. I have fixed this code on my local machine but unable to push my branch due to authorization. Please help me

Why not use CSS Module for 'close' class name?

Good work for developing this with CSS Module, but I find there is still a class name .close is not in CSS Module style. It's conflicting with Bootstrap css in my project.

className={'close ril-close ril-toolbar__item__child' +

Move CSS to an external file

While importing styles with style-loader makes the component more plug-and-play-able, it causes a couple significant issues:

  1. It doesn't work with isomorphic builds (/ server-side rendering / SSR).
  2. CSS class precedence is a pain, because style-loader either adds the <style> tag to the very bottom or top of the <head>, making it difficult to override the CSS without using !important.

With these in mind, I'm planning on migrating all of the CSS into an external file using extract-text-webpack-plugin.

image thumbnails

Hi @fritz-c,

What's the purpose of the mainSrcThumbnail, nextSrcThumbnail and previousSrcThumbnail?

It's noted in the readme.md, but I don't understand.

Kind regards,

Sander

How to get images with header?

Hi,
Thanks for your amazing plugin. It works like a charm.
But I have a problem with getting images from server that needs token.

I solved that problem by getting images from server then converting to base64.

Is there any way to solve my problem?

Thanks for any help!

Toolbar Item Child height via css

I realize you can set the toobar height through css with something like

.ril-toolbar{
    height: 200px!important;
}

But toolbarItemChild is only set from scss, is there a way to change the item child line-height?

can i place rotate button ??

hi,
i want to put rotate button with zoom buttons.
i able to place that button but how can i handle that rotate button click?

Youtube Embedded Video Support?

First off, great work! I like what you're doing with the project ๐Ÿ‘

Any plans to offer support for embedded video or will this just be a lightbox for images?

ReferenceError: window is not defined

There is a bug when i use this component on server side rendering

[piping] can't execute file: /Users/firdausious/Works/myweb/bin/server.js [piping] error given was: ReferenceError: window is not defined at /Users/firdausious/Works/myweb/node_modules/react-image-lightbox/dist/umd/react-image-lightbox.js:2:1265 at /Users/firdausious/Works/myweb/node_modules/react-image-lightbox/dist/umd/react-image-lightbox.js:2:1197 at e.exports (/Users/firdausious/Works/myweb/node_modules/react-image-lightbox/dist/umd/react-image-lightbox.js:2:1483) at Object.t.exports (/Users/firdausious/Works/myweb/node_modules/react-image-lightbox/dist/umd/react-image-lightbox.js:2:1959) at t (/Users/firdausious/Works/myweb/node_modules/react-image-lightbox/dist/umd/react-image-lightbox.js:1:534)

im using [email protected] with this boiletplate -> https://github.com/erikras/react-redux-universal-hot-example

thanks

Orange border on mobile view

When I view the demo using my Samsung S7, I see an orange border around the image. Is there a way disable this, perhaps by passing a style directive to React Modal?

See the attached screenshot from my phone. It's difficult to see in this image, but you can see orange lines on the left and right side of the photo.

react-image-lightbox-samsung7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.