Reputation: 5311
I'm trying to figure out how I could trigger an event which after click and drag 3 times over element would trigger an event. The scenario is rubbing the 'Alladin's lamp' (I know) - when you click and drag left / right / left or right / left / right - something happens after that.
I don't really know where to start other than just trigger the click() event and then perhaps drag using jQuery UI - just a guess - any tips would be much appreciated.
Upvotes: 0
Views: 291
Reputation: 5311
Ok - found the solution - this plugin does the great job: Jquery Gestures
Thanks everyone!
Upvotes: 1
Reputation: 3833
You should read jQuery UI draggable documentation. You could use the dragstop event.
A fast example :
Construct one element lamp
and (for example) another element hand
. When you drag the hand
hover the lamp
, you can store in a boolean variable if your hand
have really hovered the lamp
. If true
when dragstop
, so you can increment another variable which contains the number of times of the hand
hover the lamp
. Then, if this number is equal to 3, show the genius :) !
Upvotes: 2