+ 2

How to drag an object??

dragging an object in mobile phones, please give codes.

2nd Nov 2017, 10:41 AM
Jitesh Gupta
13 ответов
+ 6
@Tim Thurma answer use JQuery: if you want use drag and drop with vanilla JS, you need to at least use a polyfill to support drag and drop events on touch devices (html5 drag and drop API natively only support mouse events)... this code show how to, and provide references links: https://code.sololearn.com/Wrhkbc5ngt7y/?ref=app
2nd Nov 2017, 11:34 AM
visph
visph - avatar
+ 2
You can find some codes on Code Playground. I found someones and made it a bit more simple so it's easier to understand. https://code.sololearn.com/WNCMz6T2v2ch/?ref=app
2nd Nov 2017, 11:27 AM
Tim Thuma
Tim Thuma - avatar
+ 2
The full code of my simpliefied one is here. https://code.sololearn.com/WSqW41Mv08fr/?ref=app I'm not sure, but maybe you can add an onclick event and then play music when it's triggered. For playing music you've got something here. https://code.sololearn.com/WKlCtEJ9eRH0/?ref=app
2nd Nov 2017, 11:35 AM
Tim Thuma
Tim Thuma - avatar
+ 2
@Andrew can you please show a code including this, because I just can't do it right😅
2nd Nov 2017, 11:54 AM
Tim Thuma
Tim Thuma - avatar
+ 2
Thanks
2nd Nov 2017, 12:09 PM
Tim Thuma
Tim Thuma - avatar
+ 1
Yes I said you can add onclick event and then added audio player code for example of how you can make audio playing when an object is clicked.
2nd Nov 2017, 2:03 PM
Tim Thuma
Tim Thuma - avatar
0
thanks @Tim, but now, how can we add a music to it when we drag it, means when we touch the object to drag, then it will play a song and when released song will also stop, how to do that??
2nd Nov 2017, 11:30 AM
Jitesh Gupta
0
cool
2nd Nov 2017, 11:36 AM
Jitesh Gupta
0
thanks @Tim @Andrew
2nd Nov 2017, 1:47 PM
Jitesh Gupta
0
@tim you shared a code of audio player but I asked for an object which can be dragged and when touched play song, when released stops the song
2nd Nov 2017, 1:54 PM
Jitesh Gupta
0
ok ty @Tim
2nd Nov 2017, 3:44 PM
Jitesh Gupta