Share Posted February 12, 2021 Hello attempting and failing to animate an svg gradient. Im using svg.js and setting the gradient object using a gradientStops object var gradientStops = { _start: 0, get start() { return this._start; }, set start(value) { this._start = value; }, _end: 1, get end() { return this._end; }, set end(value) { this._end = value; } }; var draw = new SVG().addTo("#svg").attr({ viewBox: "0 0 100 100", class: "w-2/3 bg-red-50" }); var gradient = draw.gradient("linear", function (add) { add.stop(gradientStops.start, "hsla(352, 99%, 90%, 1.00)"); add.stop(gradientStops.end, "hsla(352, 99%, 50%, 1.00)"); }); var globe = draw.circle(50).fill(gradient).cx(50).cy(50); gsap.to(gradientStops, { start: 1, end: 0, duration: 2, yoyo: true, repeat: -1 }); Thanks in advance See the Pen gOLLezz?editors=0010 by limitedunlimited (@limitedunlimited) on CodePen Link to comment Share on other sites More sharing options...
Share Posted February 12, 2021 Maybe with the simplest of ways? See the Pen e5bc4356cdea93434978159c07db1dd5 by dadacoded (@dadacoded) on CodePen 3 Link to comment Share on other sites More sharing options...
Author Share Posted February 12, 2021 Thank you fro this solution. I was hopping to stick with the svg.js. code where I'm attempting to animate the gradient stop position Link to comment Share on other sites More sharing options...
Share Posted February 12, 2021 5 minutes ago, JamesGrubb said: I was hopping to stick with the svg.js. code where I'm attempting to animate the gradient stop position You do realize this is a GSAP forum, right? What's bad about doing it the way that tailbreezy recommended? Link to comment Share on other sites More sharing options...
Author Share Posted February 12, 2021 Nothing what so ever. I imagine it must sound ungrateful when you give a response and it it is bounced back with what sounds like someone being picky. Im on a learning path of my own and thats why I was hopping to follow with this current code stack. Please do know that I am immensely appreciative of the support you give to the community. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now