Git Product home page Git Product logo

tiltingscrollview's Introduction

TiltingScrollView

UIScrollView extension that scrolls when the user tilts the device.

Usage

  • When your view controller appears on screen (most cases in viewWillAppear or viewDidAppear), call scrollView.setTiltingEnabled(true).
  • If at any point you want to stop the tilt-to-scroll, call scrollView.setTiltingEnabled(false). This will automatically set scrollView.scrollingEnabled = true.
  • You can recalibrate the scroll view at any point by calling scrollView.calibrate(). I recommend adding a button that allows the user to choose to recalibrate in order to redefine the angle at which the scroll view goes up and down.

Public Variables

/// Factor by which the accelerometer data is multiplied to scroll the view. Larger values cause faster scrolling.

public var tiltingFactor: CGFloat = 20

Public Methods

/// Enables or disables the tilting behavior of the scroll view.
/// - true: Tilting the device causes the scroll view to scroll. `scrollingEnabled = false`
/// - false: Tilting the device does nothing. `scrollEnabled = true`

public func setTiltingEnabled(tiltingEnabled: Bool)
/// Resets the internal calculations to use the current angle of the device as the reference point.
/// At the device's current angle, the scroll view will not scroll.

public func calibrate()

Conclusion

If you have any issues or suggestions, please create an issue or a pull request (preferred :). Revisions and improvements are always welcome.

You can contact me on Twitter at @ERDekhayser.

tiltingscrollview's People

Contributors

edekhayser avatar

Stargazers

Paulo Eduardo Correa avatar Instant Flashback avatar Rishabh Kesarwani avatar John Manos avatar Maciej Kuliszkiewicz avatar  avatar Simon Strandgaard avatar Ernest Semerda avatar James Rocco avatar Marvin Nazari avatar pj avatar Mukesh Mandora avatar MohsinAli avatar Soheil avatar Moonlight avatar woshizilong avatar Carabineiro avatar Michael Mellinger avatar Alberto R. avatar  avatar Spyros Zarzonis avatar

Watchers

James Cloos avatar MohsinAli avatar Carabineiro avatar  avatar

tiltingscrollview's Issues

Extension

Is it possible to make this into an extension instead of a subclass so I can use it with a different subclass of UIScrollView?

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.