Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyyeh/handling-input-events
https://github.com/cyyeh/handling-input-events
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cyyeh/handling-input-events
- Owner: cyyeh
- Created: 2021-12-27T23:01:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-28T12:34:18.000Z (about 3 years ago)
- Last Synced: 2024-12-21T05:10:17.116Z (2 months ago)
- Language: JavaScript
- Size: 3.72 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Handling Input Events
demo site: https://gracious-sinoussi-18a298.netlify.app/
## Requirements Checklist
- [x] mouse-click on a div - causes the div to be selected, and it changes color to be blue. If another div was selected, it should be deselected.
- [x] mouse-click on the background (on workarea) not on any objects - deselects the selected div, if any.
- [x] mouse down on a div and move - causes the div to start moving, following the mouse, until mouse-up. It should not change color (this way of moving should not change the selected div).
- [x] mouse double-click - causes the div to be selected (change color), and also starts a mode where this - div follows the mouse (even though the mouse button has been released). The div should stop following the mouse on the next mouse up event. While in this mode, all other mouse behaviors on the divs should be suspended (so, for example, clicking on a different div will not select it). This is a common accessibility feature for people who have difficulty holding down a mouse button.
- [x] If the user hits the keyboard "ESC" key while the operation is in progress, then the moving or growing should abort, and the div should go back to the way it was before the operation starts. Hitting "ESC" when an operation is not in progress should do nothing. (Obviously, this mainly applies to mouse behaviors, but if you have a keyboard on your tablet, or a touch screen on your laptop, then this should work with moving and changing size from touch events too.) Aborting a move or grow should not affect which object is selected.
- [ ] one-finger tap and double-tap - as explained in class, these generate mouse click and double click events, so they should do the same thing as mouse-click and mouse-double-click.
- After double tap on the touch screen, the div gets to be in "following the finger" mode. When you do touchstart, the div follows the finger even if the touch is not on the object, until touchend. Touchend does not stop the mode, however, so the next touchstart continues to move the same div (again, even if the touchstart is not on the div). This mode only ends with a click action (touchstart and touchend quickly in the same place).
- If the user puts down another finger while the first finger is already moving the object in this "following the finger" mode, then this should abort - return the object to its original position before the move started and stop being in this mode, just like hitting the ESC key on the keyboard. It should not affect which object is selected.
- [ ] one-finger touch drag - This should have the same behavior as mouse-drag (move the object around with the finger).
- If the user puts down another finger while the first finger is already moving the object, then this should abort - return the object to its original position before the move started, just like hitting the ESC key on the keyboard. It should not affect which object is selected.
- [ ] two-finger touch - If the user puts two fingers down at approximately the same time, this should change the size of the selected div in place, without moving that div. The size should approximately follow the two fingers, while keeping the center of the div pinned in place. The requirement is that this work horizontally, with vertical size changing being extra credit (the video shows both). That is, moving the fingers will change the left and right sides of the div to be as far apart at the fingers are. If nothing is selected, then using two fingers should do nothing. The change-size should stop when the two fingers are released.
- If one finger is released but the other stays on the screen, this should stop the size change as it last was (just stop growing but not abort), since this inevitably happens when one lifts two fingers - one finger lifts off first then the other.
- If the finger goes back into contact before the other finger lets up, the div can go back to changing size.
- If a third finger is put down on the surface, this should abort the change size and go back to the original size before the change size started. All further finger activity should be ignored until all the fingers are removed from the surface.
- Your code should enforce a minimum width and height for the div. Any attempts to make it smaller should just be ignored, but the change size continues, in case the user moves their fingers further apart again.
- [x] Your code should work for any number of div's - not just the 3 in the provided html file. You can assume all the div's will have the same structure as those provided (they will have have the same target class).
- [ ] As shown in the video, support changing the size with two finger touch in either horizontal or vertical directions, depending on the orientation of the fingers when they both touch the surface, as shown on the video. For example, if the two fingers are approximately horizontal, and then the fingers will change the left and right sides of the div. Alternatively, if the user puts their fingers approximately vertical, then this should change the top and bottom. [Up to +5 extra credit, out of 100]
- [ ] Add in a behavior where pressing down in the background, and enclosing an area while the mouse button is held down selects a div that is entirely within the bounding area, like in conventional drawing programs like PowerPoint. (If there is more than one, you can select any one you want.) Preferably show a bounding box to provide feedback for the current bounding area. [Up to +5 extra credit, out of 100]
- [ ] Add an event handler for a different kind of event (should be of a different form than the above, so it doesn't count as extra to handle something like touchcancel). Some examples that would count are (see large list of events): window resize event, scroll wheel, devicemotion (accelerometer), etc. Do something interesting to the divs as a result of those events. [Up to +10 extra credit, out of 100]