Giter VIP home page Giter VIP logo

trendingtechnology / circular-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ramotion/circular-carousel

0.0 1.0 0.0 24.57 MB

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center. - https://github.com/Ramotion/swift-ui-animation-components-and-libraries

License: MIT License

Ruby 1.79% Swift 97.13% Objective-C 1.07%

circular-carousel's Introduction

CAROUSEL

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.


We specialize in the designing and coding of custom UI for Mobile Apps and Websites.

Stay tuned for the latest updates:

๐Ÿ’ก๐Ÿž Inspired by Kevin Gautier shot

CocoaPods CocoaPods Twitter

Donate

Requirements

  • iOS 12.0+
  • Xcode 10.2+
  • Swift 5.0+

Installation

Just add the CircularCarousel directory to your project.

or use CocoaPods with Podfile:

pod 'CircularCarousel'

or just drag and drop the CircularCarousel directory to your project

Usage

  1. Create a custom view that will be used as a carousel item. In this tutorial we will just use a blank UIView.

  2. Create a view controller or container view that handles datasource and delegate responses for the contained Carousel.

	final class ContainerView : UITableViewCell, CircularCarouselDataSource, CircularCarouselDelegate {

	}

2.1) Add a reference to the carousel control and the selection of a delegate and datasource to your Carousel control.

	private weak var _carousel : CircularCarousel!
    @IBOutlet var carousel : CircularCarousel! {
        set {
            _carousel = newValue
            _carousel.delegate = self
            _carousel.dataSource = self
        }
        
        get {
            return _carousel
        }
    }
  1. Implement the DataSource and Delegate functions. Some of the key functions are listed below.

3.1) Datasource

	func numberOfItems(inCarousel carousel: CircularCarousel) -> Int {
        return /* Number of carousel items */
    }
	func carousel(_: CircularCarousel, viewForItemAt indexPath: IndexPath, reuseView view: UIView?) -> UIView {
    	var view = view as? UIVIew

    	if view == nil {
    		view = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
    	}

    	return view
    }
	func startingItemIndex(inCarousel carousel: CircularCarousel) -> Int {
        return /* Insert starting item index */
    }

3.2) Delegate

Select how you want the carousel to operate based on the control variables specified below :

	func carousel<CGFloat>(_ carousel: CircularCarousel, valueForOption option: CircularCarouselOption, withDefaultValue defaultValue: CGFloat) -> CGFloat {
	    switch option {
        case .itemWidth:
            return /* Select item width for carousel */
        /*  Insert one of the following handlers :
			case spacing
			case fadeMin
			case fadeMax
			case fadeRange
			case fadeMinAlpha
			case offsetMultiplier
			case itemWidth
			case scaleMultiplier
			case minScale
			case maxScale
        */
        default:
            return defaultValue
        }
	}

Handle the selection of a particular carousel item :

	func carousel(_ carousel: CircularCarousel, didSelectItemAtIndex index: Int) {
        /* Handle selection of the selected carousel item */
    }

Handle will begin scrolling :

	func carousel(_ carousel: CircularCarousel, willBeginScrollingToIndex index: Int) {

	}

To handle spacing between items depending on their offst from the center :

	func carousel(_ carousel: CircularCarousel, spacingForOffset offset: CGFloat) -> CGFloat {        
        return /* Based on the offset from center, adjust the spacing of the item */
    }

That's it, the Carousel is good to go!

๐Ÿ“„ License

Carousel is released under the MIT license. See LICENSE for details.

This library is a part of a selection of our best UI open-source projects.

If you use the open-source library in your project, please make sure to credit and backlink to www.ramotion.com

๐Ÿ“ฑ Get the Showroom App for iOS to give it a try

Try this UI component and more like this in our iOS app. Contact us if interested.

circular-carousel's People

Contributors

juriv avatar ramotiondev avatar realityworks avatar vladiram 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.