Git Product home page Git Product logo

lightense-images's Introduction

lightense-images's People

Contributors

dependabot[bot] avatar greenkeeperio-bot avatar ramblinjan avatar renovate-bot avatar renovate[bot] avatar sparanoid 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

lightense-images's Issues

Zoom into alternate image

I played around with your lib, simple and small, i like it.

Now, when i use a thumbail e.g. <img src="/path/to/thumbnail_small.png" data-image="/path/to/full_res_image.png" > and use lightense, it will just zoom in the thumb (but with the size of the data-img).

Wheni use the "data-image" attribute 2 things happen:

  • on click, it will be zoomed in by the size of the "data-image", but still the src is display (blurry big thumb)
  • on ctrl click (new window), the full size image will be shown.

Is that considered a bug?

Issue with including lightense-images in Shopify Slate environment

When adding Lightense to a Shopify store development environment with Webpack, the library fails to expose the Lightense module in a way that can be accessed in the HTML body.

Replicate Issue
Run git clone [email protected]:Shopify/slate.git

Create a new directory and run yarn create slate-theme my-new-theme. Finish setting the .env variables via these instructions.

Install Lightense in the my-new-theme directory via yarn add lightense-images

Import Lightense in src/scripts/layout/theme.js by adding import 'lightense-images'; to the file.

You can see the JS loading in Chrome dev tools in theme.js but Lightense cannot be accessed.

Notes
I think this has something to do with how Webpack is processing lightense.js. I replaced the contents of this file with lightense.es6, but this did not fix the issue, though the change was reflected in theme.js

It's also worth noting that lightense.js functions properly when the file contents are included in the HTML inline.

Lightense on lazy loaded images

I'm trying to use Lightense on a page where some images are lazy loaded when a toggle is opened. I have a window.addEventListener('load' set up on the page generally, and am calling Lightense() on the images when they are loaded in.

The issue I'm seeing is that multiple instances of Lightense() break because the !d.querySelector('.lightense-backdrop') check causes config.container to be undefined:

Uncaught TypeError: Cannot read property 'removeEventListener' of undefined
    at unbindEvents (lightense.js:366)
    at removeViewer (lightense.js:299)
    at init (lightense.js:337)
    at HTMLImageElement.<anonymous> (lightense.js:193)

My solution is to set config.container to the already existing backdrop:

if (!d.querySelector('.lightense-backdrop')) {
  ...
} else {
  config.container = d.querySelector('.lightense-backdrop');
}

This fix works great, but I wanted to call it out and ask if there was a better solution to this general problem than what I'm doing. Thanks!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @babel/core ^7.10.5
  • @babel/preset-env ^7.10.4
  • babel-loader ^8.1.0
  • core-js ^3.15.2
  • eslint ^8.0.0
  • eslint-webpack-plugin ^3.0.0
  • husky ^8.0.0
  • release-it ^15.0.0
  • terser-webpack-plugin ^5.1.4
  • webpack ^5.41.1
  • webpack-cli ^4.7.2
travis
.travis.yml
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

Set background in config

You can’t set the background in the config object because it gets overwritten in line 282

config.background = config.target.getAttribute('data-background') || false;

If you comment this line and change line 233 in createViewer() from this

if (config.background) config.container.style.backgroundColor = config.background;

to this

if (config.target.getAttribute('data-background')) {
  config.container.style.backgroundColor = config.target.getAttribute('data-background');
} else if (config.background) {
  config.container.style.backgroundColor = config.background;
}

you can set the background like this

// hand them over to Lightense
Lightense('img[data-zoom]', {
    background: 'rgba(0,0,0,0.5)'
});

and still overwrite the background locally using a data-backgroundattribute, if you wish to.

Anyway, great script, thanks :-)

Unexpected Behavior When Using Flexbox

I'm getting unexpected behavior when using flexbox to align images.

lightense-flexbox

As you can see, the images are moving around before the overlay is applied. But, even worse, the last image doesn't center itself as it should.

The markup:

<div class="gallery">
  <img src="images/18.jpg">
  <img src="images/19.jpg">
  <img src="images/20.jpg">
</div>

The styles:

.gallery {
  display: flex;
  flex-wrap: wrap;
}

.gallery img {
  flex-grow: 1;
  margin: 0 .25rem .5rem;
  width: 30%;
}

Is there something I can change in the config to have it perform as expected?

Allow upscaling

With a small change, you could let the user configure whether or not he wants to allow upscaling images or not

in line 108 add a default (false to keep normal behaviour as is):

  // default options
  var defaults = {
    time: 300,
    padding: 40,
    offset: 40,
    keyboard: true,
    cubicBezier: 'cubic-bezier(.2, 0, .1, 1)',
    background: 'rgba(255, 255, 255, .98)',
    zIndex: 2147483647,
    allowUpscaling: false
  };

And in line 260 change the if statement to this:

if (naturalWidth < viewportWidthOffset && naturalHeight < viewportHeightOffset && !config.allowUpscaling) {
//...

Thanks a lot :-)

how to destroy Lightense ?

@sparanoid

thanks for your great plugin <3

i have smooth-page-transition with Barba.js

i have to reinit the plugin..

reinit the plugin after page change but

that backdrop clone three time after page changed

and image transfrom does'nt work good

pls tell me how to destory plugin and remove backdrops

Regards

Background not working in Firefox, Chrome only

Hey! Thank you for the nice library.

I am currently running into an issue. The background behavior is different between Firefox and Chrome: basically when clicking on an image with Firefox the background remains transparent, while it becomes white with Chrome.

Firefox

Chrome

I think they should be consistent.

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.