+ 2
How to drag an object??
dragging an object in mobile phones, please give codes.
13 Answers
+ 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
+ 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
+ 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
+ 2
@Andrew can you please show a code including this, because I just can't do it rightđ
+ 2
Thanks
+ 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.
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??
0
cool
0
thanks @Tim @Andrew
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
0
ok ty @Tim