<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title>Corona Docs: API > Types > ScrollViewWidget > scrollToPosition</title>
  <meta name="revised" content="26-Nov-2013" />
  <meta name="description" content="Whether you're new to Corona or want to take your app to the next level, we've got a wealth of resources for you including extensive documentation, API reference, sample code, and videos.  API > Types > ScrollViewWidget > scrollToPosition" />
  <style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #40a070; }
code > span.fl { color: #40a070; }
code > span.ch { color: #4070a0; }
code > span.st { color: #4070a0; }
code > span.co { color: #60a0b0; font-style: italic; }
code > span.ot { color: #007020; }
code > span.al { color: #ff0000; font-weight: bold; }
code > span.fu { color: #06287e; }
code > span.er { color: #ff0000; font-weight: bold; }
  </style>
  <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
<script src="//www.coronalabs.com/wp-content/themes/corona-labs/js/docs.js"></script>
</head>
<body>
<div class="header"></div>
<div class="title">
	<span class="titleimg" onclick="window.location='http://docs.coronalabs.com/'"></span>
	<div id="nav">
		<ul>
<li><a href="../../index.html">SDK APIs</a></li>
<li><a href="../../../native/index.html">Enterprise APIs</a></li>
<li><a href="../../../plugin/index.html">Plugins</a></li>
<li><a href="../../../guide/index.html">Guides</a></li>
<li><a href="http://www.coronalabs.com/resources/tutorials/">Tutorials</a></li>
</ul>


		<div id="resources-link"><a href="http://www.coronalabs.com/resources/">Corona Resources</a> &#9657;</div>
	</div>
</div>

<div class="SearchBar">
  <form action="http://www.google.com/cse" id="cse-search-box">
  <input type="hidden" name="cx" value="009283852522218786394:g40gqt2m6rq" />
  <input type="hidden" name="ie" value="UTF-8" />
  <input type="text" name="q" id="q" autocomplete="off" size="40" style="width:150px;float:left" />
  <input type="submit" name="sa" value="Search" style="float:right; font-size: 13px;" />
  </form>
</div>
<div id="TOC">
<ul>
<li><a href="#objectscrolltoposition">object:scrollToPosition()</a><ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#syntax">Syntax</a><ul>
<li><a href="#x-optional">x <sub><sup>(optional)</sup></sub></a></li>
<li><a href="#y-optional">y <sub><sup>(optional)</sup></sub></a></li>
<li><a href="#time-optional">time <sub><sup>(optional)</sup></sub></a></li>
<li><a href="#oncomplete-optional">onComplete <sub><sup>(optional)</sup></sub></a></li>
</ul></li>
<li><a href="#example">Example</a></li>
</ul></li>
</ul>
</div>
<div id="breadcrumb">
<a href="http://docs.coronalabs.com">Ξ</a>  ▸  <a href="../../index.html">API</a>  ▸  <a href="../index.html">Types</a>  ▸  <a href="index.html">ScrollViewWidget</a>  ▸  <a href="scrollToPosition.html">scrollToPosition</a>
</div>
<div class="section level1" id="objectscrolltoposition">
<h1><a href="#TOC">object:scrollToPosition()</a></h1>
<blockquote>
<table>
<tbody>
<tr class="odd">
<td align="left"><strong>Type</strong></td>
<td align="left"><a href="../Function.html">Function</a></td>
</tr>
<tr class="even">
<td align="left"><strong>Library</strong></td>
<td align="left"><a href="../../library/widget/index.html">widget.*</a></td>
</tr>
<tr class="odd">
<td align="left"><strong>Revision</strong></td>
<td align="left"><a href="http://coronalabs.com/links/docs/current-corona-sdk">Current Public Release (2013.2076)</a></td>
</tr>
<tr class="even">
<td align="left"><strong>Keywords</strong></td>
<td align="left">widget, scrollview, scrollbox, scrolling content</td>
</tr>
<tr class="odd">
<td align="left"><strong>See also</strong></td>
<td align="left"><a href="../../library/widget/newScrollView.html">widget.newScrollView()</a></td>
</tr>
</tbody>
</table>
</blockquote>
<div class="section level2" id="overview">
<h2><a href="#TOC">Overview</a></h2>
<p>Makes a <a href="../../library/widget/newScrollView.html">ScrollView</a> scroll to a specific <strong>x</strong> or <strong>y</strong> position.</p>
</div>
<div class="section level2" id="syntax">
<h2><a href="#TOC">Syntax</a></h2>
<pre><code>object:scrollToPosition( options )</code></pre>
<p>This function takes a single argument, <code>options</code>, which is a table that accepts the following parameters:</p>
<div class="section level5" id="x-optional">
<h5><a href="#TOC">x <sub><sup>(optional)</sup></sub></a></h5>
<p><em><a href="../Number.html">Number</a>.</em> The <strong>x</strong> position to scroll to. If you only want to scroll vertically, you should omit this parameter.</p>
</div>
<div class="section level5" id="y-optional">
<h5><a href="#TOC">y <sub><sup>(optional)</sup></sub></a></h5>
<p><em><a href="../Number.html">Number</a>.</em> The <strong>y</strong> position to scroll to. If you only want to scroll horizontally, you should omit this parameter.</p>
</div>
<div class="section level5" id="time-optional">
<h5><a href="#TOC">time <sub><sup>(optional)</sup></sub></a></h5>
<p><em><a href="../Number.html">Number</a>.</em> Time in milliseconds to scroll to the specified coordinate(s). For an instantaneous effect (no transition), set this to <code>0</code>. Default is <code>400</code>.</p>
</div>
<div class="section level5" id="oncomplete-optional">
<h5><a href="#TOC">onComplete <sub><sup>(optional)</sup></sub></a></h5>
<p><em><a href="../Function.html">Function</a>.</em> An optional function that will be called when the scroll completes.</p>
</div>
</div>
<div class="section level2" id="example">
<h2><a href="#TOC">Example</a></h2>
<pre class="sourceCode lua"><code class="sourceCode lua"><span class="kw">local</span> <span class="kw">function</span> onScrollComplete<span class="ot">()</span>
    <span class="fu">print</span><span class="ot">(</span> <span class="st">&quot;Scroll complete!&quot;</span> <span class="ot">)</span>
<span class="kw">end</span>

<span class="kw">scrollView</span>:<span class="kw">scrollToPosition</span>
<span class="ot">{</span>
    <span class="kw">x</span> <span class="ot">=</span> <span class="dv">100</span>,
    <span class="kw">y</span> <span class="ot">=</span> <span class="ot">-</span><span class="dv">100</span>,
    <span class="kw">time</span> <span class="ot">=</span> <span class="dv">800</span>,
    <span class="kw">onComplete</span> <span class="ot">=</span> <span class="kw">onScrollComplete</span>
<span class="ot">}</span></code></pre>
<div id="footer">
<p style="font-size: 13px">
© 2013 Corona Labs Inc. All Rights Reserved. (Last updated: 26-Nov-2013)
</p>

<br />
<p>
<strong>Help us help you! Give us feedback on this page:</strong>
</p>

<ul>
<li>
<a href="https://coronalabs.wufoo.com/forms/z7p9w5/def/field3=api.type.ScrollViewWidget.scrollToPosition&field4=Current+Public+Release+%282013%2E2076%29" target="_blank">Love it</a>
</li>

<li>
<a href="https://coronalabs.wufoo.com/forms/z7p9m3/def/field103=api.type.ScrollViewWidget.scrollToPosition&field104=Current+Public+Release+%282013%2E2076%29" target="_blank">Like it, but...</a>
</li>

<li>
<a href="https://coronalabs.wufoo.com/forms/z7p8x1/def/field103=api.type.ScrollViewWidget.scrollToPosition&field104=Current+Public+Release+%282013%2E2076%29" target="_blank">Hate it</a>
</li>
</ul>
</div>

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































</div>
</div>

</body>
</html>