0.2.52 • Published 4 months ago

touchboom v0.2.52

Weekly downloads
2
License
MIT
Repository
github
Last release
4 months ago

touchboom

MIT-license

touchboom

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.

//
// state is defined and mutated on cfg
//
let cfg = {};

//
// start coords = [ xcoord, ycoord ]
// all properties are optional
// 
cfg.coords = touchboom.coords([{
  bgn : 0
}, {
  autoweight : 10,
  bgn : 0,
  min : -400,
  max : 400
}]);

//
// target element must have id, used to manage delegation
// one set of listeners are attached body and delegated
// to touchboom functions assocated w/ element
//
rootelem.id = 'id-is-required';

//
// all event functions are optional,
//
//  * oneventfn, called when an event occurs
//    touchboom.events
//
//  * oninertiafn, called each 'frame' of movement
//    before and after touch/mouse release
//
//  * onmovefn, called when mouse is over element
//
touchboom.attach(cfg, rootelem, {
  oneventfn : function (cfg, etype, e) {
    if (etype === 'moveend') {
      // coords stopped moving
      console.log(touchboom.coordsgettotal(cfg));
    } else if (etype === 'end') {
      // mouse or finger are disengaged
      console.log(touchboom.coordsgettotal(cfg));
    }
  },
  oninertiafn : function (cfg, etype, e) {
      // coordinates are updated
      console.log(touchboom.coordsgettotal(cfg));
  }
});

scrounge

(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.

0.2.52

4 months ago

0.2.51

1 year ago

0.2.50

7 years ago

0.2.49

7 years ago

0.2.48

7 years ago

0.2.47

7 years ago

0.2.46

7 years ago

0.2.45

7 years ago

0.2.43

7 years ago

0.2.42

7 years ago

0.2.41

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

8 years ago