Code Monkey home page Code Monkey logo

flipper's Introduction


Flipper is an animation library for Roblox based around Motors and Goals.

Installation

Rojo

0.6.x+

Add this repository as a submodule into your packages directory. This example assumes the directory is packages.

git submodule add https://github.com/Reselim/Flipper packages/Flipper

0.5.x

Copy the src folder from this repository into your packages directory.

npm (for roblox-ts)

Install the @rbxts/flipper package using npm or yarn.

npm i @rbxts/flipper

Without Rojo

Download the latest .rbxm file from the releases page and drag it into studio.

Usage

With Roact

This example creates a button that shrinks when pressed.

local Example = Roact.Component:extend("Example")

function Example:init()
	self.motor = Flipper.SingleMotor.new(0)

	local binding, setBinding = Roact.createBinding(self.motor:getValue())
	self.binding = binding

	self.motor:onStep(setBinding)
end

function Example:render()
	return Roact.createElement("ImageButton", {
		Size = self.binding:map(function(value)
			return UDim2.new(0, 100, 0, 100):Lerp(UDim2.new(0, 80, 0, 80), value)
		end),
		Position = UDim2.new(0.5, 0, 0.5, 0),
		AnchorPoint = Vector2.new(0.5, 0.5),

		[Roact.Event.MouseButton1Down] = function()
			self.motor:setGoal(Flipper.Spring.new(1, {
				frequency = 5,
				dampingRatio = 1
			}))
		end,

		[Roact.Event.MouseButton1Up] = function()
			self.motor:setGoal(Flipper.Spring.new(0, {
				frequency = 4,
				dampingRatio = 0.75
			}))
		end
	})
end

return Example

Flipper works wonderfully with Roact on its own, but if you plan on using it for a lot of your components, roact-flipper will make that much easier.

Without Roact

Check out the demo script in the test project!

License

Flipper is licensed in full under the MIT license. Note that it contains code from another author, which is also under the MIT license.

flipper's People

Contributors

alihsaas avatar alreadypro avatar murmanox avatar nezuo avatar ok-nick avatar optimisticside avatar osyrisrblx avatar phalanxia avatar reselim avatar vorlias avatar

Forkers

rocky28447

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.