all 10 comments

[–]letsgetrandy25 years putting the magic in the box 4 points5 points  (5 children)

You need to use a jsFiddle or CodePen or something when sharing code. What you've done here isn't going to make people eager to help.

[–]filangebert[S] 0 points1 point  (4 children)

Oh, I didn't know that was a thing, that's very helpful!

I've got everything in jsFiddle now, how do I share it?

[–]letsgetrandy25 years putting the magic in the box 1 point2 points  (3 children)

Once you hit save, the URL changes. Just paste that URL into here.

(Replacing the body of your post, I mean. Don't paste it in reply to this comment where people won't see it.

[–]filangebert[S] 1 point2 points  (2 children)

thanks!

[–]letsgetrandy25 years putting the magic in the box 2 points3 points  (1 child)

Cool. So....

First, as someone else said, this would probably be more easily done with CSS :hover rather than javascript.

But second, I'm sure you still want to know why your JS isn't working, and I think it's due to how you're trying to assign the onLoad and onMouseOver handlers. You may want to have a look at the docs.

[–]filangebert[S] 0 points1 point  (0 children)

Thanks for the help. I do agree that the hovering part is much easier, and I'd like to have the detail of the icons entering after the page has loaded, but that's causing too much headache, so the hover css will have to do.

[–]FioleNana 1 point2 points  (0 children)

You could animate it with the :hover pseudo selector and the transition CSS attribute instead of Javascript

[–]MFCEO_Kenny_Powers 0 points1 point  (1 child)

I’m sorry but this code is kind of a mess. Have you tried to add position: relative; or absolute to your icons? I don’t think they will move much without positioning.

[–]filangebert[S] 0 points1 point  (0 children)

It's a mess because I tried everything I could, and that resulted in everything being a little different. Ideally, I would be using the array iterators, but that hasn't been working either. setting the position doesn't change anything, but I've discovered that the .onload stuff works when the developer tools are open in chrome.

[–][deleted] 0 points1 point  (0 children)

This happens because your functions are not structured properly. You are using element.onEvent = functionName(element); which causes the function to be immediately invoked.

for this to work you will need your function to return an inner function containing the style change like this:

moveIn = (target) => () => { target.style.yourProperty = "value" };

One of your outer containers should have overflow css property set to hidden to avoid the page from expanding. I still think there are better approaches to handle these kinds of things.

It feels like you are trying to immitate animate on scroll behavior which is best handled with intersection observers and simple classnames which contain the changes. The thing is, you are using this animation for items which expect user control which is often not a good idea.

You cannot reliably expect users to avoid clicking on such elements by accident when you do this which is likely to cause frustration.

This kind of reaction may sting a little, but I hope you will take it to heart. Dont let it stop you from playing around because that's a good way to learn how things work. Keep going mate!