
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
pointer-event
Advanced tools
Event Controller for mouse and touch interfaces
var pointerEvent = new PointerEvent(),
// startHandlerId which is used for adding/removing to element is returned.
startHandlerId = pointerEvent.regStartHandler(function(pointerXY) {
console.log('[START]');
console.dir(pointerXY); // Object having `clientX` and `clientY`.
return true; // If it returns `false`, the starting is canceled.
});
// When `mousedown` or `touchstart` is fired on this element, the registered start-handler is called.
pointerEvent.addStartHandler(document.getElementById('trigger'), startHandlerId);
// When `mousemove` or `touchmove` is fired on this element, this move-handler is called.
pointerEvent.addMoveHandler(document, function(pointerXY) {
console.log('[MOVE]');
console.dir(pointerXY); // Object having `clientX` and `clientY`.
});
// When `mouseup` or `touchend` is fired on this element, this end-handler is called.
pointerEvent.addEndHandler(document, function(pointerXY) {
console.log('[END]');
console.dir(pointerXY); // Object having `clientX` and `clientY`.
});
// When `touchcancel` is fired on this element, this cancel-handler is called.
pointerEvent.addCancelHandler(document, function() {
console.log('[CANCEL]');
});
// ============================================================================
document.getElementById('move-button').addEventListener('click', function() {
// Emulate the `move` that is done when `mousemove` or `touchmove` is fired.
pointerEvent.move(); // pointerXY can be passed.
}, false);
document.getElementById('end-button').addEventListener('click', function() {
// Emulate the `end` that is done when `mouseup` or `touchend` is fired.
pointerEvent.end(); // pointerXY can be passed.
}, false);
document.getElementById('cancel-button').addEventListener('click', function() {
// Emulate the `cancel` that is done when `touchcancel` is fired.
pointerEvent.cancel();
}, false);
// ============================================================================
// Remove the added start-handler from this element.
pointerEvent.removeStartHandler(document.getElementById('trigger'), startHandlerId);
// Unregister the registered start-handler.
pointerEvent.unregStartHandler(startHandlerId);
// ============================================================================
// Options:
// preventDefault {boolean} [true] - Call `event.preventDefault()` if it is `true`.
// stopPropagation {boolean} [true] - Call `event.stopPropagation()` if it is `true`.
var pointerEvent = new PointerEvent({stopPropagation: false}); // Don't call that.
// ============================================================================
// addEventListener with specific option.
PointerEvent.addEventListenerWithOptions(target, type, listener, options);
FAQs
Event Controller for mouse and touch interfaces
The npm package pointer-event receives a total of 226 weekly downloads. As such, pointer-event popularity was classified as not popular.
We found that pointer-event demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.