You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using iScroll the calculation of the scroll position was actually
wrong, because instead of really scrolling the container, iScroll moves
the content element.
To fix this a new method was added to the controller, that allows for
custom functions for the scroll position calculation.
When adding iScroll users should now define a function to calculate the
correct scroll position.
Example:
controller.scrollPos(function () {
return -myScroll.y;
});
I also updated the main demo page to be mobile compatible.
<p><strong>Get</strong> or <strong>Set</strong> the current scrollPosition.<br>Watch out: this will permanently overwrite the controller's scrollPos calculation.<br>If you set it to a number it will always have this value.<br>It usually makes more sense to pass a function, when the scrollPosition calculation is not defined by the containers scrollTop or scrollLeft values.<br>This may be the case for mobile applications using iScroll, as there a child container is moved, instead of actually scrolling the container.<br>Please also mind that your function should return y values for vertical scrolls an x for horizontals.</p>
1382
+
</div>
1383
+
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+
<h5>Parameters:</h5>
1391
+
1392
+
1393
+
<tableclass="params table table-striped">
1394
+
<thead>
1395
+
<tr>
1396
+
1397
+
<th>Name</th>
1398
+
1399
+
1400
+
<th>Type</th>
1401
+
1402
+
1403
+
<th>Argument</th>
1404
+
1405
+
1406
+
1407
+
1408
+
<thclass="last">Description</th>
1409
+
</tr>
1410
+
</thead>
1411
+
1412
+
<tbody>
1413
+
1414
+
1415
+
<tr>
1416
+
1417
+
<tdclass="name"><code>newLoglevel</code></td>
1418
+
1419
+
1420
+
<tdclass="type">
1421
+
1422
+
1423
+
<spanclass="param-type">number</span>
1424
+
|
1425
+
1426
+
<spanclass="param-type">function</span>
1427
+
1428
+
1429
+
1430
+
</td>
1431
+
1432
+
1433
+
<tdclass="attributes">
1434
+
1435
+
<optional><br>
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
</td>
1442
+
1443
+
1444
+
1445
+
1446
+
<tdclass="description last"><p>The new value or function used for the scroll position of the container.</p></td>
<preclass="sunlight-highlight-javascript">// get the current scroll Positionvar scrollPos = controller.scrollPos();// set a new scrollPos calculation functioncontroller.scrollPos(function () { return this.info("vertical") ? -$mychildcontainer.y : -$mychildcontainer.x});</pre>
0 commit comments