Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Go to solution Solved by BornToCreate,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

in my script im using a draggable for navigation.

In the throwProps-callback the draggable is disabled.

Now i want to enable it in an oncomplete callback of my timeline, but itis doing nothing.

I can log the draggable instance but calling the method isnt affecting anything.

The draggable stays disabled.

 

After every section in my timeline my timeline callback is called.

Then I want to enable my dragger to grant navigation.

OnThrowPropsComplete I want to disable the dragger and navigation to dont disturb the timeline.

 

Draggable instanciation:

draggerInstance = Draggable.create($dragger, {
    type: "y",
    bounds: "#drag-container > div",
    overshootTolerance: 0,
    throwProps: true,
    onThrowComplete: function() {
        hideSwiperButtons();
        wasDragged = true;
        var itemNo = getDraggerItemNo(this.y);
        tl.seek(sceneLabels[itemNo]);
        $dragger.removeClass("active");
        $menuItems.removeClass("active");
        $menuItems.eq(itemNo).addClass("active");
        TweenMax.to($menuContainer, 0.5, {
            opacity: 0,
            delay: 0.01,
            ease: Expo.easeOut,
            onComplete: function() {
                $menuContainer.removeClass("active");
                currentTween = tl.tweenTo(sceneLabels[itemNo + 1]);
                currentScreen = itemNo + 1;
            }
        });
        this.disable();  //Disable dragger here to prevent navigation while tweening
    },
    snap: {
        y: function(endValue) {
            return getDraggerItemNo(endValue) * gridHeight;
        }
    },
    maxDuration: 1,
    onDragStart: function() {
        $dragger.addClass("active");
        $menuContainer.addClass("active");
        TweenMax.to($menuContainer, 0.5, {
            opacity: 1,
            ease: Expo.easeOut
        });
    },
    onDrag: function() {
        var itemNo = getDraggerItemNo(this.y);
        $menuItems.removeClass("active");
        $menuItems.eq(itemNo).addClass("active")
    }
});

 

 

TimeLine onComplete callback

function onCompleteTimeline() {
  //draggerInstance is accessable from here
  draggerInstance[0].enable(); //not working
  tl.pause();
}
Link to comment
Share on other sites

Yup, Diaco is right, we really need to see what is happening in order to trouble shoot properly.

Your demo only needs to contain code that makes the item Draggable and Throwable with the proper callbacks that will disable() / enable() the draggable.

All that code about adding and removing classes, tweening $menuContainer, snapping, etc isn't necessary. I'm guessing you can cut the code down by 50% and that will make it very easy for us to spot any potential problems. Thx!

  • Like 1
Link to comment
Share on other sites

  • Solution

Thanks for your responses. I solved it now and it was a really dumb mistake from my side.

Shame on me  :oops:

Link to comment
Share on other sites

Cool. Thx for letting us know. FWIW we are all masters of dumb mistakes around here:)

  • Like 1
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.
×