Code Monkey home page Code Monkey logo

Comments (4)

evnaz avatar evnaz commented on July 22, 2024

if don't need physical effect, you don't need to use UIDynamic. Use uiview.animateWithDuration function to change position of the side menu container in the toggleMenu function.

from enswiftsidemenu.

caravaneer404 avatar caravaneer404 commented on July 22, 2024

Yeah, sound simple, but cant get it. Can you help me to remove bounce using UIDynamic?

As i know, all magic is here:

private func toggleMenu (shouldOpen: Bool) {

    animator.removeAllBehaviors()
    isMenuOpen = shouldOpen
    let gravityDirectionX: CGFloat = (shouldOpen) ? 0.5 : -0.5;
    let pushMagnitude: CGFloat = (shouldOpen) ? 60.0 : -60.0;
    let boundaryPointX: CGFloat = (shouldOpen) ? menuWidth : -menuWidth-1.0;

    let gravityBehavior = UIGravityBehavior(items: [sideMenuContainerView])
    gravityBehavior.gravityDirection = CGVectorMake(gravityDirectionX, 0.0)
    animator.addBehavior(gravityBehavior)

    let collisionBehavior = UICollisionBehavior(items: [sideMenuContainerView])
    collisionBehavior.addBoundaryWithIdentifier("menuBoundary", fromPoint: CGPointMake(boundaryPointX, 20.0),
        toPoint: CGPointMake(boundaryPointX, sourceView.frame.size.height))
    animator.addBehavior(collisionBehavior)

    let pushBehavior = UIPushBehavior(items: [sideMenuContainerView], mode: UIPushBehaviorMode.Instantaneous)
    pushBehavior.magnitude = pushMagnitude
    animator.addBehavior(pushBehavior)

    let menuViewBehavior = UIDynamicItemBehavior(items: [sideMenuContainerView])
    menuViewBehavior.elasticity = 0.3
    animator.addBehavior(menuViewBehavior)
}

from enswiftsidemenu.

evnaz avatar evnaz commented on July 22, 2024

There is no need to use the UIDynamic framework

private func toggleMenu (shouldOpen: Bool) {
        isMenuOpen = shouldOpen

        let destFrame = CGRectMake((shouldOpen) ? 0 : -menuWidth, 0, menuWidth, sideMenuContainerView.frame.size.height)
        UIView.animateWithDuration(0.4, animations: { () -> Void in
            self.sideMenuContainerView.frame = destFrame
        })
}

from enswiftsidemenu.

caravaneer404 avatar caravaneer404 commented on July 22, 2024

Man, i called THIS "REAL SUPPORT!".
Thank you for so fast answer! Hope your advice will be helpful for other people!

from enswiftsidemenu.

Related Issues (20)

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.