mirror of
https://github.com/averello/Ents.git
synced 2026-10-11 21:49:10 +02:00
28 lines
769 B
Swift
28 lines
769 B
Swift
//
|
|
// NoImplicitAnimationBlock.swift
|
|
// Ents
|
|
//
|
|
// Created by Georges Boumis on 06/09/2016.
|
|
// Copyright © 2016-2019 Georges Boumis.
|
|
// Licensed under MIT (https://github.com/averello/Ents/blob/master/LICENSE)
|
|
//
|
|
|
|
import Foundation
|
|
#if canImport(QuartzCore) && canImport(CoreFoundation)
|
|
import QuartzCore
|
|
import CoreFoundation
|
|
|
|
public func NoImplicitAnimation(_ block: () throws -> Void) rethrows {
|
|
CATransaction.begin(); defer { CATransaction.commit() }
|
|
CATransaction.setDisableActions(true)
|
|
try block()
|
|
}
|
|
|
|
public func ImplicitAnimation(withDuration duration: CFTimeInterval, _ block: () throws -> Void) rethrows {
|
|
CATransaction.begin(); defer { CATransaction.commit() }
|
|
CATransaction.setAnimationDuration(duration)
|
|
try block()
|
|
}
|
|
|
|
#endif
|