touchboom
MIT-license
Reports inertial movement and key/touch/mouse events from the document. A reworking of the motion scripts found here, courtesy of Ariya Hidayat.
Try it out by visiting this page. Try clicking, dragging and releasing.
All handlers connect to the same data, so that mouse-originated glide motions continue alongside key-originated glide motions. One set of listeners are attached to the body from which all events are delegated so that behaviour may be bound many times.
Touchboom uses the legacy property event.keyCode with keyboard up, down, left, right, wasd events.
Run npm test and load the test page to see a demo.
let cfg = {};
cfg.coords = touchboom.coords([{
bgn : 0
}, {
autoweight : 10,
bgn : 0,
min : -400,
max : 400
}]);
rootelem.id = 'id-is-required';
touchboom.attach(cfg, rootelem, {
oneventfn : function (cfg, etype, e) {
if (etype === 'moveend') {
console.log(touchboom.coordsgettotal(cfg));
} else if (etype === 'end') {
console.log(touchboom.coordsgettotal(cfg));
}
},
oninertiafn : function (cfg, etype, e) {
console.log(touchboom.coordsgettotal(cfg));
}
});
(The MIT License)
Copyright (c) 2016 Bumblehead chris@bumblehead.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.