Giter VIP home page Giter VIP logo

jsswipeablecell's Introduction

JSSwipeableCell

Support CocoaPods SPM

Simple & manually configurable swipe action on UICollectionViewCell.

Installation

Cocoapods

pod 'JSSwipeableCell'

Swift Package Manager

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/wlsdms0122/JSSwipeableCell", from: "1.1.0")
    ],
    targets: [
        .target(
            name: "Your target",
            dependencies: ["JSSwipeableCell"]
        ),
    ]
    ...
)

Usage

You can swipe action just inherit JSSwipeableCollectionViewCell.

class CustomCollectionViewCell: JSSwipeableCollectionViewCell { }

You can only left, right swipe action now. you can add any UIView in swipe action view.

let deleteButton: UIButton = {
    let view = UIButton()
    view.backgroundColor = .red
    view.setTitle("Delete", for: .normal)
    return view
}

init(frame: CGRect) {
    super.init(frame: frame)
    
    // If you use `SnapKit`, set swipe action view like this.
    [deleteButton].forEach { rightActionView.addSubview($0) }
    deleteButton.snp.makeConstraints { make in
        make.edges.equalToSuperview()
        make.width.equalTo(80)
    }
}

Then you can see your cell swipe to left and visible delete button.

Swipe action based on leftActionView and RightActionView's size. So you have to set these view can calculate size.

Additinal Feature

Serve several properties and methods.

// MARK: properties
var speed: Double = 0.3 // Auto swipe animation speed.
var isSwipeThreshold: Bool = true // Swipe can only action view's bounds

// MARK: methods
func willSwipe(able cell: JSSwipeableCollectionViewCell)
func didSwipe(able cell: JSSwipeableCollectionViewCell, translation: CGPoint, direction: Direction)
func endSwipe(able cell: JSSwipeableCollectionViewCell, translation: CGPoint, direction: Direction)

If you want more powerful transition, animation, etc... override these properties and methods.

Demo app should be help you to get more informations.

Contribution

Any ideas, issues, opinions are welcome.

License

JSSwipeableCell is available under the MIT license.

jsswipeablecell's People

Contributors

wlsdms0122 avatar

Stargazers

신명섭 avatar socar-hyodi avatar

Watchers

James Cloos avatar 한석호(MilKyo) avatar  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.