Jump to content
Search Community

darkgr33n

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by darkgr33n

  1. Thank you Rodrigo All the best
  2. Thanks for your help Rodrigo, I was a little lost as to how best to tackle this, but your reply certainly helped me look at it in a different way I needed the background transparency animation from my original pen though, and after a bit of messing about, it became obvious that I really needed to separate the change in height from the background transparency so I could involve some kind of scrub on the height change, otherwise it felt a bit jerky. I think i've achieved this now but i'm not sure how well its constructed, but it seems to work at least! https://codepen.io/darkgr33n/pen/XWyjXOq
  3. Hey, Using Greensock's codepen as the basis, I've got a menu bar that move's offscreen on scroll down and back into view on scroll up. Using another ScrollTrigger, it also changes the menu background so that its transparent on the first section and opaque in the subsequent sections. The final piece of the puzzle, which is what i'm struggling with, is trying to ensure that, when top of the first section is at the top of the viewport (ie, we're at the top!), the menu bar should be an additional, say, 100px from the top of the screen. I can add a y:100 into the second tl timeline, but it obviously interferes with the the first timeline trying to scroll the menu out of view. Should I add a third scrollTrigger to watch for that ? I've already got two scrolltriggers on one element and i think i'm going down a bit of a rabbit hole!
  4. Thanks Jack! I could see why it was conflicting, but didn't even consider using a different property which, of course, works beautifully. Thanks again
  5. Hi, I have three columns that use stagger to animate into position using ScrollTrigger.batch. This is set to Once only. I'd like to add a data-lag attribute to the columns, but if I add it in the code, it competes with the stagger animation resulting in a bit of a twitch. The question is, once the animation is completed, is there a way to add the data-lag attribute to the columns so that we can then use the goodness of SmoothScroller but not have it affect the animation ? Thanks!
  6. I couldn't get it to work so decided to go down the flickity route which worked instantly.
  7. i also noticed when using dev-tools on chrome and properties tab, that on the HTML version clientWidth, offsetWidth and scrollWidth are being shown as 7000px (which is the full width of the content), but on the WordPress version, while scrollWidth is shown as 7000px, both clientWidth and offsetWidth are shown as the width of the visible content. as far as I understand it: offsetWidth: The size of the visual box incuding all borders. clientWidth: The visual portion of the box content, not including borders or scroll bars , but includes padding . scrollWidth: The size of all of the box's content, including the parts that are currently hidden outside the scrolling area. which seems to suggest that the non-working WordPress version is showing correctly, whereas the working HTMl version is not as offsetWidth is showing as the full content including hidden elements. so I think the question is, by initiating the Draggable.create is there any way to force the offsetWidth ? I've tried to set it using JS, but I can only set it up to a maximum of the rendered size. So, for example, if it's rendered as 1116px, i can use JS to set it to anything up to 1116px, but not beyond. if I set bounds: {left: -innerWidth*3} instead of bounds:".carousel", it lets me drag OK, but of course I can't see the whole carousel as innerWidth is actually the width of the rendered UL, not the width of the full content. Not sure if i should be using getBoundingClientRect somewhere. so frustrating that it works on codepen and HTML!
  8. something else I've just noticed, but on the non-working WordPress version, the UL is given the style: "translate: none; rotate: none; scale: none; touch-action: pan-y; cursor: grab; user-select: none; " whereas on the working HTML version with the same JS/CSS/HTML setup, the UL is given the style: "touch-action: pan-y; cursor: grab; user-select: none;" o.O
  9. Thanks for your reply Rodrigo I have tried to use div's rather than ul/li but to no avail. I just tried rebuilding on another local setup - a site without WordPress, just good old HTML/PHP - and it works exactly as the codepen version does, so I think you're right: something within WordPress is affecting the calculated width of the UL - or div. I just need to track it down. Or at a push, work out a way within GSAP to get the width of the UL from the LIs and set it, but that feels like a hack. Back to the investigations. Thanks.
  10. Hey all, I've run into an issue when porting the code in the attached codepen into my local environment, and i just hoped that someone may recognise the symptoms and have an idea of a fix. The codepen (seems) to work fine, however when I use in my local environment (WordPress) I'm unable to drag the carousel. After some hours of investigation with dev tools, it turns out that, in my local environment, the UL is not calculating the full width of all the LIs and is reporting it at just 1485px (the width of the element in the browser); whereas codepen, is reporting the width of the UL correctly as 7000px. Hence, no drag. If I manually add a specific width to each LI, it does then calculate the width correctly, but there are a lot of pages with different image sizes so doing it manually isn't really possible. From what I've read, the calculated ul width is not based on the content of the li and you have to specify the width of the li elements, but if that is the case I don't understand how codepen is working it out. I just wondered if anyone knows if codepen is doing something behind the scenes that i'm not aware of, or if anyone has experienced anything similar in their coding travels and managed to overcome it somehow ? EDIT: one other point, if i remove the bounding locally, then I can drag the carousel OK, but of course everything disappears as there are no bounds! The UL is still reporting as the width of the browser rather than full width of the content, but I can drag. With bounding, I can't drag at all. EDIT: one final difference I noted, on codepen, I can see the LI elements get a style of "touch-action: pan-y;" added, however locally, no style is added at all. I'm not sure if this has any affect on anything o.O Thanks!
  11. 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!
  12. 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
  13. 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!
  14. 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!
  15. 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
  16. 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!
  17. 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!
  18. 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
  19. @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
  20. 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...
  21. @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!
  22. 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!
  23. 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!
  24. 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!
  25. 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!
×
×
  • Create New...