Dance is an open source Swift library from Saoud Rizwan for animations utilizing UIViewPropertyAnimator for creating view animations that can even be scrubbed through using a clean straightforward syntax.

Dance includes functions allowing you to pause, start, reverse, select finished points.

This code snippet shows how to use Dance:

import Dance

class MyViewController: UIViewController {

<pre><code>let circle = UIView()

override func viewDidLoad() {
    super.viewDidLoad()

    circle.dance.animate(duration: 2.0, curve: .easeInOut) {
        $0.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
        $0.center = self.view.center
        $0.backgroundColor = .blue
        // … see ‘Animatable Properties’ for more options
    }.addCompletion { _ in
        self.view.backgroundColor = .green
    }.start(after: 5.0)
}

func pauseAnimation() {
    circle.dance.pause()
}
</code></pre>

}

You can find Dance on Github here.

A great library for animations.

Original article: Dance – Swift Library For Creating Scrubbable View Animations With A Clean Syntax

©2017 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Reference source: iOS App Dev Libraries, Controls, Tutorials, Examples and Tools

Shares in Taiwanese iPhone assembler Foxconn have reached decade-year highs over growing optimism about Apple’s upcoming iPhone 8, due to launch in 2017.

According to a new Bloomberg report, Hon Hai Precision Industry – better known as Foxconn – has gained 29 percent in the last year on high expectations for Apple’s 10th anniversary iPhone, which has helped the company defy a flat mobile market.


Apple, which accounts for half the company’s revenue, played a pivotal role in the stock’s recent buoyancy. The U.S. company this month reported stronger-than-expected iPhone sales during the key holiday quarter.

While the iPhone 7, introduced in September, failed to convince as many existing customers to upgrade as its predecessor, it did attract new smartphone buyers. That bodes well for the iPhone slated for later this year.

Apple is expected to launch a radically redesigned iPhone this year. The phone is believed to include a glass body, wireless charging, and potentially an edge-to-edge OLED display that integrates a front-facing camera with facial recognition and touch sensors for fingerprint identification. Foxconn may also end up assembling upgraded (but standard) 4.7 and 5.5-inch iPhones alongside the redesigned handset.

Investors hope the iPhone 8 line-up will provide a boost to a stalling industry, with Foxconn reportedly grappling with the slowdown. According to an average of analysts’ estimates compiled by Bloomberg, revenue is projected to slip about 3 percent in 2016, and net income will be down 13 percent. However, earnings growth could rebound to 12.2 percent this year.

In addition to the 10th anniversary iPhone boost, Foxconn is said to be considering building a $7 billion display-making facility in the U.S. Japanese company Sharp is reportedly “taking the lead” on the proposed U.S site and has set aside $1.8 billion to developing facilities for making OLED displays – the same technology Apple is expected to adopt in future iPhones.

Apple is expected to introduce the iPhone 8 in the fall, with claims of a launch as early as this summer likely due to reports that Apple could ramp up production early in order to improve yield rates, work out manufacturing issues, and ensure better supplies for a September release.

Related Roundup: iPhone 8 (2017)
Tag: Foxconn

Discuss this article in our forums

Reference source: MacRumors: Mac News and Rumors – All Stories

Say you want an element to be in one state for 9 seconds, and in another state for 1 second, on a loop.

No tweening between the state, just a straight swap.

I was wondering how to go about this other day, and Sarah Drasner showed me that you can use reallllllly short distances between keyframes to move from one state to another. Like 59.999% to 60%. No opportunity to tween there on a normal animation duration like 10 seconds.

See the Pen State Change with Quick Keyframe Change by Chris Coyier (@chriscoyier) on CodePen.

Perhaps a little bit cleaner, you don’t even have to get tricky with the .999 stuff if you use steps, like:

div {
  ...
  animation: color 10s steps(10) infinite both;
}

Single keyframe / Single step changer

That led me to stumble into another super weird CSS thing. You’d think if you used steps(1) that no change at all would occur, right? Since there is only one step? Not true, there is actually 2 steps when you use steps(1), for who-knows-what reasoning. We can use that.

Say we were going for the original premise of this article: one state for 9 seconds, and in another state for 1 second. Like this:

1-1-1-1-1-1-1-1-1-2

You could do:

div {
  ...
  background: orangered;
  animation: color 10s steps(1) infinite both;
}

@keyframes color {
  90% {
    background: teal;
  }
}

That div will only be teal for 1 second! Then switch back to orangered. Change that keyframe to 70% and you’d get:

1-1-1-1-1-1-1-2-2-2

Change it to 10% and you’d get:

1-2-2-2-2-2-2-2-2-2

See the Pen 2efd2dc514da5485073acd6f4b9f3dab by Chris Coyier (@chriscoyier) on CodePen.

Change state and “stay there”

We have a pretty cool trick in hand now for changing state in a timed loop. If you didn’t want the looping part, you could have the animation run once and stay there like:

div {
  ...
  background: orangered;
  animation: color 10s steps(1) forwards;
}

@keyframes color {
  90% {
    background: teal;
  }
}

All we’ve done here is removed the infinite keyword which was making it repeat, and used forwards meaning “when it gets to the end, keep the styles in that final state”. (The both keyword will do that too.)

But how do you swap from one state to another from a user interaction? Even this is possible! Imagine an animation with a super long duration (like, days and days). You could tie a user interaction to jumping around positions (state) within that. Here’s a simple demo of that where the clicking of a link triggers a :target state, which triggers an animation to jump to a position within keyframes that style that state:

See the Pen Keyframe State Changer by Chris Coyier (@chriscoyier) on CodePen.

Just at tricks, folks. We’ll be here all decade.


Swapping State with CSS Keyframes is a post from CSS-Tricks

Reference source: CSS-Tricks