Formula and Detect
Add to favorites
Use object properties, functions and type conversions to power your prototype

Advanced Prototyping in ProtoPie
1
Advanced Prototyping with ProtoPie
11:48
2
Quick Prototyping
11:46
3
Start Animation and Sequence
12:36
4
Drag and Release
9:38
5
Toggle with Conditions
11:48
6
Screen Transition
12:53
7
Pull to Dismiss
6:59
8
Page Scroll Position
11:57
9
Input and Submit
13:41
10
Chain and Drag 3D
7:45
11
Formula and Detect
16:37
12
Range and Card Animation
15:32
13
Variable and Detect Mouse
12:02
14
Sensors and Receive
12:47
Formula
Formula allows you to use variables and object properties inside fields such as X, Y, Width, Height or Text. You can combine values, use functions and convert pretty much the same way you'd do in code. It's really powerful when combined with triggers and responses.
Getting Started
Start off by heading to ProtoPie and creating a new Pie. Then, go to Sketch and import the artboard titled Dashboard @3x.
Setup
Before starting the animation, make sure to click on the option that says "Convert to Text" which is inside the Inspector and set the font weight to Medium. This automatically takes all the styling and we wouldn't have to recreate the layer from scratch. It also makes it easier for us to animate the layer. Do the same for Pay now. Resize the text to make it fit the screen.
Recreating Button
The button has two layers, the green background and the curved blue shape. We'll start with the first one, click on Shape and then select Rectangle. Resize it to the same size, set the radius to 20 and the color to #44CCDE. Now, for the blue shape, create a Rectangle sized 160x100. Set X to 16 and Y to 50. Set the color to #232CA8 and the radius to 20. Select Rectangle 1 and tick "Use as Mask" at the bottom. Lastly, rename the first rectangle as Mask and the second as Quantity.
Constraints
Constraints always save us a lot of effort and time. Click on Mask and disable both fixed width and fixed height. Now, set constraints to all sides. For Quantity, Pay now and Icon, set the constraints to bottom and right. Finally, delete the previous button.
Background
We'll be creating a background layer to hide everything else while the animation is happening. Create a rectangle and put it underneath Button. Set the width and the height to 100%. Set the fill to the color of the background. Now, drag Button and the rectangle to the top. Please ensure that the bars at the top of everything. Rename the rectangle to Background and set the opacity to 0.
Animation
To start animating, click on Add Trigger and choose Tap. Select Button, add Scale. Set the width to 116 and height to 440. Now, add Move, set X to 130 and Y to 96. To animate the opacity of the background, add Opacity and set it to 100.
Animating Layers
Go to Sketch, click on Make Exportable and export the Confirm Payment button @3x. Now, you can drag & drop it into ProtoPie. Set X to 130 and Y to 551. Set opacity to 0 by default. To animate when you tap, select Button Pay, add Opacity and set it to 100. Do the same for Pay now and Icon, set the opacity to 0. Set a bottom constraint for "Due in 6 days".
Spring Animation
To make Scale and Move more interesting, we'll be using Spring. Select Scale and choose the Spring option in Easing. Set the delay to 0.02.
Drag
The next step is to add a trigger for when you drag the Quantity. Click on Add Trigger and choose Drag. Now, add a response called Scale and set the direction to Upwards. To move the "Due..." text as you drag, add Move and set direction to "↕".
Detect
To change the content of the text when you drag, add a trigger and select Detect. Instead of X, choose Height. This'll detect any change in the height and call a response. Lastly, select "Due..." text and add a response called Text. In content, we'll select Formula instead of Text.
Formula
Now, we'll add Formula to make it dynamic. Click on "fx" and then press tilde to make searching easier. Select the Quantity layer and then the height value. Now, the content changes when you drag. To add the dollar sign, add "$" +
, it should look like "$" + Quantity
.height. To apply the formula on Tap, copy & paste Text from the Detect trigger to Tap.
Text-Transform
To transform the "Due..." text to upper-case. Add a new trigger called Start, select the text and add the Text response. To set the formula, type in upperCase(Due in 6 days
.text) inside the formula input field. Resize the layer so it fits the screen.
Touch Down
This step ensures that we animate back to where we were. Select Quantity and add the Touch Down trigger. Now, select the Button layer and add the 3D Rotate trigger inside Touch Down. Change the Rotation from Rotate By to Rotate to and set the angle to 10.
Touch Up
Select the Quantity layer and add the Touch Up trigger. Then, select the Button layer and add the 3D Rotate trigger inside Touch Up. Change the Rotation from Rotate By to Rotate to and set the angle to 10. To make the rotation look more smooth, select the second option in Direction.
Reset Animation
To reset animation, select Background and add the Tap trigger. Now, add a Reset response for every layer we animated i.e. Button Play, Button, Due in 6 days, Icon, Pay now, Quantity, Mask and Background. To ensure that the "Due..." text remains in upper-case, copy & paste it from Start to Tap. Please make sure that it's at the bottom, below all the Reset triggers.
Background Animation
The last step is to change the background color. To do so, select Background and add the Color trigger to our first Tap block. Set color to #46CBDD. Now, select Mask and follow the same steps. Set the color to #FFFFFF.
Animation Bug
You'll come across an issue when you click on the curved blue shape. It conflicts with Touch Up and Touch Down. Since, this is a prototype, issues like this show up often. What's important is you communicate well with your colleagues and engineers about how the animation should look like. Although, we weren't able to resolve this issue, please feel free to contact if you end up finding a solution.
Conclusion
In this section, we learned a number of techniques including how to use formulas, how this particular transition is built, how to use Drag and how to affect values in the formula. In the next one, we'll learn how to use range to detect values and some really cool card animations.
Steps
Import Scene
Import Dashboard from Design.sketch.
Convert to Text
Select Due, Pay texts in the Button container and click on Convert to Text.
Mask Rectangle
Color 44CCDE
Radius 20
Use as Mask
Constraints All Sides
Quantity Rectangle
Position X 16 Y 50
Size 160 x 100
Fill 232CA8
Radius 20
Constraints Bottom Right
Background Rectangle
Width 100%
Height 100%
Fill EDF2FB
Opacity 0
Import Button Pay
In Sketch, click Make Exportable, set size to 3x. Drag and drop image to ProtoPie from inspector.
Position X 130 Y 551
Opacity 0
Button Tap
Button Scale To 116 x 440, Spring delay 0.02
Button Move To 130 x 96, Spring
Background Opacity 100
Background Color 46CBDD
Mask Color FFF
Button Pay Opacity 100
Quantity Drag
Quantity Scale Direction Up
Due Move Direction Vertical
Quantity Detect Height
Due Text Formula:
"$" + `Quantity`.height
Duplicate to Button Tap
Due Start
Due Text Formula:
upperCase(`Due in 6 days`.text)
Quantity Touch Down
Button 3D Rotate To 10 degrees
Quantity Touch Up
Button 3D Rotate To 0 degrees Direction Reverse
Background Tap
Button Pay Reset
Button Reset
Due Reset
Icon Reset
Pay Reset
Quanity Reset
Mask Reset
Background Reset
Due Text Formula:
upperCase(`Due in 6 days`.text)
Templates and source code
Download source files
Download the videos and assets to refer and learn offline without interuption.
Design template
Source code for all sections
Video files, ePub and subtitles
Browse all downloads
1
Advanced Prototyping with ProtoPie
Create high-fidelity prototypes with variables, formula, conditions and sensors
11:48
2
Quick Prototyping
Learn the basics of ProtoPie and create a prototype for your entire app in minutes
11:46
3
Start Animation and Sequence
Learn how to use the Start trigger, animation responses and timing
12:36
4
Drag and Release
Use Drag, Touch Up and Touch Down to create gestures with cards
9:38
5
Toggle with Conditions
Create multiple animation states and toggle back and forth between them
11:48
6
Screen Transition
Create a custom transition between screens and that jumps to another scene
12:53
7
Pull to Dismiss
Create a dismiss interaction that transitions back to a previous screen
6:59
8
Page Scroll Position
Prototype an onboarding experience with 3 screens and use the scroll position to set the page indicator
11:57
9
Input and Submit
Prototype a Login experience with a form, error messages and a success modal
13:41
10
Chain and Drag 3D
Use the drag position to move and animate with perspective
7:45
11
Formula and Detect
Use object properties, functions and type conversions to power your prototype
16:37
12
Range and Card Animation
Detect a range of values to trigger a response and create screen transitions
15:32
13
Variable and Detect Mouse
Store dynamic values from your mouse and create a parallax effect
12:02
14
Sensors and Receive
Use Tilt to detect the angle on your device and Send & Receive values
12:47
Meet the instructor
We all try to be consistent with our way of teaching step-by-step, providing source files and prioritizing design in our courses.
Meng To
I design, code and write
Meng To is the author of Design+Code. Meng started off his career as a self-taught designer from Montreal and eventually traveled around the world for 2 years as his US VISA was denied. During his travels, he wrote a book which now has 35,000 readers.
40 courses - 187 hours

Master AI Prompting for Stunning UI
Learn how to leverage AI tools like Aura for creating beautiful designs, working with templates, and experimenting with advanced prompts. A concise guide for designers and developers to level up their skills.
3 hrs

Build SwiftUI apps for iOS 18 with Cursor and Xcode
In this course, we'll explore the exciting new features of SwiftUI 6 and Xcode 16 for building iOS 18 apps. From mesh gradients and text animations to ripple effects, you'll learn how to create polished, highly custom apps using the latest workflows. We'll also dive into using Cursor and Claude AI for AI-driven coding, helping you start strong and customize your apps.
5 hrs

Create your Dream Apps with Cursor and Claude AI
Learn to build your dream web apps from the ground up using Cursor, Claude AI, and a suite of powerful AI tools. This course covers everything you need, including React for frontend development, Firebase for backend integration, and Stripe for handling payments. You’ll also dive into advanced AI tools like Claude Artifacts, Galileo AI, v0.dev for UI, Ideogram for design generation, and Cursor Composer for full-scale development.
6 hrs

Build a React Site from Figma to Codux
In this course, you'll learn to build a website from scratch using Codux, starting with a Figma template. You’ll master responsive design, collaborate with developers on a real React project, export CSS from Figma using Locofy, set up breakpoints with media queries, add CSS animations, improve SEO, create multiple pages with React Router, and publish your site. By following best practices, you’ll bridge design and development, improve your web design skills.
2 hrs

Create 3D UI for iOS and visionOS in Spline
Comprehensive 3D Design Course: From Basics to Advanced Techniques for iOS and visionOS using SwiftUI
3 hrs

Master No-Code Web Design with Framer
In this free Framer course, you'll learn to create modern, user-friendly interfaces. Start with dark mode and glass designs, then move from Figma to Framer, using vectors and auto layout for responsive websites. Add animations, interactive buttons, and custom components with code. Finally, you'll craft a design system suitable for teamwork or solo projects, all in a straightforward and practical approach.
4 hrs

Build SwiftUI Apps for iOS 17
In this course, we’ll be exploring the fresh and exciting features of SwiftUI 5! As we craft a variety of iOS apps from the ground up, we'll delve deep into the treasure trove that is SwiftUI's user interface, interactions, and animations.
4 hrs

Build Beautiful Apps with GPT-4 and Midjourney
Design and develop apps using GPT-4 and Midjourney with prompts for SwiftUI, React, CSS, app concepts, icons, and copywriting
4 hrs

Build SwiftUI apps for iOS 16
Create animated and interactive apps using new iOS 16 techniques using SwiftUI 4 and Xcode 14
5 hrs

Build a 3D Site Without Code with Framer
Design and publish a responsive site with 3D animation without writing a single line of code
3 hrs

Create 3D Site with Spline and React
Design and code a landing page with an interactive 3D asset using Spline and CodeSandbox
1 hrs

Build an Animated App with Rive and SwiftUI
Design and code an iOS app with Rive animated assets, icon animations, custom layouts and interactions
3 hrs

Build a SwiftUI app for iOS 15 Part 3
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
4 hrs

Build a SwiftUI app for iOS 15 Part 2
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
3 hrs

Build a SwiftUI app for iOS 15
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
4 hrs

React Livestreams
Learn how we can use React Hooks to build web apps using libraries, tools, apis and frameworks
4 hrs

Design Founder Livestreams
A journey on how we built DesignCode covering product design, management, analytics, revenue and a good dose of learning from our successes and failures
2 hrs

SwiftUI Advanced Handbook
An extensive series of tutorials covering advanced topics related to SwiftUI, with a main focus on backend and logic to take your SwiftUI skills to the next level
4 hrs

iOS Design Handbook
A complete guide to designing for iOS 14 with videos, examples and design files
2 hrs

SwiftUI Handbook
A comprehensive series of tutorials covering Xcode, SwiftUI and all the layout and development techniques
7 hrs

Build a web app with React Hooks
Learn how we built the new Design+Code site with React Hooks using Gatsby, Netlify, and advanced CSS techniques with Styled Components.
4 hrs

UI Design Handbook
A comprehensive guide to the best tips and tricks for UI design. Free tutorials for learning user interface design.
2 hrs

Figma Handbook
A comprehensive guide to the best tips and tricks in Figma
6 hrs

SwiftUI for iOS 14
Build a multi-platform app from scratch using the new techniques in iOS 14. We'll use the Sidebar and Lazy Grids to make the layout adaptive for iOS, iPadOS, macOS Big Sur and we'll learn the new Matched Geometry Effect to create beautiful transitions between screens without the complexity. This course is beginner-friendly and is taught step-by-step in a video format.
3 hrs

SwiftUI Livestreams
This is a compilation of the SwiftUI live streams hosted by Meng. Over there he talks and teaches how to use design systems, typography, navigation, iOS 14 Design, prototyping, animation and Developer Handoff.
19 hrs

UI Design Livestreams
This is a compilation of the UI live streams hosted by Meng. Over there he talks and teaches how to use design systems, typography, navigation, iOS 14 Design, prototyping, animation and Developer Handoff.
26 hrs

UI Design for Developers
In this course we'll learn how to use design systems, set up break points, typography, spacing, navigation, size rules for adapting to the iPad, mobile and web versions, and different techniques that translate well from design to code.
3 hrs

Build an app with SwiftUI Part 3
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

Build an app with SwiftUI Part 2
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

Build a full site in Webflow
Webflow is a design tool that can build production-ready experiences without code. You can implement CSS-driven adaptive layouts, build complex interactions and deploy all in one tool. Webflow also comes with a built-in content management system (CMS) and Ecommerce for creating a purchase experience without the need of third-party tools.
3 hrs

Advanced Prototyping in ProtoPie
ProtoPie is a cross-platform prototyping tool that creates prototypes nearly as powerful as those made with code, with half of the efforts, and zero code. It's perfect for designers who want to quickly experiment with advanced interactions using variables, conditions, sensors and more.
3 hrs

Build an app with SwiftUI Part 1
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

React Native for Designers Part 2
React Native is a popular Javascript framework that builds on top of React by using native components to create a real mobile app indistinguishable from one made using Xcode or Android Studio. The main difference with native development is that you get to use CSS, hot-reload, Javascript and other familiar techniques that the Web has grown over the past decades. Most importantly, you're building for both iOS and Android using the same codebase.
3 hrs

React Native for Designers
React Native is a popular Javascript framework that builds on top of React by using native components to create a real mobile app indistinguishable from one made using Xcode or Android Studio. The main difference with native development is that you get to use CSS, hot-reload, Javascript and other familiar techniques that the Web has grown over the past decades. Most importantly, you're building for both iOS and Android using the same codebase.
5 hrs

Design System in Figma
Learn how to use and design a collaborative and powerful design system in Figma. Design Systems provide a shared library of reusable components and guidelines and that will let you build products much faster
3 hrs

React for Designers
Learn how to build a modern site using React and the most efficient libraries to get your site/product online. Get familiar with Grid CSS, animations, interactions, dynamic data with Contentful and deploying your site with Netlify.
3 hrs

Swift Advanced
Learn Swift a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV and Apple Watch
9 hrs

Learn Swift
Learn Swift a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV and Apple Watch
4 hrs

Learn Sketch
Learn Sketch a design tool entirely vector-based and focused on user interface design
5 hrs

Learn iOS 11 Design
Learn colors, typography and layout for iOS 8
1 hrs