Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
Rounding to the nearest whole number could explain the direction bias.

Sent from my iPhone

> On Jun 28, 2017, at 4:31 PM, jonathandly...@gmail.com wrote:
> 
> Are you saying the down scroll has less momentum?
> 
> I have no idea why it would do that, but you can increase the momentum 
> overall by changing tRemainingDistance/15 to a lower divisor, like 
> tRemainingDistance/10.
> 
> Sent from my iPhone
> 
>> On Jun 28, 2017, at 4:23 PM, Alejandro Tejada via use-livecode 
>>  wrote:
>> 
>> Al
>> _

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Alejandro Tejada via use-livecode
I made this change in the script and now
it reversed the behavior.

Probably everyone interested could test
this script on different mobile devices and
computers to confirm this behavior.

Al

On Wed, Jun 28, 2017 at 4:31 PM,  wrote:

> Are you saying the down scroll has less momentum?
>
> I have no idea why it would do that, but you can increase the momentum
> overall by changing tRemainingDistance/15 to a lower divisor, like
> tRemainingDistance/10.
>
> Sent from my iPhone
>
> > On Jun 28, 2017, at 4:23 PM, Alejandro Tejada via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Al
> > _
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
Are you saying the down scroll has less momentum?

I have no idea why it would do that, but you can increase the momentum overall 
by changing tRemainingDistance/15 to a lower divisor, like 
tRemainingDistance/10.

Sent from my iPhone

> On Jun 28, 2017, at 4:23 PM, Alejandro Tejada via use-livecode 
>  wrote:
> 
> Al
> _

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
Actually - the problem I just mentioned has to do with some different.

Sent from my iPhone

> On Jun 28, 2017, at 4:20 PM, jonathandly...@gmail.com wrote:
> 
> Thanks Scott
> 
> I also found something else. Mousedown stops the momentum scroll, but then 
> one must lift up the finger and start again to do more scrolling.
> 
> That should be fixable, though.
> 
> Sent from my iPhone
> 
>> On Jun 28, 2017, at 3:00 PM, Scott Rossi via use-livecode 
>> <use-livecode@lists.runrev.com> wrote:
>> 
>> Hi Jonathan:
>> 
>> Just doing some simple tests, your script is great.  Thanks for sharing it 
>> on the list.
>> 
>> Two minor improvements I would suggest:
>> 
>> 1) After the mouseUp handler, add a mouseRelease handler to trigger 
>> deceleration/stop when the mouse is released outside of the target control.
>> 
>> on mouseRelease
>>  mouseUp
>> end mouseRelease
>> 
>> 2) In the mouseMove handler, use the built-in parameters provided by the 
>> handler instead of reading the mouseV. Probably not a huge deal in the 
>> scheme of things, but might add a tiny bit more efficiency to the script.
>> 
>> on mouseMove X,Y
>> if allowDrag <> empty then
>>set the vScroll of me to (allowDrag-Y)
>> end if
>> end mouseMove 
>> 
>> Regards,
>> 
>> Scott Rossi 
>> Creative Director 
>> Tactile Media, UX/UI Design 
>> 
>> 
>> 
>>> On Jun 28, 2017, at 9:05 AM, Jonathan Lynch via use-livecode 
>>> <use-livecode@lists.runrev.com> wrote:
>>> 
>>> I just created and tested a momentum scrolling script on my iPhone, and it
>>> appears to work quite well, so I thought I would share it here.
>> 
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Momentum Scrolling Script

2017-06-28 Thread Alejandro Tejada via use-livecode
Really nice script, Jonathan!
Thanks a lot for sharing.

Previously Bernd and many LC Developers
have published similar scripts.

By the way, this script seems to works faster
when users drags upward from Line 20 to Line 1
than dragging downwards from Line 1 to 20

Dragging upwards from Line 20 towards Line 1, always
reach Line 1 (without fail), but dragging downwards
from Line 1 towards Line 20 barely reach Line 15,
(rarely Line 17) but never reach Line 20.

Al
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
Thanks Scott

I also found something else. Mousedown stops the momentum scroll, but then one 
must lift up the finger and start again to do more scrolling.

That should be fixable, though.

Sent from my iPhone

> On Jun 28, 2017, at 3:00 PM, Scott Rossi via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> Hi Jonathan:
> 
> Just doing some simple tests, your script is great.  Thanks for sharing it on 
> the list.
> 
> Two minor improvements I would suggest:
> 
> 1) After the mouseUp handler, add a mouseRelease handler to trigger 
> deceleration/stop when the mouse is released outside of the target control.
> 
> on mouseRelease
>   mouseUp
> end mouseRelease
> 
> 2) In the mouseMove handler, use the built-in parameters provided by the 
> handler instead of reading the mouseV. Probably not a huge deal in the scheme 
> of things, but might add a tiny bit more efficiency to the script.
> 
> on mouseMove X,Y
>  if allowDrag <> empty then
> set the vScroll of me to (allowDrag-Y)
>  end if
> end mouseMove 
> 
> Regards,
> 
> Scott Rossi 
> Creative Director 
> Tactile Media, UX/UI Design 
> 
> 
> 
>> On Jun 28, 2017, at 9:05 AM, Jonathan Lynch via use-livecode 
>> <use-livecode@lists.runrev.com> wrote:
>> 
>> I just created and tested a momentum scrolling script on my iPhone, and it
>> appears to work quite well, so I thought I would share it here.
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Scott Rossi via use-livecode
Hi Jonathan:

Just doing some simple tests, your script is great.  Thanks for sharing it on 
the list.

Two minor improvements I would suggest:

1) After the mouseUp handler, add a mouseRelease handler to trigger 
deceleration/stop when the mouse is released outside of the target control.

on mouseRelease
   mouseUp
end mouseRelease

2) In the mouseMove handler, use the built-in parameters provided by the 
handler instead of reading the mouseV. Probably not a huge deal in the scheme 
of things, but might add a tiny bit more efficiency to the script.

on mouseMove X,Y
  if allowDrag <> empty then
 set the vScroll of me to (allowDrag-Y)
  end if
end mouseMove 

Regards,

Scott Rossi 
Creative Director 
Tactile Media, UX/UI Design 



> On Jun 28, 2017, at 9:05 AM, Jonathan Lynch via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> I just created and tested a momentum scrolling script on my iPhone, and it
> appears to work quite well, so I thought I would share it here.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Tom Glod via use-livecode
nice going to try this out...I had a good scrolling script, but
definitely not momentum based... will give it a shot...thanks.

On Wed, Jun 28, 2017 at 1:04 PM, Jonathan Lynch via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I just realized I had the wrong way of checking to see if scrolling should
> stop. Somehow it still worked, which is kinda weird. Here is the revised
> script, with checking for tCount < 1 rather than tCount > 50
>
> -
>
> Momentum Scrolling Code
>
>
> Local StartDrag
>
> Local AllowDrag
>
> Local StartDragMil
>
> Local CumulativeMomentum
>
>
> on mousedown
>
>focus on nothing
>
>if word 1 of the name of the target = "button" or the isbutton of the
> target = 1 then
>
>   exit mousedown
>
>end if
>
>put (the mouseV)+(the vScroll of me) into AllowDrag
>
>put the milliseconds into StartDragMil
>
>put (the mouseV) into StartDrag
>
>repeat with CM = 1 to 5
>
>   put 0 into CumulativeMomentum[CM]
>
>end repeat
>
>send momentumAccumulate to me in 0 milliseconds
>
> end mousedown
>
>
> on momentumAccumulate
>
>if mouse(1) <> "down" then
>
>   exit momentumAccumulate
>
>end if
>
>
>
>put the milliseconds-StartDragMil into tTimeForLastMove
>
>put (the mouseV) into tCurrentMouseV
>
>put tCurrentMouseV - StartDrag into tLastDistanceCovered
>
>
>
>if tTimeForLastMove = 0 then
>
>   put 1 into tTimeForLastMove
>
>end if
>
>repeat with CM = 5 down to 2
>
>   put CumulativeMomentum[CM-1] into CumulativeMomentum[CM]
>
>end repeat
>
>put (tLastDistanceCovered*10) / tTimeForLastMove into
> CumulativeMomentum[1]
>
>put tCurrentMouseV into StartDrag
>
>put the milliseconds into StartDragMil
>
>send momentumAccumulate to me in 5 milliseconds
>
> end momentumAccumulate
>
>
> on mousemove
>
>if AllowDrag <> empty then
>
>   set the vScroll of me to AllowDrag-(the mouseV)
>
>end if
>
> end mousemove
>
>
> on mouseup
>
>put empty into AllowDrag
>
>put 0 into tCMTotal
>
>Repeat with CM = 1 to 5
>
>   add CumulativeMomentum[CM] to tCMTotal
>
>end Repeat
>
>put tCMTotal/5 into tAverageMomentum
>
>put tAverageMomentum * 30 into tRemainingDistance
>
>doMomentumScrolling tRemainingDistance,50
>
> end mouseup
>
>
> on doMomentumScrolling tRemainingDistance, tCount
>
>if tCount < 1 then
>
>   exit doMomentumScrolling
>
>end if
>
>if mouse(1) is "down" then
>
>   exit doMomentumScrolling
>
>end if
>
>put tRemainingDistance/15 into tDistanceToMove
>
>put the vScroll of me into tVScroll
>
>set the vScroll of me to tVScroll - tDistanceToMove
>
>put tRemainingDistance-tDistanceToMove into tRemainingDistance
>
>put tCount-1 into tCount
>
>send "doMomentumScrolling tRemainingDistance, tCount" to me in 5
> milliseconds
>
> end doMomentumScrolling
>
> On Wed, Jun 28, 2017 at 12:49 PM, Sean Cole (Pi) via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
> > Jonathan,
> > I would also recommend using the var name prefixes as recommended by LC
> in
> > thier Tips for Writing Good Code when sharing publicly. Like this I mean:
> >
> > Local sStartDrag
> > Local sAllowDrag
> > Local sStartDragMil
> > Local sCumulativeMomentum
> >
> > on mousedown
> >focus on nothing
> >if word 1 of the name of the target = "button" or the isbutton of the
> > target = 1 then
> >   exit mousedown
> >end if
> >put (the mouseV)+(the vScroll of me) into sAllowDrag
> >put the milliseconds into sStartDragMil
> >put (the mouseV) into sStartDrag
> >repeat with CM = 1 to 5
> >   put 0 into sCumulativeMomentum[CM]
> >end repeat
> >send momentumAccumulate to me in 0 milliseconds
> > end mousedown
> >
> > on momentumAccumulate
> > local tTimeForLastMove, tCurrentMouseV, tLastDistanceCovered
> >if mouse(1) <> "down" then
> >   exit momentumAccumulate
> >end if
> >put the milliseconds-sStartDragMil into tTimeForLastMove
> >put (the mouseV) into tCurrentMouseV
> >put tCurrentMouseV - sStartDrag into tLastDistanceCovered
> >if tTimeForLastMove = 0 then
> >   put 1 into tTimeForLastMove
> >end if
> >repeat with CM = 5 down to 2
> >   put sCumulativeMomentum[CM-1] into sCumulativeMomentum[CM]
> >end repeat
> >put (tLastDistanceCovered*10) / tTimeForLastMove into
> > sCumulativeMomentum[1]
> >put tCurrentMouseV into sStartDrag
> >put the milliseconds into sStartDragMil
> >send momentumAccumulate to me in 5 milliseconds
> > end momentumAccumulate
> >
> > on mousemove
> >if sAllowDrag <> empty then
> >   set the vScroll of me to sAllowDrag-(the mouseV)
> >end if
> > end mousemove
> >
> > on mouseup
> > local tCMTotal, tAverageMomentum, tRemainingDistance
> >put empty into sAllowDrag
> >put 0 into tCMTotal
> >Repeat with CM = 1 to 5
> >   add sCumulativeMomentum[CM] to tCMTotal
> >end Repeat
> >put 

Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
I just realized I had the wrong way of checking to see if scrolling should
stop. Somehow it still worked, which is kinda weird. Here is the revised
script, with checking for tCount < 1 rather than tCount > 50

-

Momentum Scrolling Code


Local StartDrag

Local AllowDrag

Local StartDragMil

Local CumulativeMomentum


on mousedown

   focus on nothing

   if word 1 of the name of the target = "button" or the isbutton of the
target = 1 then

  exit mousedown

   end if

   put (the mouseV)+(the vScroll of me) into AllowDrag

   put the milliseconds into StartDragMil

   put (the mouseV) into StartDrag

   repeat with CM = 1 to 5

  put 0 into CumulativeMomentum[CM]

   end repeat

   send momentumAccumulate to me in 0 milliseconds

end mousedown


on momentumAccumulate

   if mouse(1) <> "down" then

  exit momentumAccumulate

   end if



   put the milliseconds-StartDragMil into tTimeForLastMove

   put (the mouseV) into tCurrentMouseV

   put tCurrentMouseV - StartDrag into tLastDistanceCovered



   if tTimeForLastMove = 0 then

  put 1 into tTimeForLastMove

   end if

   repeat with CM = 5 down to 2

  put CumulativeMomentum[CM-1] into CumulativeMomentum[CM]

   end repeat

   put (tLastDistanceCovered*10) / tTimeForLastMove into
CumulativeMomentum[1]

   put tCurrentMouseV into StartDrag

   put the milliseconds into StartDragMil

   send momentumAccumulate to me in 5 milliseconds

end momentumAccumulate


on mousemove

   if AllowDrag <> empty then

  set the vScroll of me to AllowDrag-(the mouseV)

   end if

end mousemove


on mouseup

   put empty into AllowDrag

   put 0 into tCMTotal

   Repeat with CM = 1 to 5

  add CumulativeMomentum[CM] to tCMTotal

   end Repeat

   put tCMTotal/5 into tAverageMomentum

   put tAverageMomentum * 30 into tRemainingDistance

   doMomentumScrolling tRemainingDistance,50

end mouseup


on doMomentumScrolling tRemainingDistance, tCount

   if tCount < 1 then

  exit doMomentumScrolling

   end if

   if mouse(1) is "down" then

  exit doMomentumScrolling

   end if

   put tRemainingDistance/15 into tDistanceToMove

   put the vScroll of me into tVScroll

   set the vScroll of me to tVScroll - tDistanceToMove

   put tRemainingDistance-tDistanceToMove into tRemainingDistance

   put tCount-1 into tCount

   send "doMomentumScrolling tRemainingDistance, tCount" to me in 5
milliseconds

end doMomentumScrolling

On Wed, Jun 28, 2017 at 12:49 PM, Sean Cole (Pi) via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Jonathan,
> I would also recommend using the var name prefixes as recommended by LC in
> thier Tips for Writing Good Code when sharing publicly. Like this I mean:
>
> Local sStartDrag
> Local sAllowDrag
> Local sStartDragMil
> Local sCumulativeMomentum
>
> on mousedown
>focus on nothing
>if word 1 of the name of the target = "button" or the isbutton of the
> target = 1 then
>   exit mousedown
>end if
>put (the mouseV)+(the vScroll of me) into sAllowDrag
>put the milliseconds into sStartDragMil
>put (the mouseV) into sStartDrag
>repeat with CM = 1 to 5
>   put 0 into sCumulativeMomentum[CM]
>end repeat
>send momentumAccumulate to me in 0 milliseconds
> end mousedown
>
> on momentumAccumulate
> local tTimeForLastMove, tCurrentMouseV, tLastDistanceCovered
>if mouse(1) <> "down" then
>   exit momentumAccumulate
>end if
>put the milliseconds-sStartDragMil into tTimeForLastMove
>put (the mouseV) into tCurrentMouseV
>put tCurrentMouseV - sStartDrag into tLastDistanceCovered
>if tTimeForLastMove = 0 then
>   put 1 into tTimeForLastMove
>end if
>repeat with CM = 5 down to 2
>   put sCumulativeMomentum[CM-1] into sCumulativeMomentum[CM]
>end repeat
>put (tLastDistanceCovered*10) / tTimeForLastMove into
> sCumulativeMomentum[1]
>put tCurrentMouseV into sStartDrag
>put the milliseconds into sStartDragMil
>send momentumAccumulate to me in 5 milliseconds
> end momentumAccumulate
>
> on mousemove
>if sAllowDrag <> empty then
>   set the vScroll of me to sAllowDrag-(the mouseV)
>end if
> end mousemove
>
> on mouseup
> local tCMTotal, tAverageMomentum, tRemainingDistance
>put empty into sAllowDrag
>put 0 into tCMTotal
>Repeat with CM = 1 to 5
>   add sCumulativeMomentum[CM] to tCMTotal
>end Repeat
>put tCMTotal/5 into tAverageMomentum
>put tAverageMomentum * 30 into tRemainingDistance
>doMomentumScrolling tRemainingDistance,50
> end mouseup
>
> on doMomentumScrolling pRemainingDistance, pCount
> local tDistanceToMove
>if pCount > 50 then
>   exit doMomentumScrolling
>end if
>if mouse(1) is "down" then
>   exit doMomentumScrolling
>end if
>put pRemainingDistance/15 into tDistanceToMove
>put the vScroll of me into tVScroll
>set the vScroll of me to tVScroll - tDistanceToMove
>put pRemainingDistance-tDistanceToMove into 

Re: Momentum Scrolling Script

2017-06-28 Thread Sean Cole (Pi) via use-livecode
Jonathan,
I would also recommend using the var name prefixes as recommended by LC in
thier Tips for Writing Good Code when sharing publicly. Like this I mean:

Local sStartDrag
Local sAllowDrag
Local sStartDragMil
Local sCumulativeMomentum

on mousedown
   focus on nothing
   if word 1 of the name of the target = "button" or the isbutton of the
target = 1 then
  exit mousedown
   end if
   put (the mouseV)+(the vScroll of me) into sAllowDrag
   put the milliseconds into sStartDragMil
   put (the mouseV) into sStartDrag
   repeat with CM = 1 to 5
  put 0 into sCumulativeMomentum[CM]
   end repeat
   send momentumAccumulate to me in 0 milliseconds
end mousedown

on momentumAccumulate
local tTimeForLastMove, tCurrentMouseV, tLastDistanceCovered
   if mouse(1) <> "down" then
  exit momentumAccumulate
   end if
   put the milliseconds-sStartDragMil into tTimeForLastMove
   put (the mouseV) into tCurrentMouseV
   put tCurrentMouseV - sStartDrag into tLastDistanceCovered
   if tTimeForLastMove = 0 then
  put 1 into tTimeForLastMove
   end if
   repeat with CM = 5 down to 2
  put sCumulativeMomentum[CM-1] into sCumulativeMomentum[CM]
   end repeat
   put (tLastDistanceCovered*10) / tTimeForLastMove into
sCumulativeMomentum[1]
   put tCurrentMouseV into sStartDrag
   put the milliseconds into sStartDragMil
   send momentumAccumulate to me in 5 milliseconds
end momentumAccumulate

on mousemove
   if sAllowDrag <> empty then
  set the vScroll of me to sAllowDrag-(the mouseV)
   end if
end mousemove

on mouseup
local tCMTotal, tAverageMomentum, tRemainingDistance
   put empty into sAllowDrag
   put 0 into tCMTotal
   Repeat with CM = 1 to 5
  add sCumulativeMomentum[CM] to tCMTotal
   end Repeat
   put tCMTotal/5 into tAverageMomentum
   put tAverageMomentum * 30 into tRemainingDistance
   doMomentumScrolling tRemainingDistance,50
end mouseup

on doMomentumScrolling pRemainingDistance, pCount
local tDistanceToMove
   if pCount > 50 then
  exit doMomentumScrolling
   end if
   if mouse(1) is "down" then
  exit doMomentumScrolling
   end if
   put pRemainingDistance/15 into tDistanceToMove
   put the vScroll of me into tVScroll
   set the vScroll of me to tVScroll - tDistanceToMove
   put pRemainingDistance-tDistanceToMove into pRemainingDistance
   put pCount-1 into pCount
   send "doMomentumScrolling pRemainingDistance, pCount" to me in 5
milliseconds
end doMomentumScrolling


I hope this doesn't come across as patronising. You've obviously got some
years of skill behind you and I don't want to come across as demeaning.

Sean Cole
*Pi Digital Productions Ltd*

eMail Ts & Cs    Pi Digital
Productions Ltd is a UK registered limited company, no. 5255609
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
That's a good tip - it actually will affect one of my groups quite a bit - drat.

Thanks Sean

Sent from my iPhone

> On Jun 28, 2017, at 12:29 PM, Sean Cole (Pi) via use-livecode 
>  wrote:
> 
> This is excellent Jonathan, Thanks.
> 
> Another tip is to make sure that the Group object you wish to scroll the
> contents of is not nested in any other groups as the will negate the
> AcceleratedRendering. This is not documented in the API dictionary but is a
> known functionality. The documentation will be changed to include this very
> necessary information and there is word that acceleratedRendering will be
> extended to include nested controls sometime in the future, but not just
> yet.
> 
> Thanks again
> 
> Sean Cole
> *Pi Digital Productions Ltd*
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Momentum Scrolling Script

2017-06-28 Thread Sean Cole (Pi) via use-livecode
This is excellent Jonathan, Thanks.

Another tip is to make sure that the Group object you wish to scroll the
contents of is not nested in any other groups as the will negate the
AcceleratedRendering. This is not documented in the API dictionary but is a
known functionality. The documentation will be changed to include this very
necessary information and there is word that acceleratedRendering will be
extended to include nested controls sometime in the future, but not just
yet.

Thanks again

Sean Cole
*Pi Digital Productions Ltd*
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Momentum Scrolling Script

2017-06-28 Thread Jonathan Lynch via use-livecode
Hi everyone,

I just created and tested a momentum scrolling script on my iPhone, and it
appears to work quite well, so I thought I would share it here. It also
works on desktop with mouse dragging. If you see improvements, please share
them.

1. Make sure to have accelerated rendering on for the stack.
2. Make sure to set the layer mode of the group to "scrolling" for mobile
devices, so it will be fully responsive to the touch.
3. You can adjust the various constants in this script to alter the
duration, speed, and length of momentum scrolling. Just play with it as
needed.

Here is the script:
---


Local StartDrag

Local AllowDrag

Local StartDragMil

Local CumulativeMomentum


on mousedown

   focus on nothing

   if word 1 of the name of the target = "button" or the isbutton of the
target = 1 then

  exit mousedown

   end if

   put (the mouseV)+(the vScroll of me) into AllowDrag

   put the milliseconds into StartDragMil

   put (the mouseV) into StartDrag

   repeat with CM = 1 to 5

  put 0 into CumulativeMomentum[CM]

   end repeat

   send momentumAccumulate to me in 0 milliseconds

end mousedown


on momentumAccumulate

   if mouse(1) <> "down" then

  exit momentumAccumulate

   end if



   put the milliseconds-StartDragMil into tTimeForLastMove

   put (the mouseV) into tCurrentMouseV

   put tCurrentMouseV - StartDrag into tLastDistanceCovered



   if tTimeForLastMove = 0 then

  put 1 into tTimeForLastMove

   end if

   repeat with CM = 5 down to 2

  put CumulativeMomentum[CM-1] into CumulativeMomentum[CM]

   end repeat

   put (tLastDistanceCovered*10) / tTimeForLastMove into
CumulativeMomentum[1]

   put tCurrentMouseV into StartDrag

   put the milliseconds into StartDragMil

   send momentumAccumulate to me in 5 milliseconds

end momentumAccumulate


on mousemove

   if AllowDrag <> empty then

  set the vScroll of me to AllowDrag-(the mouseV)

   end if

end mousemove


on mouseup

   put empty into AllowDrag

   put 0 into tCMTotal

   Repeat with CM = 1 to 5

  add CumulativeMomentum[CM] to tCMTotal

   end Repeat

   put tCMTotal/5 into tAverageMomentum

   put tAverageMomentum * 30 into tRemainingDistance

   doMomentumScrolling tRemainingDistance,50

end mouseup


on doMomentumScrolling tRemainingDistance, tCount

   if tCount > 50 then

  exit doMomentumScrolling

   end if

   if mouse(1) is "down" then

  exit doMomentumScrolling

   end if

   put tRemainingDistance/15 into tDistanceToMove

   put the vScroll of me into tVScroll

   set the vScroll of me to tVScroll - tDistanceToMove

   put tRemainingDistance-tDistanceToMove into tRemainingDistance

   put tCount-1 into tCount

   send "doMomentumScrolling tRemainingDistance, tCount" to me in 5
milliseconds

end doMomentumScrolling

-- 
Do all things with love
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode