happen

所属分类:Python编程
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2018-08-19 21:30:52
上 传 者sh-1993
说明:  在浏览器中发生真实事件,具有纯DOM和可选$
(make real events happen in-browser, with pure DOM and optional $)

文件列表:
.eslintrc.js (388, 2018-08-19)
CHANGELOG.md (895, 2018-08-19)
LICENSE (1484, 2018-08-19)
bower.json (137, 2018-08-19)
circle.yml (32, 2018-08-19)
happen.js (6205, 2018-08-19)
jquery/ (0, 2018-08-19)
jquery/jquery.js (93436, 2018-08-19)
package.json (694, 2018-08-19)
test/ (0, 2018-08-19)
test/chai.js (144293, 2018-08-19)
test/happen.js (6514, 2018-08-19)
test/index.html (721, 2018-08-19)
test/mocha.js (339849, 2018-08-19)
test/nojquery.html (457, 2018-08-19)

[![Circle CI](https://circleci.com/gh/tmcw/happen.svg?style=shield)](https://circleci.com/gh/tmcw/happen) [![Greenkeeper badge](https://badges.greenkeeper.io/tmcw/happen.svg)](https://greenkeeper.io/) **happen** wraps the `createEvent` DOM API to make real event mocking in-browser palatable. ## Installation ### Raw: wget https://raw.github.com/tmcw/happen/master/happen.js ### With [component](https://github.com/component/component) component install tmcw/happen ### With Browserify npm install happen var happen = require('happen'); ### With [bower](https://github.com/bower/bower) bower install tmcw/happen ## Native API ### once() `happen.once(element, options)` fires an event once. The `element` must be a DOM element. `options` must have a `type` for event type, then can have options: #### Keyboard Events * keyCode * charCode * shiftKey * metaKey * ctrlKey * altKey #### Mouse Events * detail * screenX * screenY * clientX * clientY * ctrlKey * altKey * shiftKey * metaKey * button #### Touch Events * touchstart * touchmove * touchend ```javascript var element = document.getElementById('map'); // click shortcut happen.click(element); // dblclick shortcut happen.dblclick(element); // custom options happen.dblclick(element, { shift: true }); // any other event type under MouseEvents happen.once(element, { type: 'mousewheel', detail: -100 }); // The once api takes happen.once( // element element, { // event type (e.type) type: 'mousewheel', // any other options detail: -100 }); // touch events happen.once(element, { type : 'touchstart', touches : [{ pageX : 800, pageY : 800 }, { pageX : 400, pageY : 400 }] }); ``` ## jQuery Plugin ```javascript // Shortcut - 'click' is shorthand for { type: 'click' } $('.foo').happen('click'); // Longhand - specify any sort of properties $('.foo').happen({ type: 'keyup', keyCode: 50 }); // Works on any jQuery selection $('.foo, .bar').happen('dblclick'); ``` Shortcuts: * `happen.click` * `happen.dblclick` * `happen.mousedown` * `happen.mouseup` * `happen.mousemove` * `happen.keydown` * `happen.keyup` * `happen.keypress` Use it with a testing framework, like [Jasmine](http://pivotal.github.com/jasmine/) or [Mocha](http://mochajs.org/). [![](http://ci.testling.com/tmcw/happen.png)](http://ci.testling.com/tmcw/happen) (IE tests failing due to Chai) ## See Also * [simulant](https://github.com/Rich-Harris/simulant) * [trigger-event](https://github.com/adamsanderson/trigger-event) * [dom-event](https://github.com/jkroso/dom-event) * [synthetic-dom-events](https://github.com/shtylman/synthetic-dom-events)

近期下载者

相关文件


收藏者