Peek and Pop with backwards-compatibility

Related tags

Gesture PeekPop
Overview

PeekPop - backwards-compatible peek and pop in Swift

Build Status Version Carthage compatible

PeekPop

Peek and Pop is a great new iOS feature introduced with iPhone 6S and 6S+ that allows you to easily preview content using 3D touch.

Sadly, almost 60% of iOS users are on older devices.

PeekPop is a Swift framework that brings backwards-compatibility to Peek and Pop.

Features

          |  Features

--------------------------|------------------------------------------------------------ ๐ŸŒŸ | Uses Apple's beautiful peek and pop interaction for devices with 3D touch. ๐Ÿ‘† | Custom Pressure-sensitive tap recognition for older devices. ๐Ÿ’— | Faithful recreation of the peek and pop animation on older devices. ๐Ÿ“ฑ | Almost identical API to Apple's. 8๏ธโƒฃ | Runs on all iOS8+ devices.

Missing features:

  • Support for peek and pop preview actions in devices that don't have 3D touch.

Usage

Import PeekPop at the top of the Swift file.

import PeekPop

Create a PeekPop object, register your view controller for handling the peek and specify the source view. You will also need to declare that your view controller will conform to the PeekPopPreviewingDelegate protocol.

class MyViewController: UIViewController, PeekPopPreviewingDelegate {
    
    var peekPop: PeekPop?
        
    override func viewDidLoad() {
        peekPop = PeekPop(viewController: self)
        peekPop?.registerForPreviewingWithDelegate(self, sourceView: collectionView)
    }

PeekPopPreviewingDelegate requires implementing two simple functions. You will need to tell it what view controller to present for peeking purposes with:

    func previewingContext(_ previewingContext: PreviewingContext, viewControllerForLocation location: CGPoint) -> UIViewController?

...and you will need to tell it how to commit the preview view controller at the end of the transition with:

    func previewingContext(_ previewingContext: PreviewingContext, commitViewController viewControllerToCommit: UIViewController)

How does it work?

In devices without 3D touch, PeekPop recognizes pressure on the screen by monitoring significant changes in UITouch's majorRadius value.

It assumes that by pressing harder on your iPhone, more of the surface area of your finger is in contact with the screen. This is true in the majority of cases.

Setting up with CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
pod 'PeekPop', '~> 1.0'

Setting up with Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate PeekPop into your Xcode project using Carthage, specify it in your Cartfile:

github "marmelroy/PeekPop"

Inspiration

Comments
  • Retain cycle

    Retain cycle

    There is a retain cycle that avoids to release the memory of the view controller using the PeekPop. The references to view controller and delegates inside the library should be weak.

    opened by MarcosMunoz 3
  • Not working on scroll

    Not working on scroll

    It works only on first scroll frame, on invisible content not working. Even after scroll, first frame freezes.

    In sample app, if change column to 1 you can see the results.

    bug 
    opened by iAlirezaKML 3
  • Using Kingfisher and peek doesn't load image

    Using Kingfisher and peek doesn't load image

    Im using Kingfisher to download the images, and Im trying to show the a picture on peek mode, but it seams the view controller is going to be shown a screenshot is loaded or something, because the code gets to where it downloads, the callback is called when completed, but the actual Image is not shown

    opened by davidlondono 2
  • A simple UIAlertActionSheet should do the job. I think?

    A simple UIAlertActionSheet should do the job. I think?

    Implement a swipe recogniser (.Up) and check for the location in TouchesMoved Method. We need the location movement about the Y axis so, let's say it the user moves the view 20 points upwards and the swipe direction being up while peeking, bring in an alert view in the action sheet style displaying the options needed. My implementation might be wrong but do let me know.

    opened by Dershowitz011 2
  • Fix demo gif not displayed

    Fix demo gif not displayed

    The current demo gif image on the README cannot be displayed. This PR fixes the issue by moving the image to GitHub itself.

    Note: The image was uploaded to GitHub by creating a new issue on this repo, then drag the image into the page and copy the generated link, then cancel the issue.

    opened by T-Pham 1
  • Fixing objects immediately getting de-initialized

    Fixing objects immediately getting de-initialized

    Sorry about this: my retain cycle fix was causing the objects necessary to have PeekPop work to get de-initialized immediately. I didn't catch this in testing as I didn't clean the project and recompile from scratch in between me setting up my fork and submitting the pull request. Once I cleaned the project and tried to compile it again, it stopped working.

    I just checked on both an device with 3D Touch and one without, and this fix makes everything work correctly on both. This should also still fix the retain cycle issue.

    Once again, extremely sorry about that, I should have tested more thoroughly.

    opened by MrAdamBoyd 1
  • Cancel touches when touch moved in .Possible state

    Cancel touches when touch moved in .Possible state

    Cancel touches when finger moved before delayedFirstTouch. Without this code there was a posibility of valid touch (through isTouchValid) on larger views. Especially painful on tableViews and collectionViews

    opened by hansstefan 1
  • Consider using UIVisualEffectView with UIBlurEffect

    Consider using UIVisualEffectView with UIBlurEffect

    Currently producing blur screenshots takes about 0.20 second on iphone 5s, and this time is added every time the peekPopPossible method is invoked. Using UIVisualEffectView takes no time to generate, which makes the peekPop gesture much faster.

    A plus is that all animations in the background are still visible (and blurred). The downside is that you cannot control blur radius, but this is only a visual downside.

    opened by hansstefan 1
  • Fix Podfile, fix warnings after using

    Fix Podfile, fix warnings after using "pod install" command and add missing "super.viewDidLoad()" method in "Sample" demo project

    A command pod install should work properly and it will not return warnings:

    [!] The Sample [Debug] target overrides the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting defined in `Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig'. This can lead to problems with the CocoaPods installation

    [!] The Sample [Release] target overrides the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting defined in `Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig'. This can lead to problems with the CocoaPods installation

    opened by albinekcom 1
  • Update to Swift 3.0, changed screenshot to viewController and lower pressure requirements

    Update to Swift 3.0, changed screenshot to viewController and lower pressure requirements

    Hi, I would like to show you some changes in code. I was working with your library and it's fantastic, but also have some drawback.

    I implemented showing viewController instead of view's screenshot to let me show viewController and it's loading action. Without this I had barely few things loaded then.

    I changed the name of delegate method to suit Swift API guideline.

    I saw that in normal cases the gesture you have to make to call commit action is like lying your finger on the screen, so I wanted to lower this requirement and make magic numbers smaller.

    It would be nice if you could answer my questions somehow. :)

    Great job ๐Ÿ‘

    opened by piotrtorczynski 0
  • Use PeekPop in Objective C project with bridging header

    Use PeekPop in Objective C project with bridging header

    @marmelroy How to use PeekPop swift file in Objective C project ?

    I used swift library with bridging header in my objective c project but there seems to a problem with source view registration for 3D Touch.

    When i converted this file i found this method under ForceTouchDelegate

    • (void)registerFor3DTouch:(UIView * _Nonnull)sourceView viewController:(UIViewController * _Nonnull)viewController;

    Now i do not know how to use this method to register source view for 3D Touch.

    opened by imsrc21 0
  • Incorrect viewController bounds

    Incorrect viewController bounds

    Awesome framework btw!

    Peek shows viewController with UIScreen bounds instead of PeekPopView's bounds. So what I end up with is the clipping of the my actual viewController's view (and not the whole view itself).

    Works well on a 6s though.

    opened by benaneesh 0
Releases(1.0.0)
Owner
Roy Marmelstein
Ya tu sabes.
Roy Marmelstein
The easiest way to show off your iOS taps and gestures for demos and videos.

It's ShowTime ?? Installation Swift Package Manager Cocoapods Manual Usage How it works Useful info Author License ShowTime is the simplest and best w

Kane Cheshire 459 Dec 27, 2022
Drag and drop between your apps in split view mode on iOS 9

SplitViewDragAndDrop Easily add drag and drop to pass data between your apps Setup Add pod 'SplitViewDragAndDrop' to your Podfile or copy the "SplitVi

Mario Iannotta 324 Nov 22, 2022
JustPeek is an iOS Library that adds support for Force Touch-like Peek and Pop interactions on devices that do not natively support this kind of interaction.

JustPeek Warning: This library is not supported anymore by Just Eat. JustPeek is an iOS Library that adds support for Force Touch-like Peek and Pop in

Just Eat 68 Apr 4, 2021
PeekView supports peek, pop and preview actions for iOS devices without 3D Touch capibility

PeekView When implementing peek, pop and preview actions with 3D Touch, you may want to support such features for users accessing your app from older

Huong Do 123 Mar 25, 2022
ExpandingCollection is an animated material design UI card peek/pop controller.

EXPANDING COLLECTION An animated material design UI card peek/pop controller We specialize in the designing and coding of custom UI for Mobile Apps an

Ramotion 5.5k Jan 6, 2023
SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader

SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader, follow the livestream tutorial by MengTo.

Terry Kuo 4 Jun 10, 2022
Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

Peter Larson 17 Jun 27, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP.

MailCore 2: Introduction MailCore 2 provides a simple and asynchronous Objective-C API to work with the e-mail protocols IMAP, POP and SMTP. The API h

MailCore 2.5k Jan 1, 2023
AlertView A pop-up framework, Can be simple and convenient to join your project.

RAlertView AlertView A pop-up framework, Can be simple and convenient to join your project. Warning content Installation Depend on the project Masonry

ๆœ่€€่พ‰ 71 Aug 12, 2022
Interactive notification pop-over (aka "Toast) modeled after the iOS AirPods and Apple Pencil indicator.

Interactive notification pop-over (aka "Toast) modeled after the iOS AirPods and Apple Pencil indicator. Installation The recommended way is to use Co

Philip Kluz 108 Nov 11, 2022
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features โœจ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

Kingiol 154 Dec 3, 2022
Pop-up based view(e.g. alert sheet), can be easily customized.

MMPopupView ไธญๆ–‡ไป‹็ป A basic Pop-Up Kit allows you to easily create Pop-Up view. You can focus on the only view you want to show. Besides, it comes with 2

ralph li 2.1k Jan 3, 2023
RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP

RadialMenu Looking for help? For $150/hr I'll help with your RadialMenu problems including integrating it into your project. Email [email protected] t

Brad Jasper 297 Nov 27, 2022
PopMenu is pop animation menu inspired by Sina weibo / NetEase app.

PopMenu PopMenu is pop animation menu inspired by Sina weibo / NetEase app. Screenshots Installation CocoaPods With CocoaPods, add this line to your P

ๆ›พๅฎชๅŽ 898 Nov 14, 2022
A UINavigationController's category to enable fullscreen pop gesture with iOS7+ system style.

FDFullscreenPopGesture An UINavigationController's category to enable fullscreen pop gesture in an iOS7+ system style with AOP. Overview ่ฟ™ไธชๆ‰ฉๅฑ•ๆฅ่‡ช @J_้›จ ๅŒ

null 5.9k Dec 28, 2022
Reusable iOS's behavior drag or swipe to pop ViewController

DLSwipeToPopController Reusable iOS's behavior to pop ViewController base on SwipeRightToPopController: Swipe from Right to Left to pop ViewController

Le Ngoc Duy 1 Sep 17, 2022
A simple Image full screen pop up

CLImageViewPopup Description A simple UIImageView for easy fullscreen image pop up. No matter where your UIImageView may be. Image pops up from where

Vineeth Vijayan 36 Apr 29, 2021
ElongationPreview is an elegant UI push-pop style view controller

ElongationPreview is an elegant UI push-pop style view controller

Ramotion 886 Dec 19, 2022
Facebook's Pop Framework, By Examples

Facebook's Pop Framework, By Examples --- This project is a tutorial (Check tutorial here) for how to use Pop framework by Facebook. Its very easy and

Hossam Ghareeb 183 Aug 1, 2022