惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
博客园 - 司徒正美
雷峰网
雷峰网
L
LINUX DO - 最新话题
博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
V2EX - 技术
V2EX - 技术
S
Security Affairs
有赞技术团队
有赞技术团队
月光博客
月光博客
T
Threatpost
T
Tor Project blog
O
OpenAI News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
V2EX
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
博客园 - 三生石上(FineUI控件)
D
Docker
AWS News Blog
AWS News Blog
AI
AI
P
Proofpoint News Feed
K
Kaspersky official blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Securelist
F
Fortinet All Blogs
F
Full Disclosure
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
量子位
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Palo Alto Networks Blog
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
美团技术团队
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog

Maggie Appleton

The Dark Forest and Generative AI One Developer, Two Dozen Agents, Zero Alignment Gas Town’s Agent Patterns, Design Bottlenecks, and Vibecoding at Scale January 2026 | Maggie Appleton A Treatise on AI Chatbots Undermining the Enlightenment A Brief History & Ethos of the Digital Garden Vibe Code is Legacy Code May 2025 | Maggie Appleton Home-Cooked Software and Barefoot Developers Statistically, When Will My Baby Be Born? Speculative Calendar Events ChatGPT Would be a Decent Policy Advisor March 2025 | Maggie Appleton The Expanding Dark Forest and Generative AI Humanity's Last Exam Squish Meets Structure Common Misconceptions in AI Undetected AI Exam Answers Unbaited Smidgeons Growing a Human: The First 30 Weeks How to Import Academic Papers from Zotero into Tana December 2024 | Maggie Appleton Aesthetic Command Lines with Hyper, Spaceship, and Oh My Zsh Leaving Elicit July 2024 | Maggie Appleton A Short History of Bi-Directional Links The Pattern Language of Project Xanadu Assumed Audiences Ambient Co-presence On Opening Essays, Conference Talks, and Jam Jars Spinning Worlds, Seasickness, and Dealing with Vestibular Neuritis A Collection of Design Engineers Gathering Structures Daily Notes Pages Historical Trails December 2023 | Maggie Appleton September 2023 | Maggie Appleton Digital Gardening for Non-Technical Folks Language Model Sketchbook, or Why I Hate Chatbots June 2023 | Maggie Appleton Computational Notebooks Folk Interfaces Reverse Outlining with Language Models Command K Bars Spatial Web Browsing A Picture Worth a Thousand Programmes Programmable Notes Programming Portals Teenage Skeuomorphic Desktop Designs Tending Evergreen Notes in Roam Research Growing the Evergreens Why You Own an iPad and Still Can't Draw A Brief Introduction to Digital Anthropology Transclusion and Transcopyright Dreams The Block-Paved Path to Structured Data Empty Pointers and Constellations of AI Metaphors We Web By The Gift Economy Epistemic Disclosure November 2022 | Maggie Appleton Joining Ought July 2022 | Maggie Appleton The Linear Oppression of Note-taking Apps Paleolithic Nostalgia Interoperable Personal Libraries and Ad Hoc Reading Groups The Finest Narrative Non-Fiction Essays Algorithmic Transparency October 2021 | Maggie Appleton Plebeian Programming with Keyboard Maestro The Cultural Anthropology of React August 2021 | Maggie Appleton Natureculture, Moral Purity, and Cultural Boundaries The Echo & Narcissus Writing Club Pink, Soft, Glittering Developers Fetishism & Mechanical Keyboards Making Programming Visual, Spatial, and Learnable Organic, Local, Artisan Data Storage Positioning Elements & Scrollytelling in CSS Painting Roam Research with Custom CSS A Digital Anthropology Reading List The Eponymous Laws of Programming A History of Cyborgs Neologisms GreenSock Animations with React Hooks September 2020 | Maggie Appleton Illustrating Gatsby's Key Concepts Problematic Proteins New Harvest & Illustrating the Cultivated Meat Podcast Synecdoche: Drawing the Part for the Whole A Meta-Tour of This Site Douglas, Dirt, and Matter Out of Place The Knowledge Hydrant A Naïve Exploration of Computer-Supported Collaborative Learning Silent Synchronous Reading Sessions What the Fork is React Suspense? Visually Workshopping the AWS Cloud Are Data Unions the Future of Data? Pattern Languages in Programming and Interface Design A Metaphorical Reading Collection
The Bare Essentials of Greensock
2020-09-08 · via Maggie Appleton

When it comes to web animation libraries, Greensock is the Rolls Royce of options. It’s what powers most of those ridiculously fancy Awwwards websites.

It’s also been on my learning wish list for too long. I assumed it would be too complex. Everyone talks about how powerful the library is.

It’s usually safe to assume powerful === complex.

But once I started digging in I realised the core of the library was actually quite easy to get the hang of. There’s plenty of advanced mechanisms and complexity to get wrapped up in if you want to. But they’re entirely optional.

This is a one-scoop-plain-vanilla introduction to Greensock.
Without any sprinkles, nuts, or advanced functionality.

Greensock in Plain English

Greensock is a JavaScript library that changes DOM nodes directly. Once our browser has read the HTML document of a website, it transforms it into a set of DOM nodes - all our usual div’s, paragraphs, and images. Greensock then manipulates those nodes to create our animations.

Tweens

Tweens are the basic building blocks of a Greensock animation. A tween is a single transition – an element changing from state A to state B.

To create a tween, we target an element (this can be any HTML element like a <div>, <p>, or <svg>) and pass in variables. Variables define how the element should change over the course of the animation - whether it should move, change opacity or color, grow big or small – you get it.

Let’s say we want to make a box go from navy blue to red, move 40% of the way across the screen I’ve used 20vw units in this example which tells the browser to calculate 40% of the view width. vw is a handy unit for responsive design to make this work on little screens as well as big on the X axis (horizontal), and grow in scale by 1.4 times the original:

Here’s the code to do that in Greensock:

<div class="giantRedBox" background="navyblue" width="100px" height="100px" />;

gsap.to(".giantRedBox", 2, { x: 20vw, scale: 1.4, background: "red" });

First we target the element using it’s classname: giantRedBox.
We then pass in a duration that defines how long it should take the animation to move from state A to state B – here it’s 2 seconds.
Finally we pass in an object that contains our animation variables:
{ x: 20vw, scale: 1.4, background: 'red' }


Types of Tweens

There’s three types of tweens:

  • to
  • from
  • fromTo

In to we define the final state of the animation – what it looks like by the end. It begins in the position defined in our HTML & CSS, and moves to the state we define inside our greensock tween.

<div class="spinningBox" background="navyblue" width="100px" height="100px" />;

gsap.to(".spinningBox", 3, { x: 20vw, rotation: 360 });

In from we define the beginning state of the animation, and it moves back to it’s state defined in the HTML & CSS

gsap.from(".reverseSpinningBox", 3, { x: 20vw, rotation: 360 });

In fromTo we declare two states we want the animation to move between.

gsap.fromTo(".hotBox", 3, { background: "#93D0D9" }, { background: "#D93654" });

Timelines

Timelines are made up of tweens. They group them together into a sequence.

Once we declare a timeline, we can chain sets of tweens onto it.

const boxTimeline = gsap.timeline();

boxTimeline
	.to(".flyingBox", 2, { x: 100, scale: 1.5 })
	.to(".floatingBox", 3, { x: 10 })
	.to(".flippingBox", 1, { rotation: 360 });

You may see references around to multiple varieties of tweening and timelines called TweenMax, TweenLite, TimelineMax, and TimelineLite.

In late 2019 GSAP updated to version 3 and got rid of the all lite / max varieties so feel free to ignore that distinction in older code examples or.