Podcasting During the Pandemic: Castos Sees 300% Growth in New Podcasters

“My Podcast Set I” by brainblogger is licensed with CC BY 2.0.

Podcasting, like many other industries during the pandemic, is seeing a strong shift over the past six months, which has resulted in more shows and fewer listeners. While some avid podcast fans have taken solace in listening to their favorite shows to stay connected, many listeners who previously had podcasts built into their routines have turned to other forms of media consumption in the absence of a daily commute.

In April, global podcast listening was up 42% (and 53% in Europe) as lockdowns began in the U.S. and other parts of the world. Although listening in the U.S. went down 20%, certain verticals remained strong, such as true crime, music interviews, science, medicine, religion and spirituality, and self-improvement.

Prior to the pandemic, the podcasting industry was experiencing a boom, with experts projecting marketers to spend over $1 billion in advertising by 2021. The pandemic has thrown a wrench into the industry’s growth. In the months of continued isolation and social distancing, E-marketer recorded its first contraction in time spent listening since it began tracking in 2015 but estimates a rebound in the coming years.

Source: eMarketer, June 2020 (https://www.emarketer.com/content/time-spent-with-podcasts-will-dip-amid-pandemic-should-rebound-by-2022?ecid=NL1001)

The pandemic may have temporarily stunted the growth of listeners, but the team at Castos is witnessing a new trend emerging: individual creators and businesses are finding the time and inspiration for firing up new shows. From April until now, the podcast hosting company has seen a 300% increase in new trials, and a 102% increase in MRR over last two years. Castos currently has nearly 2,000 paying customers.

The company started in 2017 after non-technical founder Craig Hewitt acquired the Seriously Simple Podcasting plugin from its original creator, Hugh Lashborooke. Hewitt expanded the platform to allow both WordPress and non-WordPress users to create podcasts, and has grown the business to support seven remote, full-time employees. He attributes most of the industry’s fresh infusion of new shows to companies that are exploring new ways of getting into customers’ homes.

“Many brands are finding that traditional marketing efforts are falling short in these turbulent times, but great content that serves a specific audience always has an impact,” Hewitt said. “Many companies are pivoting from more conventional paid acquisition approaches to building stronger and longer lasting relationships with their audiences through podcasting.”

Hewitt said he expects the trend to continue after the pandemic subsides. Many of the companies Castos works with have reported that podcasting is likely to become a core part of their marketing efforts for the long haul, in both B2B and B2C environments.

“Like the move to remote work many companies are seeing that podcasting isn’t hard to do, and provides great returns for them in terms of branding and as a top of funnel customer acquisition strategy,” Hewitt said. “Whether in the midst of Coronavirus or afterwards this will continue to be true and the momentum that podcasting has gained should continue.”

Approximately 70% of Castos’ hosting customers are using the Seriously Simple Podcasting plugin. The hosting platform is unique in the podcasting market in that it automates YouTube Republishing, transcriptions, and Headliner integration, while allowing users to manage it all via WordPress. Castos recently hired Matt Medeiros, an experienced podcaster and YouTube creator, to help new podcasters keep pushing with their shows and convert into longterm customers. He shares Hewitt’s optimistic outlook on the future of the industry.

“There were early reports that podcast download stats dropped in tandem with listener commute times, but I think that opened up opportunity for creators to really capture their most loyal audiences,” Medeiros said.

“The other side of that coin are the businesses that needed to stay top of mind with the customers while their doors were closed. Spinning up a podcast is a perfect way to do that. Podcasts come in all shapes and sizes, so building one that’s tailored to your customers is what really matters and will survive through our post-pandemic ‘new normal.'”

Portability is the common denominator for podcasts – people are listening from their desktops, mobile devices, and smart speakers, using a variety of different apps. But audiences vary in their appetites for staying informed, educated, and entertained through the podcasting medium. Medeiros advises both new and established podcasters to find out what kind of show their customers want them to produce.

“Podcasts don’t have to be cookie cutter,” Medeiros said. “If you spend time getting feedback from your customers or audience, you want to tailor the show around that. Do they like 15 minute news highlights or 3 hour 1-on-1 interviews? Do they want hard news or laugh out loud entertainment? What’s in it for them as a listener? What’s in it for you as a creator?

“At the end of the day, the biggest opportunity for podcasting is that it opens the door to having your favorite creators and fans in the same room every time you publish an episode. It’s a chance to (literally) have a conversation and build trust through creative storytelling – your brand’s digital handshake.” 

Anytime Mailbox Launches API for Mail Center Operators

Anytime Mailbox, a service that provides physical mail handling with options for digital processing, has announced a new API that will enable mail center operators to integrate Anytime Mailbox’s service into their existing systems.

The company intends the API to assist developers in creating branded solutions for mail center operating partners that handle the physical portion of the business. The announcement of the API discussed some technical aspects of the API, including security standards:

Plugin Authors Can Opt Into Email Confirmation for WordPress Plugin Updates

Overnight, the Meta Team for WordPress.org flipped the switch for a new plugin author feature in the official directory. It allows plugin authors to opt into confirming plugin updates via email. Release confirmations will strengthen security and make sure any updates sent in are intentional.

Dion Hulse opened the original ticket six weeks ago with a detailed proposal and set of questions. WordPress 5.5 introduced automatic updates for plugin and theme authors. While auto-updates are completely opt-in for end-users, Hulse wanted to make sure that WordPress.org was on top of any potential disasters that may arise from the new system, such as accidental or even malicious plugin releases.

“I’d like to propose that we add an extra optional step into the release flow for plugins, not intended on adding friction, but intending to ensure that plugin releases only get made when they’re intended to,” he wrote. “A simple Email confirmation.”

At the moment, release confirmation via email is merely an opt-in feature that all plugin authors can take advantage of. However, the original proposal required it for high-usage plugins — there was never a definitive minimum install count that constituted “high usage” in the ticket.

The general agreement on how this feature should work seems to be:

  • Opt-in for all plugin authors now.
  • Forced opt-in and no opt-out for high-usage plugins soon.
  • Opt-out for all other plugins in the future.

For larger plugins with multiple committers, there was some discussion on requiring confirmation from a separate committer who did not push the code live. This would essentially require two people to confirm that a plugin update is valid. This could potentially add to the friction that Hulse wanted to avoid in the original proposal. However, some friction for plugins with millions of installs might not always be such a bad thing. These plugins serve a massive user base and can damage WordPress’s reputation if a malicious actor gained commit access somehow. Having two people confirm an update is a good kind of friction in some cases.

However, requiring two-person confirmation is a more nuanced discussion that will need to happen. For example, Chris Christoff brought up examples in the ticket of not being able to send updates for plugins with two committers when one is on vacation or when the committers live in different time zones. Perhaps this will be an opt-in feature for plugin companies that choose to go this route in the future, depending on what fits their release flow best.

On the whole, the current implementation is a good starting position that will allow the community to iron out further details. This is about making WordPress more secure. If there is an extra step involved in publishing a code update, plugin authors should be on board with the process. Verifying the validity of a release sounds like a common-sense security feature. I would welcome WordPress.org making this a hard requirement — neither opt-in nor opt-out — in the long run after the feature has gone through a few rounds of real-world testing.

Theme developers do not have access to this feature at this time. However, the theme authors do not have access to SVN and must submit updates via a ZIP file. It is a much more manual process and should not be subjected to the same number of potential mishaps as plugin updates.

How Plugin Authors Can Enable Release Confirmation Emails

Screenshot of the plugin release confirmation email form.
Enable email release confirmation form for plugin authors.

Plugin authors should now see a new administration option for each of their projects listed in the official plugin directory. The Danger Zone section of the Advanced View tab should display a new sub-section for enabling release confirmation emails. From there, authors merely need to click a button to turn them on.

It is important to note that, once enabled, release confirmation emails cannot be disabled from the same screen. Plugin authors are presented with the following notice before enabling the feature:

Warning: Enabling release confirmations is intended to be a permanent action. There is no way to disable this without contacting the plugins team.

Do not let the warning put you off if you are a plugin author. This is a good thing. Go ahead and enable it on at least one plugin if you want to test it first. I already have done so for one of my plugins. It is a simple process and helps add one additional layer of security over your plugins.

Settings: Redesigned!

We’ve been on a bit of a redesign tear these last few months. I’m happy to unveil the latest one: a complete redesign of CodePen Settings!

Settings is one of the last remnants of Old School CodePen™. While I’ll miss the 2011 nostalgia, the new Settings page is a thing of beauty. Beyond the UI and UX we also ripped out another huge chunk of our Ruby on Rails stack and modernized to reusable React Components, expanded our GraphQL API, and refined our component library. The Settings codebase is a joy to work with!

Perhaps a redesign of the settings area of CodePen isn’t particularly exciting to you, dear user. Fair enough. But we really do hope that when you need to change settings, this new experience is much more snappy and clear. We revisited literally every single page and redesigned it for clarity and responsiveness. We’re particularly happy with how the billing information is presented. You should be able to easily see your current account status and billing history.

Before & After

Now some fun! I love nothing more than before and after design unveilings, so buckle up y’all.

Content Organization

We flipped the tabbed navigation vertically. Which is the experience you’ll recognize from the rest of CodePen. We streamlined content where we could (For example, Customize is now within Profile, where it makes sense) but the tab names are almost exactly the same as before. It’s just far easier to absorb the beautifully laid out content from top to bottom. The permanent sidebar also makes it easier to remember where you are.

Before: Tabs on Top
After: Tabs on Left

Auto Save

Before, you’d have to click that pesky Save button for your updates to take affect. No more! Thanks to elegantly laid out React Hooks, your changes automatically save. After a short grace period, of course.

You’re also given immediate feedback on bad inputs.

Billing

An area that’s near and dear to my heart (only slightly kidding), we spent lots of time figuring out an improved UX for our entire billing system. We’ve got a few more phases of billing releases to go but this is a great start. For example, you no longer have to switch context to view your team’s billing information. We’ve got your personal billing tab up top with the rest of your personal settings. We created a new “Teams” section below to house your team billing tab alongside other team settings.

Before: You had to switch contexts to manage team billing separately from personal billing.
After: Because I’m the owner of Team ChimeOn, I can see both my personal billing history and the Team billing history.

Team Account & Members

So many amazing changes, it’s hard to pick a favorite. But the team roster is high up there. If you’re the Team Owner, you’ll see a simple form below the roster for inviting new members by email.

Editor Preferences

I’ve saved possibly the best for last: editor settings. I know many of you will be using this settings pane the most, and hopefully its a delightful experience.

A Team Effort

This was a massive effort from everybody on Team CodePen. It involved a ton of design, client and server side work and support desk emails. So it feels especially good to finally have new Settings on production, giving all y’all out there an improved CodePen. I promise, you don’t want to know how many support tickets were caused by confusion in the Settings area. Don’t mind us as we self-high-five. 🙌🏽

The post Settings: Redesigned! appeared first on CodePen Blog.

Calling restful API from Android App

Dear Friends,

I have a web API I developed using asp.net c# with uri "https://www.xxxxxxx.com:82/api/pincheck" with the function called "getuser".

I want to use this API to authenticate login to an android App. I am building the app using Android Studio One.

The user enters a six digit pin, the app calls the API and returns the user details attached to the PIN entered.

Please help me on a simple tutorial or code to call this API from my android App. I have tried looking for one online but cannot find something simple to follow.

Regards,
Naheed

17 Navigation Menus Made With Only CSS (No JavaScript)

We’ve been on a kick lately here at 1WD, looking at ways to code things in pure CSS without utilizing JavaScript, not because we don’t like JavaScript, but when you can avoid using it and still accomplish what you set out to do, why not? So today we’ve gathered 17 examples of navigation menus coded this way. Have a gander and see if there are any you can use in your future projects.

Web Designer Toolbox: Unlimited Downloads Starting at $16.50/Month
Website Kits

Website Kits
16,000+ Web Designs

UX & UI Kits

UX & UI Kits
14,000+ UX & UI Kits

Graphic Assets

Graphic Assets
33,000+ Graphics

DOWNLOAD NOW
Envato Elements


Mobile Overlay Menu

Here’s a hamburger icon that reveals a full screen overlay when clicked, with a nice animation of the hamburger turning into a close “X” icon.

See the Pen Mobile Menu – CSS by Daniel Hearn (@danhearn) on https://codepen.io‘>CodePen.dark

Mobile Fade In Menu

A slightly different approach with the menu fading into view to the right of the hamburger icon. This obviously would work best on small screens with only a few menu items.

See the Pen Mobile Menu (CSS) by AY (@amycodes) on https://codepen.io‘>CodePen.dark

Hamburger Menu With Animations

Some eye-catching animations make this menu stand out.

See the Pen Hamburger Menu – Pure CSS by Mark Claus Nunes (@mnunes) on https://codepen.io‘>CodePen.dark

Tumblr Inspired Menu

As the title says, this menu was inspired by Tumblr and has some slick animation.

See the Pen Tumblr inspired menu (pure css) by John Riordan (@JohnRiordan) on https://codepen.io‘>CodePen.dark

Hidden Navigation Menu

An off-canvas menu that slides out and back in when toggled.

See the Pen Hidden Navigation Menu (Pure CSS) by Jessica Jones (@helloheyjess) on https://codepen.io‘>CodePen.dark

Fade In/Fade Out Menu

A modal window that fades in and out houses the navigation menu in this example.

See the Pen Fade-In/Fade-Out Menu – Pure CSS by Ben Melluish (@pseudosocial) on https://codepen.io‘>CodePen.dark

Mega Menu

How about a full-width mega menu? Nicely done!

See the Pen Mega Menu Pure CSS by Mohammed Naji Abu Alqumboz (@mohnaji94) on https://codepen.io‘>CodePen.dark

Off-Canvas Menu

A well-designed slide-out menu with a nice UX.

See the Pen Off Canvas Menu – Pure CSS by Muhamed Ibrahim (@MuhamedIbrahim) on https://codepen.io‘>CodePen.dark

Animated Radial Menu

Here’s a cool social sharing icon radial menu.

See the Pen Animated menu by Dario Fuzinato (@fuzinato) on https://codepen.io‘>CodePen.dark

Mobile-Like Aside Menu

Another slide out hamburger menu example.

See the Pen mobile-like aside menu pure css by Felipe Nunes (@willpower) on https://codepen.io‘>CodePen.dark

Material Design Round Mask Menu

An interesting concept where the menu appears on hover.

See the Pen Material design round mask menu (pure css) by Sorin Botirla (@sorinbotirla) on https://codepen.io‘>CodePen.dark

Just Another Menu

Not really “just another menu”, this one is a share icon menu that would work well on blog posts or other content that needs to be shared.

See the Pen Just Another Menu(Pure CSS) by Akhil Sai Ram (@akhil_001) on https://codepen.io‘>CodePen.dark

Drop Down Navigation Menu

A drop down menu with sub-items appearing with an interesting animation.

See the Pen #CodePenChallenge: Menu by Hakkam Abdullah (@Moslim) on https://codepen.io‘>CodePen.dark

Radial Menu

Another radial menu not unlike the previous examples.

See the Pen Radial Menu – Pure CSS by Colin Hall-Coates (@Oka) on https://codepen.io‘>CodePen.dark

Fullscreen Overlay Menu

And here’s another fullscreen overlay menu with some nice animation.

See the Pen Fullscreen overlay menu (pure css) by Vlada Oleynik (@vladaoleynik) on https://codepen.io‘>CodePen.dark

Responsive Hamburger Menu

A nice navigation menu that adjusts to various screen sizes like a responsive menu should.

See the Pen Responsive hamburger menu – pure CSS  #1 by mutedblues (@mutedblues) on https://codepen.io‘>CodePen.dark

Animated Mobile Navigation Menu

Lastly, we have a bottom of the screen mobile device menu with a slick animation.

See the Pen Animated mobile navigation menu (pure CSS) by Lovro Kalan (@LovroKalan) on https://codepen.io‘>CodePen.dark

How Will You Use These Pure CSS Navigation Menus?

We hope these examples of navigation menus will prove useful for your future projects. Be sure to check out our other collections of pure CSS code snippets too!

Java Programming ( Cashier Question )

I got a java programming assignment in where you will ask:

1.) Ask the user to input item name, price, quantity and payment.

2.) Store the responses in the computer's memory.

3.) Displaying the item name, total amount and change.

( PS: Still new to this site, want some help badly. )

Animating React Components With GreenSock

During the early days of the World Wide Web, things were rather static and boring. Webpages were mostly based on graphic design and layouts from the print world until animations were introduced. Animation can engage and hold people’s attention longer than a static web page and communicates an idea or concept more clearly and effectively.

However, when not done right, animations can hamper user interactions with your product and negatively impact traction. The GreenSock Animation Platform AKA (GSAP) is a powerful JavaScript library that enables front-end developers, animators and designers to create performant timeline based animations. It allows animation lovers take precise control of their animation sequences rather than the sometimes constraining keyframe and animation properties that CSS offers.

In this article, I’ll introduce you to some features of GSAP such as scrollTriggers, Timelines, Easing etc, at the end we’ll build an intuitive user interface by animating a React app with this features👌. Check out the finished project on codesandbox.

This article will be useful to you if:

  • You have been building animations on web applications with HTML, CSS, and JavaScript.
  • You are already building animated webpages in a React apps with packages like animate.css, React-motion, Framer-motion, and React-Spring, plus you want to check out alternatives.
  • You are a React enthusiast, and you’d like to build complex animations on React-based web applications.

We will look at how to build a variety of animations from an existing web project. Let’s get to it!

Note: This article assumes you are comfortable with HTML, CSS, JavaScript, and React.js.

What Is GSAP?

GreenSock Animation Platform also known as GSAP is an Ultra high-performance, professional-grade animation for the modern web that allows developers to animate their apps in a modular, declarative, and re-usable fashion. It is framework-agnostic and can be used across any JavaScript based project, it has a very minimal bundle size and will not bloat your app.

GSAP can perform canvas animations, used to create WebGL experiences, and create dynamic SVG animations and as great browser support.

Why Use GSAP?

Maybe you’re not quite ready to betray other frameworks yet, or you haven’t been convinced to embrace the goodies that come with GSAP. Allow me to give you a few reason why you may want to consider GSAP.

You Can Build Complex Animations

GSAP JavaScript library makes it possible for developers to build simple to very complex physics-based animations like in the case of these sites, it allows developers and designers sequence motion and controls the animation dynamically. It has lots of plugins such as DrawSVGPlugin, MorphSVGPlugin, and more, which makes creating SVG based animations and 2D/3D animations a reality. Asides integrating GSAP on DOM elements, you can use them within WebGL/Canvas/ Three.js context-based animations.

Furthermore, the easing capacity of GSAP is quite sophisticated, hence making it possible to create advance effects with multiple beziers as compared to the regular CSS animation.

Performance

GSAP has an impressive high performance across different browsers.

According to GSAP’s team, in their website, “GSAP is 20x faster than jQuery, plus GSAP is the fastest full-featured scripted animation tool on the planet. It's even faster than CSS3 animations and transitions in many cases.” Confirm speed comparison for yourself.

Furthermore, the GSAP animations perform effortlessly on both desktop computers, tablets, and smartphones. It is not needed to add a long list of prefixes, this is all being taken care of under the hood by GSAP.

You can check out more benefits on GSAP or see what Sarah Drasner as to say about it here.

Cons Of GSAP

Are you saying I should always use GSAP for every project? Of course not! I feel like, there’s only one reason you might not want to use GSAP. Let’s find out!

  • GSAP is solely a JavaScript-based animation library, hence it requires some knowledge of JavaScript and DOM manipulation to effectively utilize its methods and APIs. This learning curve downside leaves even more room for complications for a beginner starting out with JavaScript.
  • GSAP doesn’t cater to CSS based animations, hence if you are looking for a library for such, you might as well use keyframes in CSS animation.

If you’ve got any other reason, feel free to share it in the comment section.

Alright, now that your doubts are cleared, let’s jump over to some nitty-gritty in GSAP.

GSAP Basics

Before we create our animation using React, let’s get familiar with some methods and building blocks of GSAP.

If you already know the fundamentals of GSAP, you can skip this section and jump straight to the project section, where we’ll make a landing page skew while scrolling.

Tween

A tween is a single movement in an animation. In GSAP, a tween has the following syntax:

TweenMax.method(element, duration, vars)

Let’s take a look at what this syntax represents;

  1. method refers to the GSAP method you’ll like to tween with.
  2. element is the element you want to animate. If you want to create tweens for multiple elements at the same time, you can pass in an array of elements to element.
  3. duration is the duration of your tween. It is an integer in seconds (without the s suffix!).
  4. vars is an object of the properties you want to animate. More on this later.

GSAP methods

GSAP provides numerous methods to create animations. In this article, we’d mention only a few such as gsap.to, gsap.from, gsap.fromTo. You can check out other cool methods in their documentation. The methods discussed in this section will be used in building our project later in this tutorial.

  • gsap.to() the values to which an object should be animated i.e the end property values of an animated object — as shown below:
    gsap.to('.ball', {x:250, duration: 5})

To demonstrate the to method the codepen demo below shows that an element with a class of ball 250px will move across the x-axis in five seconds when the components mounts. If a duration isn't given, a default of 500 milliseconds would be used.

See the Pen GSAP REACT DEMO1 by Blessing Krofegha.

Note: x and y-axis represent the horizontal and vertical axis respectively, also in CSS transform properties such as translateX and translateY they are represented as x and y for pixel-measured transforms and xPercent and yPercent for percentage-based transforms.

To view the complete snippet of the code check the codepen playground.

  • gsap.from() — Defines the values an object should be animated from — i.e., the start values of an animation:
    gsap.from('.square', {duration:3, scale: 4})

The codepen demo show how an element with a class of square is resized from a scale of 4 in 3seconds when the components mounts. Check for the complete code snippet on this codepen.

See the Pen GSAP REACT DEMO2 by Blessing Krofegha.

  • gsap.fromTo() — lets you define the starting and ending values for an animation. It is a combination of both the from() and to() method.

Here’s how it looks;

gsap.fromTo('.ball',{opacity:0 }, {opacity: 1 , x: 200 , duration: 3 });
gsap.fromTo('.square', {opacity:0, x:200}, { opacity:1, x: 1 , duration: 3 });

This code would animates the element with a class of ball from an opacity of 0 to an opacity of 1 across the x-axis in 3 seconds and the square class is animated the from an opacity of 0 to 1 in 3 seconds across the x-axis only when the component mounts. To see how the fromTo method works and the complete code snippet, check the demo on CodePen below.

See the Pen React GSAP FromTo demo by Blessing Krofegha.

Note: Whenever we’re animating positional properties, such as left and top, we must ensure that the elements concerned must have a CSS position property of either relative, absolute, or fixed.

Easing

GSAP official documentation defined easing as the primary way to change the timing of your Tweens. It determines how an object changes position at different points. Ease controls the rate of change of animation in GSAP and is used to set the style of an object’s animation.

GSAP provides different types of eases and options to give you more control over how your animation should behave. It also provides an Ease Visualizer to help you choose your preferred ease settings.

There are three types of eases, and they vary in their operations.

  1. in() — Motion starts slowly, then picks up the pace toward the end of the animation.
  2. out() — The animation starts fast then slows down at the end of the animation.
  3. inOut() — The animation begins slow, picks up the pace halfway through, and ends slowly.

See the Pen React GSAP Easing demo by Blessing Krofegha.

In these easing example, we chained the tweens that displayed the three types of eases bounce.in, bounce.out and bounce.inOut, and set a delay of the number of seconds it takes the animation to complete before starting the next one only when the component is mounts. This pattern is repetitive, in the next next section we would see how we could use a timeline to do this better.

Timelines

A Timeline acts as a container for multiple tweens. It animates tweens in sequential order, and it is not dependent on the duration of the previous tween. Timeline makes it simple to control tweens as a whole and precisely manage their timing.

Timelines can be written by creating an instance of a timeline like so:

gsap.timeline();

You can also chain multiple tweens to a timeline in two different ways, in the code below:

##Method 1
const tl = gsap.timeline(); // create an instance and assign it a variable
tl.add(); // add tween to timeline 
tl.to('element', {});
tl.from('element', {});

##Method 2
gsap.timeline()
    .add() // add tween to timeline 
    .to('element', {})
    .from('element', {})

Let’s recreate the previous example with a timeline:

const { useRef, useEffect } = React;

const Balls = () => {
    useEffect(() => {
const tl = gsap.timeline(); tl.to('#ball1', {x:1000, ease:"bounce.in", duration: 3}) tl.to('#ball2', {x:1000, ease:"bounce.out", duration: 3, delay:3 }) tl.to('#ball3', {x:1000, ease:"bounce.inOut", duration: 3, delay:6 }) }, []); } ReactDOM.render(, document.getElementById('app'));

Inside a useEffect hook, we created a variable(tl) that holds an instance of a timeline, next we used the tl variable to animate our tween in sequential without depending on the previous tween to animate, passing the same properties as it were in the previous example. For the complete code snippet of this demo check the codepen playground below.

See the Pen React GSAP (Easing with Timeline) demo by Blessing Krofegha.

Now that we have gotten a feel of some the basic building blocks of GSAP, let’s see how we could build a complete animation in a typical React app in the next section. Let’s begin the flight! 🚀

Building an Animated Landing Page with React and GSAP

Let’s get to animate a React App. Ensure you clone the repo before you begin and run npm install, to install the dependencies.

What are we building?

Currently, our landing page contains a few texts a white background, a menu that doesn’t drop down, with really no animation. The following are what we’ll be adding to the landing page;

  • Animate the text and the logo on the homepage, so it eases out when the component is mounted.
  • Animate the menu, so it drops down when the menu is clicked.
  • Make the images in the gallery page skew 20deg when the page scrolls.
Animated page.

Check out the demo on codesandbox.

We’ll break the process of our landing page into components, so it will be easy to grasp. Here’s the process;

  • Define the animation methods,
  • Animate text and logo,
  • Toggle menu,
  • Make images skew 20deg on page scroll.

components

  • Animate.js — Defined all animation methods,
  • Image.js — import galley images,
  • Menu.js — Contains the menu toggle functionality,
  • Header.js — Contains navigation links.

Define animation methods

Create a component folder inside the src directory, and create an animate.js file. Copy and paste the following code into it.

import gsap from "gsap"
import { ScrollTrigger } from "gsap/ScrollTrigger";
//Animate text 
export const textIntro = elem => {
  gsap.from(elem, {
    xPercent: -20,
    opacity: 0,
    stagger: 0.2,
    duration: 2,
    scale: -1,
    ease: "back",
  });
};

Here, we imported gsap . We wrote an exported arrow function that animates the text on the landing page. Remember that gsap.from() method defines the values an object should be animated from. The function has an elem parameter that represents the class which needs to be animated. It takes a few properties and assigns values such as xPercent: -20 (transforms the object by -20%), gives the object no opacity, makes the object scale by -1, makes the object ease back in 2sec.

To see if this works, head over to App.js and include the following code.

...
//import textIntro
import {textIntro} from "./components/Animate"

...
//using useRef hook to access the textIntro DOM
 let intro = useRef(null)
  useEffect(() => {
    textIntro(intro)
  }, [])

function Home() {
  return (
    <div className='container'>
      <div className='wrapper'>
        <h5 className="intro" ref={(el) => (intro = el)}></h5>
          The <b>SHOPPER</b>, is a worldclass, innovative, global online ecommerce platform,
          that meets your everyday daily needs.
        </h5>
      </div>
    </div>
  );
}

Here, we import the textIntro method from the Aminate component. To access the DOM we used to useRef Hook. We created a variable intro whose value is set to null. Next, inside the useEffect hook, we called the textIntro method and the intro variable. Inside our home component, in the h5 tag, we defined the ref prop and passed in the intro variable.

Animated text.

Next, we have got a menu, but it isn’t dropping down when it’s clicked. Let’s make it work! Inside the Header.js Component, add the code below.

import React, { useState, useEffect, useRef } from "react";
import { withRouter, Link, useHistory } from "react-router-dom";
import Menu from "./Menu";
const Header = () => {
  const history = useHistory()
  let logo = useRef(null);
  //State of our Menu
  const [state, setState] = useState({
    initial: false,
    clicked: null,
    menuName: "Menu",
  });
  // State of our button
  const [disabled, setDisabled] = useState(false);
  //When the component mounts
  useEffect(() => {
    textIntro(logo);
    //Listening for page changes.
    history.listen(() => {
      setState({ clicked: false, menuName: "Menu" });
    });
  }, [history]);
  //toggle menu
  const toggleMenu = () => {
    disableMenu();
    if (state.initial === false) {
      setState({
        initial: null,
        clicked: true,
        menuName: "Close",
      });
    } else if (state.clicked === true) {
      setState({
        clicked: !state.clicked,
        menuName: "Menu",
      });
    } else if (state.clicked === false) {
      setState({
        clicked: !state.clicked,
        menuName: "Close",
      });
    }
  };
  // check if out button is disabled
  const disableMenu = () => {
    setDisabled(!disabled);
    setTimeout(() => {
      setDisabled(false);
    }, 1200);
  };
  return (
    <header>
      <div className="container">
        <div className="wrapper">
          <div className="inner-header">
            <div className="logo" ref={(el) => (logo = el)}>
              <Link to="/">SHOPPER.</Link>
            </div>
            <div className="menu">
              <button disabled={disabled} onClick={toggleMenu}>
                {state.menuName}
              </button>
            </div>
          </div>
        </div>
      </div>
      <Menu state={state} />
    </header>
  );
};
export default withRouter(Header);

In this component, we defined our menu and button state, inside the useEffect hook, we listened for page changes using useHistory hook, if the page changes we set the clicked and menuName state values to false and Menu respectively.

To handle our menu, we checked if the value of our initial state is false, if true, we change the value of initial , clicked and menuName to null, true and Close. Else we check if the button is clicked, if true we’d change the menuName to Menu. Next, we have a disabledMenu function that disables our button for 1sec when it’s clicked.

Lastly, in our button, we assigned disabled to disabled which is a boolean value that will disable the button when its value is true. And the onClick handler of the button is tied to the toggleMenu function. All we did here was toggle our menu text and passed the state to a Menu component, which we would create soonest. Let’s write the methods that will make our menu dropdown before creating the actual Menu component. Head over to Animate.js and paste this code into it.

....
//Open menu
export const menuShow = (elem1, elem2) => {
  gsap.from([elem1, elem2], {
    duration: 0.7,
    height: 0,
    transformOrigin: "right top",
    skewY: 2,
    ease: "power4.inOut",
    stagger: {
      amount: 0.2,
    },
  });
};
//Close menu
export const menuHide = (elem1, elem2) => {
  gsap.to([elem1, elem2], {
    duration: 0.8,
    height: 0,
    ease: "power4.inOut",
    stagger: {
      amount: 0.07,
    },
  });
};

Here, we have a function called menuShow, which skews the menu horizontally by 2degrees, eases the menu, offset’s the animation using the stagger property, and transforms the menu from right to top in 0.7sec, the same properties go for the menuHide function. To use these functions, create Menu.js file inside the components and paste this code into it.

import React, {useEffect, useRef} from 'react'
import { gsap } from "gsap"
import { Link } from "react-router-dom"
import {
  menuShow,
  menuHide,
  textIntro,
} from './Animate'
const Menu = ({ state }) => {
   //create refs for our DOM elements

  let menuWrapper = useRef(null)
  let show1 = useRef(null)
  let show2 = useRef(null)
  let info = useRef(null)
  useEffect(() => {
    // If the menu is open and we click the menu button to close it.
    if (state.clicked === false) {
      // If menu is closed and we want to open it.
      menuHide(show2, show1);
      // Set menu to display none
      gsap.to(menuWrapper, { duration: 1, css: { display: "none" } });
    } else if (
      state.clicked === true ||
      (state.clicked === true && state.initial === null)
    ) {
      // Set menu to display block
      gsap.to(menuWrapper, { duration: 0, css: { display: "block" } });
      //Allow menu to have height of 100%
      gsap.to([show1, show2], {
        duration: 0,
        opacity: 1,
        height: "100%"
      });
      menuShow(show1, show2);
      textIntro(info);

    }
  }, [state])

  return (
    <div ref={(el) => (menuWrapper = el)} className="hamburger-menu">
      <div
        ref={(el) => (show1 = el)}
        className="menu-secondary-background-color"
      ></div>
      <div ref={(el) => (show2 = el)} className="menu-layer">
        <div className="container">
          <div className="wrapper">
            <div className="menu-links">
              <nav>
                <ul>
                  <li>
                    <Link
                      ref={(el) => (line1 = el)}
                      to="/about-us"
                    >
                      About
                    </Link>
                  </li>
                  <li>
                    <Link
                      ref={(el) => (line2 = el)}
                      to="/gallery"
                    >
                      Gallery
                    </Link>
                  </li>
                  <li>
                    <Link
                      ref={(el) => (line3 = el)}
                      to="/contact-us"
                    >
                      Contact us
                    </Link>
                  </li>

                </ul>
              </nav>
              <div ref={(el) => (info = el)} className="info">
                <h3>Our Vision</h3>
                <p>
                  Lorem ipsum dolor sit amet consectetur adipisicing elit....
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}
export default Menu

What we did in the Menu component was to import the animated functions, which are menuShow, menuHide, and textIntro. Next, we assigned variables for each created refs for our DOM elements using the useRef hook and passed null as their values. Inside the useEffect hook, we check for the state of the menu, if clicked is false, we call the menuHide function, otherwise, if the clicked state is true we call the menuShow function. Lastly, we ensured that the DOM elements concerned are passed their specific refs which are menuWrapper, show1, show2. With that, we’ve got our menu animated.

Let’s see how it looks.

Animated Menu.

The last animation we would implement is make our images in our gallery skew when it scrolls. Let’s see the state of our gallery now.

Gallery without animation.

To implement the skew animation on our gallery, let’s head over to Animate.js and add a few codes to it.

....
//Skew gallery Images
export const skewGallery = elem1 => {
  //register ScrollTrigger
  gsap.registerPlugin(ScrollTrigger);
  // make the right edge "stick" to the scroll bar. force3D: true improves performance
    gsap.set(elem1, { transformOrigin: "right center", force3D: true });
    let clamp = gsap.utils.clamp(-20, 20) // don't let the skew go beyond 20 degrees. 
    ScrollTrigger.create({
      trigger: elem1,
      onUpdate: (self) => {
        const velocity = clamp(Math.round(self.getVelocity() / 300));
        gsap.to(elem1, {
          skew: 0,
          skewY: velocity,
          ease: "power3",
          duration: 0.8,
        });
      },
    });
}

We created a function called skewGallery, passed elem1 as a param, and registered ScrollTrigger.

ScrollTrigger is a plugin in GSAP that enables us to trigger scroll-based animations, like in this case of skewing the images while the page scrolls.

To make the right edge stick to the scroll bar we passed right center value to the transformOrigin property, we also set the force3D property to true in other to improve the performance.

We declared a clamp variable that calculates our skew and ensures it doesn’t exceed 20degs. Inside the ScrollTrigger object, we assigned the trigger property to the elem1 param, which would be the element that needs to be triggered when we call this function. We have an onUpdate callback function, inside it is a velocity variable that calculates the current velocity and divides it by 300.

Lastly, we animate the element from their current values by setting other values. We set skew to initially be at 0 and skewY to be the velocity variable at 0.8.

Next, we’ve got to call this function in our App.js file.

....
import { skewGallery } from "./components/Animate"
function Gallery() {
  let skewImage = useRef(null);
  useEffect(() => {
    skewGallery(skewImage)
  }, []);
  return (
    <div ref={(el) => (skewImage = el)}>
      <Image/>
    </div>
  )
}

....

Here, we imported skewGalley from ./components/Animate, created a skewImage ref that targets the image element. Inside the useEffect hook, we called the skewGallery function and passed the skewImage ref as a param. Lastly, we passed the skewImage to the ref to attribute.

You’d agree with me it was such a pretty cool journey thus far. Here’s the preview on CodeSanbox 👇

The supporting repo for this article is available on Github.

Conclusion

We’ve explored the potency of GSAP in a React project, we only scratched the surface in this article, there’s no limit to what you can do with GSAP as it concerns animation. GSAP’s official website offers additional tips to help you gain a thorough understanding of methods and plugins. There’s a lot of demos that would blow your mind away with what people have done with GSAP. I’d love to hear your experience with GSAP in the comment section.

Resources

  1. GSAP Documentation — GSAP
  2. The Beginner’s Guide to the GreenSock Animation Platform — Freecodecamp
  3. An introduction to animations with Greensock Animation API (GSAP) — Zellwk