Git Product home page Git Product logo

Comments (5)

MartinVerges avatar MartinVerges commented on June 23, 2024

I got the same bug, dunno at the moment why or how to fix it.

from hugo-easy-gallery.

halogenica avatar halogenica commented on June 23, 2024

I have the same exact problem. After searching a bit I found the following post:
https://stackoverflow.com/questions/31127896/photoswipe-pswp-class-not-clearing-after-closing-image

Indeed, in load-photoswipe.js the last line that creates and initializes PhotoSwipe is triggered twice because for some reason

$figure.on(/'click/', function(event) {

is being called twice, despite the actual click event only triggered once.

from hugo-easy-gallery.

halogenica avatar halogenica commented on June 23, 2024

Turns out the reason this happened in my code is because I was including the load-photoswipe.js code twice, which resulted in registering the on click callback twice. This was entirely my fault because I manually loaded the load-photoswipe.js script in my footer in addition to using the load-photoswipe shortcode. This could most easily be solved by either removing the script in my footer, or using the load-photoswipe-theme shortcode instead. I chose to fix it by always loading photoswipe in my theme's partials and not using either of those shortcodes.

I can confirm once I fixed my bug, things worked as expected. So you may want to double check your code for the on click function being registered twice, etc.

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

Perhaps I should put something in load-photoswipe.js to prevent the callback being registered twice.

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 23, 2024

I've added a check to load-photoswipe.js that will alert you if you've loaded the js file twice.

If you're going to load the js files in the footer, make sure you follow the instructions at https://github.com/liwenyip/hugo-easy-gallery#theme-integration

The main point is: if you are going to load the js files in the footer of your theme, you need to comment out the <script> tags in the load-photoswipe shortcode (or use the load-photoswipe-theme shortcode).

from hugo-easy-gallery.

Related Issues (20)

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.