Coder Social home page Coder Social logo

Comments (5)

henrygd avatar henrygd commented on July 17, 2024

Hi Mike, would you mind posting the html that goes along with this? Just the container with the mybook id should be fine.

from bigpicture.

macsupport avatar macsupport commented on July 17, 2024

Here is the basic html. I'm wondering if having some div's with id's within the main id might be the issue? I am also using lazysizes but it would not work when that was disabled either.

 <div id="mybook" data-intro="Notebook" data-position="right">	

<div class="keywords filters" >
 <span style="display:none;" class="keys">all </span>
</div>
</div>
<div id="item5" title="Drip" class="selectFav" >
<div class="sbp">
<button class="btn btn-link social fa fa-share-alt fa-2x"></button>
</div>
<h1>Drip</h1>
<img  class="thumbs lazyload" src="thumbs/Drop.jpg" alt="Drip" title="Drip" data-keyword="Green" width="340px" height="400px"/>
<div id="scroll5" class="nano"><div class="nano-content">
<p>A Drop of Water</p>
</div></div>

</div>


from bigpicture.

macsupport avatar macsupport commented on July 17, 2024

Interesting that this works:

(function() {

    function setClickHandler(id, fn) {
      document.getElementById(id).onclick = fn;
    }

    setClickHandler('mybook', function(e) {
      var className = e.target.className;
      ~className.indexOf('thumbs') &&
        BigPicture({
        el: e.target,
        imgSrc: e.target.src.replace('thumbs', 'slides')
      });
    }); 
  })();

from bigpicture.

henrygd avatar henrygd commented on July 17, 2024

Yep, the problem is that e.target.className === 'thumb' will not be true if the element also has other classes. Since the element also has the lazyload class, you end up testing if 'thumbs' is exactly equal to 'thumbs lazyload', which returns false, and BigPicture never gets called. ~className.indexOf('thumbs') will work because it does the same as className.indexOf('thumbs') > -1 -- tests if className contains the string 'thumbs' rather than test if it's equal. If you're using jQuery, another alternative would be $(e.target).hasClass('thumbs').

from bigpicture.

macsupport avatar macsupport commented on July 17, 2024

Ahhh, thanks! I totally missed the === part as the cause.

from bigpicture.

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.