Jump to content
Search Community

GreenSock last won the day on April 21

GreenSock had the most liked content!

GreenSock

Administrators
  • Posts

    23,155
  • Joined

  • Last visited

  • Days Won

    817

Everything posted by GreenSock

  1. Hm, it's tough to diagnose without seeing a codepen demo, but it looks to me like one of the biggest problems is that you're setting currentSlide to 0 INSIDE your click function. So it'll never get past the second one I think you mean to declare that variable outside your click function, right? I'd also be careful about using clip-path because it's not very well supported across browsers yet. It probably doesn't perform terribly well either - maybe just use a container <div> with overflow:hidden? Just a thought. If you still need help, please provide a reduced case in codepen since that'll allow us to identify issues much more quickly. Happy tweening!
  2. So are you saying that in some cases, you want slide.two to turn blue part-way through, and other times you want it to turn blue at the very end of the timeline? I don't think this is an issue of having an onComplete fire at a different time (it wouldn't make sense for it to fire at different times, and certainly a nested onComplete shouldn't fire after its parent's onComplete). Wouldn't it be best to just add some logic to your parent timeline's onComplete so that it checks whatever conditions you need to check, and acts accordingly? Perhaps I'm misunderstanding your goal, though.
  3. Oh, and I forgot to mention - you asked about documenting the plugin stuff. There has been a TEMPLATE_Plugin.js file in the downloads for years. Just crack that open and you'll find exactly what [I think] you're asking for.
  4. Good catch. All you probably needed to do was to change the _filterProp from "webkitFilter" to "WebkitFilter" (capital). But hey, if your other version works, great!
  5. Hm, I'm not quite sure what might be the problem. Your "import Draggable from 'gsap/Draggable'" seems correct. I'm not very familiar with Angular. @OSUblake is usually pretty good with this stuff - perhaps he'll have some suggestions. I noticed that you've got a "TimelineLite" declaration there but I didn't see an import statement. I wonder if the packager is choking on something else along the way, before it gets to Draggable. Totally guessing.
  6. Ah, okay - then I'd make it more automatic so that if it ends at 0, it just removes it automatically: (function() { var _div = document.createElement("div"), _filterProp = /Edge\/\d./i.test(navigator.userAgent) ? false : (_div.style.webkitFilter !== undefined) ? "webkitFilter" : (_div.style.filter !== undefined) ? "filter" : false, _filterCSSProp = _filterProp ? _filterProp.replace(/([A-Z])/g, "-$1").toLowerCase() : ""; _gsScope._gsDefine.plugin({ propName: "n2blur", API: 2, version: "1.1.0", overwriteProps: ["n2blur"], init: function(target, value, tween, index) { if (!_filterProp) { //browser doesn't support filters return true; } if (typeof(value) === "function") { //accommodate function-based values value = value(index, target); } var start = window.getComputedStyle(target)[_filterProp], end = "blur(" + value + "px)"; if (start === "none") { start = "blur(0px)"; } this._style = target.style; this._remove = !value; this._addTween(target.style, _filterProp, start, end, "n2blur"); return true; }, set: function(ratio) { this._super.setRatio.call(this, ratio); //ratio is typically 1 when tween is done. if (ratio === 1 && this._remove) { this._style.removeProperty(_filterCSSProp); } } }); })(); Here's a fork:
  7. Hm, I don't quite understand - are you saying you want to be able to set the final value to "none"? Can you show me a use case, maybe in a codepen?
  8. TweenMax.staggerTo() returns an ARRAY of tweens, but it looks like you're treating it as if it's a timeline or a tween. In other words, you're calling kill() on an array. You could either loop through that array and kill() each tween, or you could just use a TimelineLite staggerTo() instead so that all those tweens are embedded in a timeline which can be killed, like: var sparkleblink = new TimelineLite(); sparkleblink.staggerTo(".confetti", .5, {ease:Linear.easeNone, opacity:.2, repeat:-1}, .01); ... //then later... sparkleblink.kill(); Does that help?
  9. Hm, I'm having a hard time wrapping my head around exactly what you're after. When you disable() a Draggable instance, it should completely disable it (not just dragging). Therefore, it's expected behavior that its onClick wouldn't fire (that'd be weird if a disabled object kept firing off events and stuff). Maybe it'd help if you showed in one of your codepens a challenge that you want to achieve. For example, maybe you want to click on the draggable element and make it turn something else red but only when it's clicked and not dragged? Sorry if I'm missing something obvious here. I read your post about 4 times and looked at the codepens and from what I can tell Draggable is working exactly as expected. If your goal is to keep the Draggable element from being dragged in some cases (without disabling it), maybe set its dragResistance to 1? Or do some fancy logic in an onDrag?
  10. GreenSock

    GSDevTools

    Your animation workflow is about to get a major boost. GSDevTools gives you a visual UI for interacting with and debugging GSAP animations, complete with advanced playback controls, keyboard shortcuts, global synchronization and more. Jump to specific scenes, set in/out points, play in slow motion to reveal intricate details, and even switch to a "minimal" mode on small screens. GSDevTools makes building and reviewing GSAP animations simply delightful. Get Started Load the JavaScript file //be sure to use a path that works in your dev environment <script src="./js/GSDevTools.min.js"></script> Instantiate GSDevTools GSDevTools.create(); That's it! The demo below shows GSDevTools running with its default settings. It automatically gives you control over every animation on the global timeline. Select an animation by id Any GSAP animation (tween or timeline) can be assigned an id (a string) which causes it to show up in the animation menu. That makes it easy to jump to any scene. Notice how the timeline and each tween below have an id assigned: //give the timeline and child tweens their own id. var tl = gsap.timeline({id: "timeline"}) tl.to(".orange", {duration: 1, x: 700, id: "orange"}) .to(".green", {duration: 2, x: 700, ease: "bounce", id: "green"}); //give this tween an id gsap.to(".grey", {duration: 1, x: 700, rotation: 360, delay: 3, id: "grey"}) //instantiate GSDevTools with default settings GSDevTools.create(); Now each id shows up in the animations menu (lower left). Persistence between refreshes For added convenience, when you manually set the in/out points, animation, timeScale, or looping state in the UI, they persist between refreshes! This means you can drag the in/out points to isolate a particular section and then tweak the code, hit refresh, and see the changes immediately within that cropped area. Any values set in the GSDevTools.create({...}) method will override manual selections. Set persist: false to disable persistence. If you encounter persistence contamination (e.g. setting timeScale in one affects another), simply assign a unique id to the GSDevTools instance (the recorded values are segregated by id, session, and domain). Configuration options GSDevTools can be configured extensively. Optionally define any of these properties in the config object: animation [string | animation] - If you define an animation, like animation: myTimeline, animation: myTween or animation: "id", that animation will be initially selected. By default, the global timeline is selected. container [string | element] - Specify the container element for GSDevTools, like: "#devTools" or document.getElementById ("devTools"). css [object | string] - The CSS you want on the outer div, like {width:"50%", bottom:"30px"} or a string of css like "width: 50%; bottom: 30px". It is safe to use GSAP-specific shortcuts like x, yPercent, etc. in the object syntax because it just gets passed to a gsap.set() internally. globalSync [boolean] - By default, animations are kept in context and synchronized with the root timeline (scrubbing one scrubs them all), but you can set globalSync: false to unhook it from the global timeline. Note: only one GSDevTools instance can be globally synchronized on a page (otherwise scrubbing them both to different times would break the time-space continuum). hideGlobalTimeline [boolean] - If true, the Global Timeline will be removed from the animation menu. id [string] - A unique string to identify the GSDevTools instance. The persistent values between refreshes are mapped to this id, so if you ever run into a case where there's cross-contamination of the persistent values (like if you embed multiple codepens on one page and don't want timeScale changes in one to affect the others on refresh), just make sure you give each one a unique id. inTime [number | string] - Position of the in marker (time, in seconds, or label or animation id). You can even use relative values like "myAnimation-=2" to start 2 seconds before the animation with the id of "myAnimation". If you use just a negative relative value like "-=5" , it will be measured from the end of the timeline, making it easy to just watch the final 5 seconds. keyboard [boolean] - If true (the default), keyboard shortcuts will work. Note: only one GSDevTools instance can listen for keyboard shortcuts. paused [boolean] - Initial paused state. loop [boolean] - Initial loop state. minimal [boolean] - If true, the UI will only show minimal controls (scrubber, play/pause, and timeScale). Note: when the screen is less than 600px it automatically switches to minimal mode anyway. outTime [time | label] - Position of the out marker (time, in seconds, or label, or animation id). You can even use relative values like "myAnimation+=2" to end 2 seconds after the animation with the id of "myAnimation" ends. If you use just a positive relative value like "+=5", it will be measured from wherever the inTime is. persist [boolean] - By default, GSDevTools remembers the in/out points, selected animation, timeScale, and looping state between refreshes in the same domain session, but you can disable that behavior by setting persist: false. timeScale [number] - Initial timeScale. visibility [string] - "auto" causes the controls to automatically hide when you roll off of them for about 1 second, and return when you move your mouse over the area again. Default is "visible", or you can set it to "hidden" to hide the controls initially (useful if you don't want the controls to obscure any part of the screen - you can still use the keyboard shortcuts to control playback or tap the "H" key to toggle visibility). Keyboard Controls SPACEBAR: Play/pause UP/DOWN ARROWS: Increase/decrease timeScale LEFT ARROW: Rewind RIGHT ARROW: Jump to end L: Toggle loop I: Set the in point to current position of playhead O: Set the out point to current position of playhead H: Hide/show toggle Tips and tricks Clicking the GreenSock logo (bottom right) gets you right to the GreenSock docs! Double-click on the in/out marker(s) to reset them both immediately. If the playback UI is obscuring part of your animation, just tap the "H" key to hide it (and again to bring it back) - you can still use all the keyboard shortcuts even when it's invisible. Advanced demos We purposefully chose very basic animations for the demos above, but here are a few that illustrate how easy GSDevTools makes it to control and debug even super-complex animation sequences. How do I get it? GSDevTools is available to Club GreenSock members ("Shockingly Green" and above). Just download GSAP with the bonus files zip from your Dashboard. Try GSDevTools for free on CodePen. To learn how to include GSDevTools into your project, see the GSAP install docs. FAQ Why is my global timeline 1000 seconds long? That means you've probably got an infinitely repeating animation somewhere. GSDevTools caps its duration at 1000 seconds. Scrubbing to Infinity is awkward. Does loading GSDevTools impact runtime performance? Since it must monitor and record the root timeline, yes, there is a slight performance hit but probably not noticeable. Keep in mind that usually you'll only load GSDevTools while you're developing/reviewing your animations and then remove it when you're ready to launch, so ultimately it shouldn't be much of a factor anyway. Why isn't GSDevTools in the CDN or GitHub repo? Because it's a membership benefit of Club GreenSock. It's a way for us to give back to those who support our ongoing development efforts. That's why we've been able to continue innovating for over a decade. See https://greensock.com/why-license for details about our philosophy. Does GSDevTools work with other animation libraries? Nope, it depends on some unique capabilities baked into the GSAP architecture. What will I do with all the time this tool saves me? Take up a new hobby, ponder deep philosophical questions, make cookies - it's up to you.
  11. Yep, @PointC is right - I can't imagine how this could be a GSAP issue since all GSAP does is set properties quickly over time. Definitely sounds like some kind of hardware/driver issue. I wish I had a simple solution for ya. Happy tweening!
  12. Can you be a little more specific about the "odd behavior" you're encountering? Please keep in mind that by default, when any tween begins for the first time, it'll look for other conflicting tweens (ones that are trying to control the SAME property of the SAME object) and kill the overlapping/conflicting parts. That's typically a GOOD thing, as it protects you. Otherwise, you might have one tween trying to animate object.x to one value, and another trying to animate it to a completely different value. The way you're doing things looks like you might be creating conflicts. Are you running your timelines concurrently? Again, be careful not to create your animations in such a way that they'll conflict with each other. If you want to allow the conflicts, you could set overwrite:false on each tween (or TweenLite.defaultOverwrite = false if you want it to affect everything). In most cases I wouldn't really recommend that, though. Also, I noticed you're using from() tweens. Remember that those animate things to whatever the current value is at the start of the tween, from the value you define. So be very careful about the logic there. For example, if you've got one tween that finishes running, and then another one starts, it'll lock in that current value as the "to". And from() tweens render immediately by default, thus the first time you call contentsAnimation(), it'll actually set opacity:0 and the x/y values as you defined them there, so the NEXT time you call that function, the values will already be rendered in that way. For example, if obj.x is at 0, and then I call .from(...{x:100}) then obj.x will be 100 IMMEDIATELY and it'll start animating toward 0 on the next render. So if I call from(...{x:100}) again at that point, it'll again make obj.x 100 and use the current value as the "to", but it's already 100 because of your previous from(), thus that second tween will animate obj.x from 100 to 100 (no change). I bet that might be your problem. Perhaps it'd be wiser to use a fromTo() and staggerFromTo() so that you can control both the from and to values. If you're still running into trouble, a codepen would be super helpful.
  13. Yep, hopefully it's relatively simple to wrap stuff in one callback just like @Shaun Gorneau recommended. For the record, it was very intentional that we use callbacks in GSAP rather than event listeners (other than for the ticker itself) - they're much more performant.
  14. GreenSock

    MorphSVG on click

    Ha - @OSUblake and @PointC were those references to that old "War Games" movie? I vaguely (and fondly) remember that.
  15. Multiple cursors Are you talking about having the cursor change at various events? Currently, you can already define any "cursor" that you want, like {cursor:"grab"} Off-screen mouse release This seems to be an issue only when the page you're dragging on is loaded inside an iframe (like on codepen), right? The really annoying thing is that you must pick your poison - either put up with the current behavior or set allowEventDefault:true and then if you press/drag, it can highlight things in some cases. The crux of the issue has to do with the fact that the mousedown/touchdown event must NOT call preventDefault() if you want the release to bubble up, but by default we DO call preventDefault() for a bunch of other reasons (like to prevent drag-scrolling on touch devices, and to prevent the selection stuff from happening, etc.). See what I mean? Or do you see any good solutions that don't involve this tradeoff?
  16. I think the problem had to do with the way you were adding a class which was changing to position:absolute. Here's a more efficient way to accomplish what [I think] you're after, using the liveSnap feature: Does that help?
  17. Yep, and there are some blog posts about the highlights of several of the bigger releases. https://greensock.com/blog/
  18. Nope, in this case there's no advantage to using TweenLite.set() over JS .style or jQuery.css(). The only reasons TweenLite.set() can be advantageous are: It uses the same API as GSAP, thus you can set properties like x, y, rotation, drawSVG, and other shortcuts/special properties. Again, not necessary here because you're doing something standard ("height") TweenLite.set() is actually a zero-duration tween, thus it records starting values and ending values. If you put it into a timeline, when the playhead moves past it forward, it'll set the values accordingly, and if the playhead moves backward (in front of where that set() is located), it'll revert the values for you. This can be very useful in certain cases. Technically, since it is a zero-duration tween, you could set a delay on it and then restart(true) it to have it act kinda like a timer that'd set the value after that delay elapses. And of course that'd be perfectly synchronized with the whole GSAP engine. Since none of those matter in your case, you're fine using plain JS or jQuery.css(). Enjoy!
  19. Hm, it certainly sounds like some kind of build process problem, especially because you said it works fine locally. Very difficult to troubleshoot by just looking at 2 chunks of the code. Can you reproduce the problem in a codepen or something? That'd give you a much better chance of getting a solid answer. I did notice that some of your quotes were non-standard, like: //BAD: `all` //GOOD: 'all' Also, I'd recommend that whenever you're animating x or y to a percentage-based value, use xPercent and yPercent because it eliminates some potential confusion. You can actually have BOTH an x/y AND an xPercent/yPercent which can be extremely useful. But as a convenience, GSAP automatically checks and if you define x/y with a "%", it'll funnel that over to xPercent/yPercent. So it wasn't breaking anything - I just wanted to point out a "best practice"
  20. You can totally use ThrowPropsPlugin for that - I think there were just some logic issues in your updateProgress() function. If you prevent the onThrowUpdate from calling that, you'll see what I mean. I haven't had time to analyze it all and figure out exactly how to re-code things, but it sounds like you got what you wanted already, right? Let me know if you need some more help with it. Another interesting approach you could consider is to just create a linear timeline that animates the whole thing across the screen, pause it, and hook up a Draggable to an invisible div that sits on top and simply controls the progress() or time() of that timeline. Just a thought.
  21. Yay! Thanks for reporting back. Glad you figured it out. Happy tweening!
  22. That's actually a very tricky scenario just because of the way you coded it. First, the solution: //OLD: tl = new TimelineLite(); tl.set($('#menu'), { css: { display: 'block', height: 'auto' } }) .from($('#menu'), 0.6, { height: 0, ease: Power3.easeInOut }, 0); //NEW: TweenLite.set("#menu", {display:"block", height:"auto"}); tl = TweenLite.from('#menu', 0.6, { height: 0, ease: Power3.easeInOut }, 0); Notice that I'm not embedding the initial set() call in the timeline itself. The explanation: You had a set() call embedded at the VERY start of the timeline which sets height to "auto", so imagine what's supposed to happen when the playhead goes forward and then comes back (after reversing the timeline). When the playhead hits the beginning...if it's EXACTLY on top of that time (0), it'll actually tell it to render as height:"auto". After all, those instructions are there on the timeline. The reason you only intermittently saw that was because the playhead would literally have to land exactly on that spot, but it's more typical for it to be just after or before it ("ticks" are usually 16.6ms apart, but depend on many factors). If the playhead lands BEFORE that spot (like literally a negative time...which isn't allowable, but GSAP still senses that condition in order to properly set state), in this case it'll tell that set() to revert to its start state, which means height probably wasn't "auto" (it's whatever it was at the time that tween rendered the first time). I know, it probably sounds a little complex. It kinda is. So a much cleaner and more performant way to handle this is to just do a regular TweenLite (or TweenMax) .set() call that just fires off that one time initially, and doesn't get embedded in the timeline. Hopefully that clears things up.
  23. For the record, @GNB, I totally see why it'd be a bit frustrating if you were told you'd have an answer in a specific timeframe and didn't get it. Understandable. @OSUblake is typically awesome with getting people above-and-beyond answers, but hopefully it's clear now that there was good reason for him not being able to get back to you within that time frame he mentioned (natural disaster). Anyway, I just wanted to make sure I acknowledged the fact that he did specify a time frame and it didn't happen which was cause for your original frustration. Happy tweening.
  24. Yes, @OSUblake, the least you could do is send some smoke signals while your utilities are being repaired after a natural disaster. Please also write a binary parsing mechanism hooked up to a satellite so this never happens again. Short puff = 0, Long puff = 1. Sure, it may take a day to string together enough signals to form a cohesive sentence, much less a full codepen demo, but hey, we're all busy. "...an extra serving of french fries" - Mmm, sounds good.
  25. Very nice. It did crash my iPad, though (like, immediately). On the desktop it was good after the initial few seconds.
×
×
  • Create New...