On Feb 20, 2013, at 2:25 AM, Ben Rubinstein wrote:
> On 11/02/2013 18:13, Devin Asay wrote:
>> I'd recommend following Elanor's excellent native scroller tutorial in the
>> latest RevUP newsletter for your list. Once you've wrapped your head around
>> mobile-native controls I think you'll see that they're not difficult, and
>> they go a long way to taking the "clunk" out of your mobile apps.
>>
>> http://www.runrev.com/newsletter/february/issue148/newsletter4.php
>
> Thanks Devin (and Elanor), and what a timely article! That certainly gets me
> most of the way there.
>
> I noticed that on Elanor's sample stack, although the field scrolls nicely
> with inertia, and a bounce-back at the bottom, there's no bounce-back at the
> top. Is this a known limitation?
>
No, you can build bounce in at the top, too.
Here's a script from a card that has a native scrolling field, and it bounces
on both ends. I seem to remember that I had to build in some blank space in the
enclosing group (or was it in the field itself?) to allow for bounce.
local sScrollerID
on preOpenCard
initCard
end preOpenCard
on closeCard
if the environment is "mobile" then
# delete the control before leaving the card
iphoneControlDelete sScrollerID
end if
end closeCard
on initCard
set the height of fld "longtext" to the formattedHeight of fld "longtext"
set the vScroll of group "textGrp" to 0 # scroll to top of text to begin
with
if the environment is "mobile" then
set the layerMode of group "textGrp" to "scrolling"
set the vScrollbar of group "textGrp" to false
set the unboundedVScroll of group "textGrp" to true # allows
out-of-bounds-scrolling
iphoneControlCreate "scroller", "textScroller"
put the result into sScrollerID
put the rect of group "textGrp" into tScrollerRect
put the rect of fld "longText" into tContentRect
# set various properties of the scroller
iphoneControlSet "textScroller", "rect", tScrollerRect # the size of
the scroll area
iphoneControlSet "textScroller", "contentRect", tContentRect # the size
of the scrolled content
iphoneControlSet "textScroller", "visible", true
iphoneControlSet "textScroller", "canBounce", "true"
iphoneControlSet "textScroller", "scrollingEnabled", "true"
iphoneControlSet "textScroller", "indicatorStyle", "black"
iphoneControlSet "textScroller", "vIndicator", "true"
iphoneControlSet "textScroller", "pagingEnabled", "false"
iphoneControlSet sScrollerID, "vScroll", "0"
else
set the vScrollbar of group "textGrp" to true
end if
end initCard
on scrollerDidScroll pOffsetX, pOffsetY
-- Set the scroll values of the group based on feedback from the scroller
-- notice that we can just use the values directly and because out-of-bounds
-- scrolling is enabled for the group, the bounce effect needs no extra
-- code.
lock screen
set the vScroll of group "textGrp" to pOffsetY
unlock screen
end scrollerDidScroll
HTH
Devin
Devin Asay
Office of Digital Humanities
Brigham Young University
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode