Giter Site home page Giter Site logo

sungeundev / numberscrollanimatedview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexsmet/numberscrollanimatedview

0.0 1.0 0.0 80 KB

View for displaying integer numbers with scroll animation for each digit

License: MIT License

Swift 95.24% Ruby 4.76%

numberscrollanimatedview's Introduction

NumberScrollAnimatedView

Component for displaying string with scroll animation for each numerical symbol. Scrolling directions, animation durations and time offsets can be easily customized.

All random

Usage

let animatedView = NumberScrollAnimatedView()

// Add to superview, configure view constraints etc...

// Customize a view properties like background color, font size and color
animatedView.backgroundColor = UIColor(red: 255/255, green: 47/255, blue: 146/255, alpha: 1)
animatedView.font = UIFont.boldSystemFont(ofSize: 64)
animatedView.textColor = .white

// Set animation properties
animatedView.animationDuration = 5
animatedView.scrollingDirectionRule = { (_, columnIndex) in return (columnIndex % 2) == 0 ? .down : .up }

// Set a value which will be displayed
animatedView.text = "220-548"

// Start animation
animatedView.startAnimation()

Animation parameters

  • animationDuration
  • animationTimeOffsetRule, specifies the offset of the animation start time for each numerical symbol. By default the function return random values from 0 to 1.
  • animationDurationOffsetRule, specifies the change in animation duration for each numerical symbol. By default the function return random values from 0 to 1.
  • scrollingDirectionRule, specifies the animation direction (UP or DOWN) for each numerical symbol. By default the rule return random values.
  • inverseSequenceRule, specifies whether to invert the sequence of numbers or not. By default is 0123456789, with inversion 9876543210

Animation examples

  1. By default. All animation parameters are random.

All random

  1. Scrolling direction is down.
animatedView.scrollingDirectionRule = { (_, _) in return .down }

Scrolling direction is down

  1. Scrolling direction is up, sequence is not inverted, animation duration is the same for all columns.
animatedView.scrollingDirectionRule = { (_, _) in return .up }
animatedView.inverseSequenceRule = { (_, _) in return false }
animatedView.animationDurationOffsetRule = { (_, _) in return 0 }

Scrolling direction is up, sequence don't inverted,  animation duration the same for all columns

Author

Created by Alexander Smetannikov ([email protected])

numberscrollanimatedview's People

Contributors

alexsmet avatar sungeundev avatar

Watchers

 avatar

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.