本文整理汇总了TypeScript中@ephox/sugar.DomEvent.bind方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DomEvent.bind方法的具体用法?TypeScript DomEvent.bind怎么用?TypeScript DomEvent.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.DomEvent
的用法示例。
在下文中一共展示了DomEvent.bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Chain.on(function (element, next, die) {
const unbindMouseMove = DomEvent.bind(element, 'mousemove', function (e) {
Clicks.mouseup(element);
unbindMouseMove();
next(Chain.wrap(element));
}).unbind;
const unbindMouseDown = DomEvent.bind(element, 'mousedown', function (e) {
Clicks.mousemove(element); // not sure if xy actually matters here
unbindMouseDown();
}).unbind;
Clicks.mousedown(element);
})
示例2: function
const setup = function (outerWindow, cWin) {
const cBody = Element.fromDom(cWin.document.body);
const toEditing = function () {
// TBIO-3816 throttling the resume was causing keyboard hide/show issues with undo/redo
// throttling was introduced to work around a different keyboard hide/show issue, where
// async uiChanged in Processor in polish was causing keyboard hide, which no longer seems to occur
ResumeEditing.resume(cWin);
};
const onResize = DomEvent.bind(Element.fromDom(outerWindow), 'resize', function () {
findDelta(outerWindow, cBody).each(function (delta) {
getBounds(cWin).each(function (bounds) {
// If the top is offscreen, scroll it into view.
const cScrollBy = calculate(cWin, bounds, delta);
if (cScrollBy !== 0) {
cWin.scrollTo(cWin.pageXOffset, cWin.pageYOffset + cScrollBy);
}
});
});
setLastHeight(cBody, outerWindow.innerHeight);
});
setLastHeight(cBody, outerWindow.innerHeight);
const destroy = function () {
onResize.unbind();
};
return {
toEditing,
destroy
};
};
示例3: function
const stubborn = function (outerBody, cWin, page, frame/*, toolstrip, toolbar*/) {
const toEditing = function () {
ResumeEditing.resume(cWin, frame);
};
const toReading = function () {
CaptureBin.input(outerBody, Focus.blur);
};
const captureInput = DomEvent.bind(page, 'keydown', function (evt) {
// Think about killing the event.
if (! Arr.contains([ 'input', 'textarea' ], Node.name(evt.target()))) {
// FIX: Close the menus
// closeMenus()
toEditing();
}
});
const onToolbarTouch = function (/* event */) {
// Do nothing
};
const destroy = function () {
captureInput.unbind();
};
return {
toReading,
toEditing,
onToolbarTouch,
destroy
};
};
示例4: function
const exclusive = function (scope, selector) {
return DomEvent.bind(scope, 'touchmove', function (event) {
SelectorFind.closest(event.target(), selector).filter(hasScroll).fold(function () {
event.raw().preventDefault();
}, Fun.noop);
});
};
示例5: function
return Step.stateful(function (_, next, die) {
const onKeydown = DomEvent.bind(body, 'keydown', function (event) {
newState.log.push('keydown.to.body: ' + event.raw().which);
});
const log = [ ];
const newState = {
log,
onKeydown
};
next(newState);
});
示例6: handleMessage
AlloyEvents.runOnAttached(() => {
const unbind = DomEvent.bind(Element.fromDom(window), 'message', (e) => {
// Validate that the request came from the correct domain
if (iframeUri.isSameOrigin(new URI(e.raw().origin))) {
const data = e.raw().data;
// Handle the message if it has the 'mceAction' key, otherwise just ignore it
if (isSupportedMessage(data)) {
handleMessage(editor, instanceApi, data);
} else if (isCustomMessage(data)) {
internalDialog.onMessage(instanceApi, data);
}
}
});
messageHandlerUnbinder.set(Option.some(unbind));
}),
示例7: function
const onChange = function (outerWindow, listeners) {
const win = Element.fromDom(outerWindow);
let poller = null;
const change = function () {
// If a developer is spamming orientation events in the simulator, clear our last check
clearInterval(poller);
const orientation = get(outerWindow);
listeners.onChange(orientation);
onAdjustment(function () {
// We don't care about whether there was a resize or not.
listeners.onReady(orientation);
});
};
const orientationHandle = DomEvent.bind(win, 'orientationchange', change);
const onAdjustment = function (f) {
// If a developer is spamming orientation events in the simulator, clear our last check
clearInterval(poller);
const flag = outerWindow.innerHeight;
let insurance = 0;
poller = setInterval(function () {
if (flag !== outerWindow.innerHeight) {
clearInterval(poller);
f(Option.some(outerWindow.innerHeight));
} else if (insurance > INSURANCE) {
clearInterval(poller);
f(Option.none());
}
insurance++;
}, INTERVAL);
};
const destroy = function () {
orientationHandle.unbind();
};
return {
onAdjustment,
destroy
};
};
示例8: getBoxElement
editor.on('init', () => {
const scroller = editor.getBody().ownerDocument.defaultView;
// FIX: make a lot nicer.
const onScroll = DomEvent.bind(Element.fromDom(scroller), 'scroll', () => {
lastAnchor.get().each((anchor) => {
const elem = lastElement.get().getOr(editor.selection.getNode());
const nodeBounds = elem.getBoundingClientRect();
const contentAreaBounds = editor.contentAreaContainer.getBoundingClientRect();
const aboveEditor = nodeBounds.bottom < 0;
const belowEditor = nodeBounds.top > contentAreaBounds.height;
if (aboveEditor || belowEditor) {
Css.set(contextbar.element(), 'display', 'none');
} else {
Css.remove(contextbar.element(), 'display');
Positioning.positionWithin(sink, anchor, contextbar, getBoxElement());
}
});
});
editor.on('remove', () => {
onScroll.unbind();
});
});
示例9: function
export default function (win, frame) {
// NOTE: This may be required for android also.
/*
* FakeSelection is used to draw rectangles around selection so that when the content loses
* focus, the selection is still visible. The selections should match the current content
* selection, and be removed as soon as the user clicks on them (because the content will
* get focus again)
*/
const doc = win.document;
const container = Element.fromTag('div');
Class.add(container, Styles.resolve('unfocused-selections'));
Insert.append(Element.fromDom(doc.documentElement), container);
const onTouch = DomEvent.bind(container, 'touchstart', function (event) {
// We preventDefault the event incase the touch is between 2 letters creating a new collapsed selection,
// in this very specific case we just want to turn the fake cursor into a real cursor. Remember that
// touchstart may be used to dimiss popups too, so don't kill it completely, just prevent its
// default native selection
event.prevent();
ResumeEditing.resume(win, frame);
clear();
});
const make = function (rectangle) {
const span = Element.fromTag('span');
Classes.add(span, [ Styles.resolve('layer-editor'), Styles.resolve('unfocused-selection') ]);
Css.setAll(span, {
left: rectangle.left() + 'px',
top: rectangle.top() + 'px',
width: rectangle.width() + 'px',
height: rectangle.height() + 'px'
});
return span;
};
const update = function () {
clear();
const rectangles = Rectangles.getRectangles(win);
const spans = Arr.map(rectangles, make);
InsertAll.append(container, spans);
};
const clear = function () {
Remove.empty(container);
};
const destroy = function () {
onTouch.unbind();
Remove.remove(container);
};
const isActive = function () {
return Traverse.children(container).length > 0;
};
return {
update,
isActive,
destroy,
clear
};
}
示例10: function
return function (handler) {
return DomEvent.bind(doc, type, handler);
};