Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function baseInteractionsFromEvents (targetEl, options) {
const defaults = {
passiveEventsHandlers: true,
preventScroll: true,
preventMenu: true
}
options = Object.assign({}, defaults, options)
const {passiveEventsHandlers, preventScroll, preventMenu} = options
const mouseDowns$ = fromEvent('mousedown', targetEl, {passive: passiveEventsHandlers, capture: false})
const mouseUps$ = fromEvent('mouseup', targetEl, {passive: passiveEventsHandlers, capture: false})
// const mouseLeaves$ = fromEvent('mouseleave', targetEl, {passive:true,capture:false}).merge(fromEvent('mouseout', targetEl, {passive:true,capture:false}))
const mouseMoves$ = fromEvent('mousemove', targetEl, {passive: passiveEventsHandlers, capture: false}) // .takeUntil(mouseLeaves$) // altMouseMoves(fromEvent(targetEl, 'mousemove')).takeUntil(mouseLeaves$)
const rightClicks$ = fromEvent('contextmenu', targetEl, {passive: !options.preventMenu, capture: false})
const touchStarts$ = fromEvent('touchstart', targetEl, {passive: passiveEventsHandlers, capture: false})
const touchMoves$ = fromEvent('touchmove', targetEl, {passive: passiveEventsHandlers, capture: false})
const touchEnds$ = fromEvent('touchend', targetEl, {passive: passiveEventsHandlers, capture: false})
const pointerDowns$ = merge(mouseDowns$, touchStarts$) // mouse & touch interactions starts
const pointerUps$ = merge(mouseUps$, touchEnds$) // mouse & touch interactions ends
const pointerMoves$ = merge(mouseMoves$, touchMoves$.filter(t => t.touches.length === 1))
function preventAllScrolls (targetEl) {
fromEvent('mousewheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('DOMMouseScroll', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('wheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('touchmove', targetEl, {passive: false, capture: false}).forEach(preventDefault)
}
function createView(db, name, html, schema, siblings) {
let emitter = new Emitter()
let stream = most.fromEvent('patch', emitter)
let self
let props = {
// Find what props are required based on the schema
// e.g. /foo//bar - "id" will be a required prop
// on the component
//
required: [],
// Linking the required props with the data paths
// from the schema
schema: {},
// On instance props that correlate with data paths
// A higher-order stream (stream whose events are themselves streams)
// A mousedown DOM event generates a stream event which is
// a stream of 1 GRAB followed by DRAGS (ie mousemoves).
var drag = most.fromEvent('mousedown', draggable)
.map(function(e) {
return most.fromEvent('mousemove', e.target)
.map(function(e) {
return eventToDragInfo(DRAG, e);
})
.startWith(eventToDragInfo(GRAB, e));
});
// A mouseup DOM event generates a stream event which is a
// stream containing a DROP
var drop = most.fromEvent('mouseup', draggable)
.map(function(e) {
return most.of(eventToDragInfo(DROP, e));
});
// Merge the drag and drop streams
// Then use switch() to ensure that the resulting stream behaves
// like the drag stream until an event occurs on the drop stream. Then
// it will behave like the drop stream until the drag stream starts
// producing events again.
// This effectively *toggles behavior* between dragging behavior and
// dropped behavior.
most.merge(drag, drop)
.switch()
.reduce(handleDrag, offset(draggable));
};
module.exports = function run() {
var circle = document.querySelector('.circle');
var transformProp = sniffTransformStyleProp(circle);
var s = window.getComputedStyle(circle);
var w = parseInt(s.width, 10)/2;
var h = parseInt(s.height, 10)/2;
// Number of mouse tails (circles) to create
var nTails = 100;
// Stream mouse movements and turn them into translate3d style rules
var mousemoves = most.fromEvent('mousemove', document).map(toTranslate3d);
// Unfold nTails circles.
// Merge the flurry of circles into one stream, and start observing it
// so it will actually run (streams are lazy: when not observing
// then, they are inert!)
most.unfold(unfoldTail, 0).take(nTails).join().drain();
function unfoldTail(x) {
return { value: makeDelayedTail(x*100, colorGenerator()), seed: x+1 };
}
// Move a circle by setting its css transform to the provided translate3d
function translate(circle, tx) {
circle.style[transformProp] = tx;
return circle;
}
function preventAllScrolls (targetEl) {
fromEvent('mousewheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('DOMMouseScroll', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('wheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('touchmove', targetEl, {passive: false, capture: false}).forEach(preventDefault)
}
}
}
//no topics is allowed for produce only streams
this.topicName = topicName || [];
this.kafka = kafka;
this.storage = storage;
this.isClone = isClone;
if (!(this.storage instanceof KStorage)) {
throw new Error("storage must be an instance of KStorage.");
}
this._ee = new EventEmitter();
this.stream$ = most.fromEvent(MESSAGE, this._ee);
this.produceAsTopic = false;
this.outputTopicName = null;
this.outputPartitionsCount = 1;
this.produceType = PRODUCE_TYPES.SEND;
this.produceVersion = 1;
this.produceCompressionType = 0;
this._kafkaStreams = null;
this.PRODUCE_TYPES = PRODUCE_TYPES;
this.DEFAULT_AUTO_FLUSH_BUFFER_SIZE = DEFAULT_AUTO_FLUSH_BUFFER_SIZE;
}
function preventAllScrolls (targetEl) {
fromEvent('mousewheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('DOMMouseScroll', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('wheel', targetEl, {passive: false, capture: false}).forEach(preventDefault)
fromEvent('touchmove', targetEl, {passive: false, capture: false}).forEach(preventDefault)
}