Comments (3)
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.
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:
- Cache the
childNodes.length
as a variable and use this value in thefor
loop. - Define the
child
always aschildNodes[0]
(rather thanchildNodes[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...
- Converting the childNodes object into an array (as documented here).
- Reversing the array.
- Then within the
for
loop, defining thechild
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shine.js.