Making Layers Respond to Mouse Drag

69 views
Skip to first unread message

Olawande Meyungbo

unread,
Jan 20, 2018, 7:10:17 PM1/20/18
to Google Web Designer beta
Hi, 

I am new to Google Web Designer but have been doing a lot of catching up lately.

The challenge I am facing is making an object or layer movable by the end user with mouse. Let's say I have a CTA saying move the egg into the basket to unveil flavours. Please how do I make the eggs moveable into the basket then the page with the flavours come up. 

Many thanks 

Piotr Kowalski

unread,
Jan 22, 2018, 8:30:00 AM1/22/18
to Google Web Designer beta
Hello
in the script view mode click File->Add Library->GreenSock->Draggable


then follow this documentation:  

https://greensock.com/draggable

https://greensock.com/docs/Utilities/Draggable


legendary :) 





Olawande Meyungbo

unread,
Jan 22, 2018, 12:28:10 PM1/22/18
to Google Web Designer beta
Thanks a lot, Piotr

This helps a lot 

Please I am having issues placing the code. I am trying to start with the 

Draggable.create("#yourID"); 
So I am trying to insert draggable.create("#code") in the script here. 
I have already done the Include JS library -> Greensock -> Draggable then achieved this 

So what I am trying to do now is to insert the draggable.create("#code") at the bottom as attached

But still no outcome. Please how do I make this work?
P.S: I am so so grateful

Piotr Kowalski

unread,
Jan 23, 2018, 3:51:58 AM1/23/18
to Google Web Designer beta
Hello 

1. You need TweenMax and Draggable - I forgot

2. If you don't use jquery you need to find elements with pure javascript 

window.onload = function () { 

var myDraggable =  Draggable.create(document.getElementById("dragg"), {
type: "x,y",
onDragEnd: function (e) {
var slot = "#slot";

if (this.hitTest(slot, 20)) {
alert("done");
}

},
onRelease: function (e) {

},
onPress: function (e) {
}
}); 

}

3. grab test project from attachment  http://wooosh.pl/ftp/testDragg.zip

Olawande Meyungbo

unread,
Jan 23, 2018, 10:39:55 AM1/23/18
to Google Web Designer beta
Many thanks Piotr,

This works perfectly. I am very grateful, I was able to drag the layer. 

Sorry I might be bothering you right now, I would to know if using Google Web Designer, I can initialize an action or timeline after drag. 

Using the test you sent to me, I am looking at a scenario whereby the green tab on the right begins to move after the red tab has been dragged into it.

Please is this possible with Google Web Designer, if yes, please can you share a clue on how to go about it

This is much appreciated 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages