- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › creating an if/else statement for drag and drop absolute positioning
my last post I attempted to make on this forum for blocked before I could post anything. I linked to a js-fiddle page, and one other demo page. not sure if that is what cause it from betting blocked, but i am here to test if it is just a complication with my office’s firewall.
Posting JS does seem to be problematical on the forum.
We tend to use Codepen around here for demos.
It was the links I posted, I’ll try adding it to codepen and see if that makes a difference
ok, so my dilemma is I am creating a small page that let’s users drag answer blocks and place them to what they believe is the correct spot for the answer.
If the answer is correct for that location, the answer block’s position stays in that location. If it is not the correct answer, the answer block returns to it’s starting position.
I am still new to javascript, and have had no luck in getting the block to drag or to stay in an absolute position when hovered over a specific area.
I’m sure there are multiple methods to achieve the functionality I need, but I’m unsure which is the best way (since I’ve tried multiple tutorials that did not quite meet my needs).
Here is my demo page. Any help would be greatly appreciated!
P.S. I numerated one answer block and one gapped aread to put the answer to make the demonstrating a potential solution easier. Once I figure out the JS behind getting it to work, I can take care of the tedium of replicating it for all the answers.
This would be the basic idea to make a (touch supported) draggable :
http://codepen.io/Shikkediel/pen/ZYbWzL?editors=011
As interesting an exercise it might be, it would go a bit far for myself to adapt it to your situation.
why you do not use jquery ui
Because there’s really no need for a whole extra library plugin when you can code the relevant bit yourself…