Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

darkgr33n

ShockinglyGreen
  • Posts

    68
  • Joined

  • Last visited

About darkgr33n

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

darkgr33n's Achievements

  1. Hey Jack, Thanks for highlighting that point, I had totally missed that there was a static method I could utilise as well. I just gave it a go and it seems to work and has saved about 20 lines of code! I might be able to optimise it a little more, but for now I'm pretty happy. https://codepen.io/darkgr33n/pen/MWbVooR Next step is to make draggable only available on mobile but I should be able to use matchMedia for that. Cheers!
  2. Just had a quick look at getting this working, but I think what I struggled with when I first saw hitTest was that the target element - the actual element being dragged - is actually a wrapper, and I can't see a way I can use hitTest as the child elements I need to effect are within the draggable target. https://codepen.io/darkgr33n/pen/rNWdxjW
  3. Thanks Zach that's helpful. For the mid-point, I'm assuming I'd have a div that's not visible, absolutely positioned in the center to act as the testObject. I assume I'm ok having three hitTests on one draggable instance, like I've done in my demo: one for onDrag - which adds a class; one for onDragEnd - which animates the element; and one for onDragStart - which clears everything ready for the next one.) ? Cheers!
  4. Thanks Zach, The end goal is for it to work as it does now, just a little more efficiently When dragging it needs to just add a class to each of the child elements as it passes the center point. If you end the drag while an element is on the center point, it needs to run an animation that widens the element. It will do other things, but I wanted to reduce the code to just the functionality i was struggling with. There will be text popping up and a video playing, but i just needed to nail being able to initiate some kind of action when dragging the child elements over the center of the screen. I'll give the hitTest a go and report back. Cheers!
  5. Thanks Zach. To be honest, I did see it but wasn't sure if it was entirely relevant in my case. Because I was targetting the child elements of the element I'm dragging I didn't think it would work and so I reverted to getting it working any way I could! So in theory then, I could use hitTest to effect the same behaviour. Interesting. I'll try and explore it and see if I can get it working in my case later today. Thanks
  6. Hey all, I'm trying to get something working on mobile that I have working on desktop. On desktop i'm using mouseenter and mouseleave to add a class and expand the width of a child 'slate' element. For mobile, the reduced screen size means I need slightly different functionality so I want to introduce the ability to drag the wrapper element and fire the same animation on the child element if the child is within 30px of the horizontal center of the window. Surprisingly I seem to have it working, however I'm not really sure if my method is over-the-top and I wonder if i've missed a much cleaner way of achieving what i'm after. I have 9 'slate' elements. On mobile, you'll probably only see 3 slates. The idea is you drag the elements across the screen horizontally, and as you drag if a child element hits the center of the screen, we add a class to highlight the element. If you end the drag with the element highlighted, it will then run an animation to expand the width of that element. In my draggable instance, i'm using three functions and this is where i'm unsure. each function has to loop through all the child elements to see if any of them is in the center - or highlighted - , so onDrag: function has to loop through everything as it's being dragged to see if the position of any of the elements is in the center of the window. if it is, it add a class to highlight the element. onDragEnd: function has to loop through all the child elements to see if we have a highlighted class added. If it does, it runs an animation . onDragStart: function has to loop through all the child elements to see if we have a highlighted class added. If it does, it reverses the animation. So the question is, does it seem reasonable to be looping over everything all the time or is there a simple method that I've totally overlooked that would achieve similar functionality. Cheers!
  7. Ah, gotcha! A quick experiment, but yeah I think that could be the way to go. With five items I was still getting a little movement on either end, but with 10, if it is there, its barely noticeable. If I can get the images and videos to work without affecting anything, we're golden. 💥 https://codepen.io/darkgr33n/pen/zYKbdLx Thanks for the clarification Cheers!
  8. Thanks @PointC, the demo and video almost did the trick really clear video actually; once this project is over I should sign up and go through some of the tutorials. Anyway, I've got it working without any errors and without messing around with mouse events. I went down the wrong road there I think! https://codepen.io/darkgr33n/pen/xxEBqNE The only thing, as mentioned above, is that when one expander is open and you move to an adjacent expander, the width of the overall block increases because the closing of the previous and opening of the current panels aren't synced. @ZachSaucier when you said that keeping the same total width was quite doable, were you referring to the demo that carl did and that this new pen is based on ? And, if so, was it the syncing of the reverse and play that are called when you move from an adjacent block what you were thinking ? Thanks both
  9. @ZachSaucier ooh, intriguing!! that does seem to be the crux of the issue. my very first attempt before I asked the question here was much simpler and was working except that the visual width of the container appeared to change as you hovered over multiple panels. https://codepen.io/darkgr33n/pen/gOwQQrm
  10. Just had a quick look and it could certainly be an option for me: However, with the site I linked to above, when you hover over multiple adjacent panels, the overall width of the block (of 10 panels) doesn't change. So if you kind-of hover and sweep across a few panels in the amended example ((https://codepen.io/darkgr33n/pen/wvzNQqg), it can look a little jerky as the parent container expands and contracts. I do actually like the organic feel it gives, but my client has been quite specific - perhaps I need to challenge her to think again...
  11. @PointC Hey Craig - thanks for that! No, I hadn't seen it, but will definitely have a look in the morning. I'm lost in mouse events at the moment and it seems close, but I really like the way the example you showed feels and could well be the way to go Many thanks!
  12. Hey Zach, Thanks for taking the time to look I was beginning to suspect it was more logical than a specific GSAP issue, but I wasn't sure if I was missing something GSAP-related that would solve it. I've been racking my brains all day. I've started looking at event.relatedTarget to work out where the mouse is coming from or going to and then trying to animate accordingly. I had started to avoid reverse as well during my experiments, but perhaps you're right - maybe i should just rebuild/simplify the layout a little. I actually based the layout on this site - which also uses GSAP to do the business - but while I can see what's happening with devtools I'm not entirely sure how it's achieved. I was half-aware of Flip but haven't looked at the docs yet. I'll have a look Cheers!
  13. Hi, I think I'm really close to getting this to work, and while I can almost understand what's going wrong, I'm not quite sure how to address it or if its down to a wrong approach or not. The goal is to be able to hover over each panel and to change width. I'm actually changing the width of an inner div as a pseudo-clip-path so that the content (image/video) doesn't scale. https://codepen.io/darkgr33n/pen/VwKgZOO SO, in the example, if hover over any panel without touching any of the other panels, all works well. However, if you hover over an adjacent panel, initially it seems to work but when you hover off things break down. Looking at the compiled code in dev tools, the translate to the adjacent panel seems to look ok, but when you hover off it's not completely reversing correctly. I'm using prevAll and nextAll to work out which way to move the non-hovered panels. I suspect something along the lines of the .to values get screwed up somewhere along the line. I tried a .fromTo version, which might be slightly closer as it doesn't leave gaps, but because it's a .fromTo, hovering to an adjacent panel manifests a big jump which looks bad! (https://codepen.io/darkgr33n/pen/poEGyBw); I've tried to work out a way to try and monitor the state of the panels, but as i said, I can't quite understand the whole picture to determine exactly what's wrong. It feels like I need to know if a panel is "open" before reversing or not not reversing the other panels that had moved as, in the .fromTo version, that would seem to be the only issue. Any ideas? Am I even close?! I think I've come quite far, but not yet far enough 😕 Cheers!
  14. Hey Zach, Thank you mate, again! Very much appreciated, and spot-on!! It does make sense to use a single timeline! Ignorance is the reason I had setup one for each. No reason for the pause - other than, as mentioned, I started by trying to get the hovered panel to be twice the width and then reversing on mouseleave and had copy/pasted when i was building the text timelines. Again, a lack of knowledge of the impact is at fault there Noted! As part of me trying to work it out, attaching the variables to the objects seemed to work better than what i had done previously, and i had looked at your replies to various posts and had pulled that through, without really understanding the impact. I've learnt loads since I started the first project, but my knowledge is rather patchy in places! I'm going to work on getting the hovered panel to expand to twice the width next so may be back with another question, but for now, thank you Cheers!
  15. Hi All, Second project! I'm creating a contents page that has 10 panels. When hovered, each panel needs to populate a single div below with specific text - which is currently inside attributes of the specific <section> (".Slate-item"). (Eventually, each panel will also increase in width and play a video on the hover, but one thing at a time!). I've 'almost' got it working, but there's an small issue, which I think may be caused by the way i'm structuring the code. The current iteration is the closest I've got to getting it working. The idea is you hover over the panel and three pieces of text are show, The first text -- "title" -- is effected by SplitText, and the other two -- "producer" abd "country" -- just fade in. The issue I'm seeing is, if I hover over each panel one at a time, it seems to work fine. If I quickly drag my mouse over a couple of the panels a few times and then stop over a panel, the "title" text comes in fine, but there's a delay before the other two pieces come in and sometimes they don't fade in, they just appear. I had seen a delay before in a previous iteration, and the more times I hovered over a panel, the longer the delay became, but I don't think that seems to be happening now. It seems reasonably stable in its wrongness! I'm not sure if it's because I'm creating the SplitText on the mouse event or if it's the structure of the code. I had hoped to get to the end of this without leaning on you guys, but i'm just not seeing where i'm going wrong at the moment so if anyone can see what's happening, I'd appreciate it. Cheers!
×