Jump to content
Search Community

Scroller acceleration issue [blitMask + ThrowPropsPlugin] / Newbie question

Vortexroman test
Moderator Tag

Recommended Posts

Hi,

I have a small issue with my scroller withing my mobile app. The issue is if I'm pressing, holding and dragging (up or down to wanted position) in one action, and then lifting my finger - the scroll will continue the animation of scrolling. It's like it "stores acceleration" -  If my drag action is bigger, than the scroll will continue the animation more. 

 

How can I disable this "after scroll" animation? I just want a smooth and linear scroll. Can someone help?

 

Here is my current code:

 

ThrowPropsPlugin.to(buttons_container_mc, {throwProps:{
           y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:100}
          }, onUpdate:blitMask.update, ease:Expo.easeOut
         }, 100, 0.25, 0);

 

Best regards,

Roman

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

The code you have above is only needed IF you want the object you are dragging to be thrown based on the velocity of your drag. If you don't want the "throw" behavior just try removing the code you posted. 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

The code you have above is only needed IF you want the object you are dragging to be thrown based on the velocity of your drag. If you don't want the "throw" behavior just try removing the code you posted. 

 

Thank you for your answer, but I can't just remove the code, because it's being used in many current project's classes. I guess I need a solution of how to set a ThrowPropsPlugin. Do you have an idea how to solve it?

 

Thanks,

Roman

Link to comment
Share on other sites

Hi Carl, here is the code I've used in my app:
//Scroll

private function createScroll():void {
bounds = new Rectangle(43, 229, 552, (610+Math.round(deviceScreenHeight - baseScreenHeight)));

blitMask = new BlitMask(buttons_container_mc, bounds.x, bounds.y, bounds.width, bounds.height, false);
blitMask.disableBitmapMode();
blitMask.addEventListener(MouseEvent.MOUSE_DOWN, scrollMouseDownHandler);
}

function scrollMouseDownHandler(event:MouseEvent):void {
if ((canScrollButtons)&&(this.mouseY>229)&&(this.mouseY<(229+(610+Math.round(deviceScreenHeight - baseScreenHeight))))) {
mouse_move = false;
TweenLite.killTweensOf(buttons_container_mc);
y1 = y2 = buttons_container_mc.y;
yOffset = this.mouseY - buttons_container_mc.y;
yOverlap = Math.max(0, buttons_container_mc.height - (bounds.height-15));
t1 = t2 = getTimer();
buttons_container_mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, scrollMouseMoveHandler);
buttons_container_mc.stage.addEventListener(MouseEvent.MOUSE_UP, scrollMouseUpHandler);
}
}

function scrollMouseMoveHandler(event:MouseEvent):void {
mouse_move = true;
var y:Number = this.mouseY - yOffset;
if (y > bounds.top) {
buttons_container_mc.y = bounds.top;
} else if (y < bounds.top - yOverlap) {
buttons_container_mc.y = bounds.top - yOverlap;
} else {
buttons_container_mc.y = y;
}
blitMask.update();
var t:uint = getTimer();
event.updateAfterEvent();
}

function scrollMouseUpHandler(event:MouseEvent):void {
buttons_container_mc.stage.removeEventListener(MouseEvent.MOUSE_UP, scrollMouseUpHandler);
buttons_container_mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, scrollMouseMoveHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (buttons_container_mc.y - y2) / time;
ThrowPropsPlugin.to(buttons_container_mc, {throwProps:{
y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:100}
}, onUpdate:blitMask.update, ease:Expo.easeOut
}, 100, 0.25, 0);

 

Link to comment
Share on other sites

Sorry, but I'm really not sure what you are asking. Unfortunately I can not read through a few hundred lines of ActionScript code and attempt to debug it  :| .

I gave you the best advice I could about disabling the throw behavior:

 

  • Don't create a ThrowProps tween
  • set yVelocity to 0

if you are re-using this in a way that some scrollable items should be thrown and others not thrown my best guess is that you would have to provide an optional parameter to your createScroll() method.  

createScroll( allowThrow );
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...