javascript - JS restrict mouse movement with axis when shift pressed (for draggable element) -
When I press the shift button, I want the user to move only the mouse upwards / down or right / right . My current raw idea is to use event simulations to stop all movements and to pass the necessary event when the change is pressed (which will only have the required axis movement). I use the jQuery Draggable, so other ideas are to determine that when the shift is pressed and dragged to itself, but it can check the dragable code and any time it might be time consuming How to do more elegant way?
Resolve by dragging restriction restrictions (FF only):
Apply ApplyGrogressifference (Event, Prepayment) {if ($ (".componentPlaced"). DrugGable ("Option", "Axis")) Return; If (Math.abs (event.clientX - prev.position.x) & lt; Math.abs (event.clientY - prevposition.y)) $ $ ('componentPlaced'). Draggable ({axis: 'y'}); } And {$ ('component component'). Dragable ({axis: 'x'}); }} Apply the functionShiftHandler (event) {if (hashfundown) applies toredregression (events, oldmothersparents); Oldmoshpozoos = {x: event.clientX, y: event.clientY}; } Function checkdowndown event (event) {if (event.keyCode == KeyEvent.DOM_VK_SHIFT) {hashftdown = true; }} Check function of the function (event) {if (event.keyCode == KeyEvent.DOM_VK_SHIFT) {Cancel Gradation (); IsShiftDown = false; }} Cancel the function () {$ ('component component'). Dragable ({axis: tap}); }
Comments
Post a Comment