text: <!DOCTYPE html>
  <html lang="en">
    <head>
      <title>SortFunction Protocol Reference</title>
      <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
      <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
      <meta charset='utf-8'>
      <script src="../js/jquery.min.js" defer></script>
      <script src="../js/jazzy.js" defer></script>
      
    </head>
    <body>
      <a name="//apple_ref/swift/Protocol/SortFunction" class="dashAnchor"></a>
      <a title="SortFunction Protocol Reference"></a>
      <header>
        <div class="content-wrapper">
          <p><a href="../index.html">Spruce Docs</a> (100% documented)</p>
          <p class="header-right"><a href="https://github.com/willowtreeapps/spruce-ios"><img src="../img/gh.png"/>View on GitHub</a></p>
        </div>
      </header>
      <div class="content-wrapper">
        <p id="breadcrumbs">
          <a href="../index.html">Spruce Reference</a>
          <img id="carat" src="../img/carat.png" />
          SortFunction Protocol Reference
        </p>
      </div>
      <div class="content-wrapper">
        <nav class="sidebar">
          <ul class="nav-groups">
            <li class="nav-group-name">
              <a href="../Classes.html">Classes</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Classes/Button.html">Button</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/ViewController.html">ViewController</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Enums.html">Enums</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Enums/Angle.html">Angle</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Corner.html">Corner</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Direction.html">Direction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Distance.html">Distance</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Position.html">Position</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Scale.html">Scale</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/SlideDirection.html">SlideDirection</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/StockAnimation.html">StockAnimation</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/Weight.html">Weight</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Extensions.html">Extensions</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Extensions/CGPoint.html">CGPoint</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/UIView.html">UIView</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Protocols.html">Protocols</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Protocols/Animation.html">Animation</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/CornerSortFunction.html">CornerSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/DirectionSortFunction.html">DirectionSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/DistanceSortFunction.html">DistanceSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/PositionSortFunction.html">PositionSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/SortFunction.html">SortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/View.html">View</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/WeightSortFunction.html">WeightSortFunction</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Structs.html">Structs</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Structs/ContinuousSortFunction.html">ContinuousSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/ContinuousWeightedSortFunction.html">ContinuousWeightedSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/CorneredSortFunction.html">CorneredSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/DefaultSortFunction.html">DefaultSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/InlineSortFunction.html">InlineSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/LinearSortFunction.html">LinearSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/RadialSortFunction.html">RadialSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/RandomSortFunction.html">RandomSortFunction</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/SpringAnimation.html">SpringAnimation</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/Spruce.html">Spruce</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/SprucePoint.html">SprucePoint</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/SpruceUIView.html">SpruceUIView</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/StandardAnimation.html">StandardAnimation</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs.html#/s:V6Spruce9TimedView">TimedView</a>
                </li>
              </ul>
            </li>
          </ul>
        </nav>
        <article class="main-content">
          <section>
            <section class="section">
              <h1>SortFunction</h1>
                <div class="declaration">
                  <div class="language">
                    <pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">SortFunction</span></code></pre>
  
                  </div>
                </div>
              <p>For all the views on the screen, we need to find some way of organizing them so that when we start the animation, each view will know when to start their individual animation. The concept of a <code>SortFunction</code> is just that. Given a view, the subviews of that view are sorted in a way that when animated they resemble the nature of that sort function. There are many different types of sort functions because there are so many ways to sort the subviews that are on the screen. If you don&rsquo;t see a stock one that fits your need, feel free to implement this protocol and use your own custom <code>SortFunction</code> with Spruce.</p>
  
            </section>
            <section class="section task-group-section">
              <div class="task-group">
                <ul>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:FP6Spruce12SortFunction11timeOffsetsFT4viewCSo6UIView_GSaVS_9TimedView_"></a>
                      <a name="//apple_ref/swift/Method/timeOffsets(view:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:FP6Spruce12SortFunction11timeOffsetsFT4viewCSo6UIView_GSaVS_9TimedView_">timeOffsets(view:)</a>
                      </code>
                        <span class="declaration-note">
                          Default implementation
                        </span>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Given a view, view sort the subviews in a way that matches the desired specification of the <code>SortFunction</code>. In an example case, if you wanted a radial sort function then this method would return an array of the subviews such that their time offets would be smaller near the center of the view and grow as they get further from the center point.
  - Note: This method simply calls the <code>timeOffsets(view: UIView, recursiveDepth: Int)</code> with a <code>recursiveDepth</code> of <code>0</code>.</p>
  
                        </div>
                        <h4>Default Implementation</h4>
                        <div class="default_impl abstract">
                          <p>Given a view, view sort the subviews in a way that matches the desired specification of the <code>SortFunction</code>. In an example case, if you wanted a radial sort function then this method would return an array of the subviews such that their time offets would be smaller near the center of the view and grow as they get further from the center point.</p>
  
                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight"><code><span class="kd">func</span> <span class="nf">timeOffsets</span><span class="p">(</span><span class="nv">view</span><span class="p">:</span> <span class="kt">UIView</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt"><a href="../Structs.html#/s:V6Spruce9TimedView">TimedView</a></span><span class="p">]</span></code></pre>
  
                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>view</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>the view whose subviews should be animated. This view should not be included in the returned array</p>
  
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                        <div>
                          <h4>Return Value</h4>
                          <p>an array of <code><a href="../Structs.html#/s:V6Spruce9TimedView">TimedView</a></code>’s which contain references to the view needed to be animated and the time offset for when the animation of that individual view should start relative to the start of the overall animation</p>
  
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:FP6Spruce12SortFunction11timeOffsetsFT4viewCSo6UIView14recursiveDepthSi_GSaVS_9TimedView_"></a>
                      <a name="//apple_ref/swift/Method/timeOffsets(view:recursiveDepth:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:FP6Spruce12SortFunction11timeOffsetsFT4viewCSo6UIView14recursiveDepthSi_GSaVS_9TimedView_">timeOffsets(view:recursiveDepth:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Given a view, view sort the subviews in a way that matches the desired specification of the <code>SortFunction</code>. In an example case, if you wanted a radial sort function then this method would return an array of the subviews such that their time offets would be smaller near the center of the view and grow as they get further from the center point.</p>
  
                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight"><code><span class="kd">func</span> <span class="nf">timeOffsets</span><span class="p">(</span><span class="nv">view</span><span class="p">:</span> <span class="kt">UIView</span><span class="p">,</span> <span class="nv">recursiveDepth</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt"><a href="../Structs.html#/s:V6Spruce9TimedView">TimedView</a></span><span class="p">]</span></code></pre>
  
                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>view</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>the view whose subviews should be animated. This view should not be included in the returned array</p>
  
                                  </div>
                                </td>
                              </tr>
                              <tr>
                                <td>
                                  <code>
                                  <em>recursiveDepth</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>an int describing how deep into the view hiearchy the subview search should go, defaults to 0. A value of 0 is the same as calling the <code>subviews</code> on the actual view itself. Therefore a depth of 1 will be getting the subviews of each of the subviews, etc…</p>
  
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                        <div>
                          <h4>Return Value</h4>
                          <p>an array of <code><a href="../Structs.html#/s:V6Spruce9TimedView">TimedView</a></code>’s which contain references to the view needed to be animated and the time offset for when the animation of that individual view should start relative to the start of the overall animation</p>
  
                        </div>
                      </section>
                    </div>
                  </li>
                </ul>
              </div>
            </section>
          </section>
          <section id="footer">
            <p>&copy; 2017 <a class="link" href="https://willowtreeapps.com" target="_blank" rel="external">WillowTree</a>. All rights reserved. (Last updated: 2017-03-10)</p>
            <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
          </section>
        </article>
      </div>
    </body>
  </div>
  </html>
  