Share Posted September 18, 2015 I've read through the docs but couldn't find anything relating to this in there. Is it possible for us to trigger functions or other tweens whilst dragging in draggable? For example if you started dragging, the container would tween to an opacity change or the cursor would change whilst you were dragging then change back when you let go. I've attached a pen I have that uses draggable if it's any help to work with. Thanks! See the Pen OyLEem by olichalmers (@olichalmers) on CodePen 1 Link to comment Share on other sites More sharing options...
Share Posted September 18, 2015 Sure. you can set up an onDrag callback to run whatever logic you want while dragging. Here are 2 examples: http://codepen.io/GreenSock/pen/irzvd http://codepen.io/GreenSock/pen/gnoDc 1 Link to comment Share on other sites More sharing options...
Share Posted September 18, 2015 In addition to Carl's answer/really useful links , you can do something like one of these : using onPress/Release : var tween= TweenLite.to('#container ',0.2,{opacity:0.5,paused:true}); var draggables = Draggable.create(".box", { onPress:function(){tween.play()}, onRelease:function(){tween.reverse()} }); or run a function on Drag : var DTween=1 , tween=TweenLite.to('#container ',0.2,{opacity:0.5,paused:true}); var draggables = Draggable.create(".box", { onDrag:function(){ if(!DTween){return false}; // return false to avoid run on Drag repeatedly tween.play(); DTween=0; }, onRelease:function(){ tween.reverse(); DTween=1; } }); See the Pen bVpZPV by MAW (@MAW) on CodePen Link to comment Share on other sites More sharing options...
Author Share Posted September 19, 2015 Awesome, thanks a lot guys! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now