Git Product home page Git Product logo

Comments (3)

benjaminbojko avatar benjaminbojko commented on July 30, 2024

Shine does modify the contents of the container to add shadow elements, but there shouldn't be a limit on the maximum number of items. It's hard to say what exactly is happening without looking at your code. Do you have an example that you could share?

from shine.js.

bravokiloecho avatar bravokiloecho commented on July 30, 2024

Hi Benjamin,

Thanks so much for getting back to me. I tried several things to try and find the route of this problem but to no avail. I even rebuilt most of the site in codepen where eveything actually worked as intended!

However I did some digging around the in the plugin and I found the source of the issue...

The problem stemmed from the splitChildren prototype. What was happening was that during the for loop over the childNodes NodeList object, the object itself was being emptied of the child that was being appended to the wrapperElement after it was passed through the appendChild method. This was also effecting the number of iterations of the foor loop; there were 12 children on my site, and only 6 loops were being called. (I have no idea why this was happening on my site, but not on the codepen version. I tried it in Chrome, Safari, and Firefox and all had the same issue.)

A fix that worked for me had two steps:

  1. Cache the childNodes.length as a variable and use this value in the for loop.
  2. Define the child always as childNodes[0] (rather than childNodes[i].
    I've applied these changes in this commit: SHA: 73f7c99

It's quite possible that if the original method works for people, then my new method won't so I'm not sure it's worth making a pull request.

I had thought of another solution that would be more robust but slightly less efficient. This would involve...

  1. Converting the childNodes object into an array (as documented here).
  2. Reversing the array.
  3. Then within the for loop, defining the child as:
var currentChildIndex = childNodesLength - i - 1;
var child = childNodes[ currentChildIndex ];

I hope this all makes sense and I'd be curious to know your thoughts.

from shine.js.

benjaminbojko avatar benjaminbojko commented on July 30, 2024

That's actually a great find and I'm strongly considering merging this into the main repo. From the looks of it, your additions should make the script behave as intended. I assume that this hasn't been a larger issue since the library is mostly used decoratively in fairly straight forward settings. Let me take a closer look and I'll probably merge then.

from shine.js.

Related Issues (8)

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.