本文整理匯總了TypeScript中vs/base/browser/globalMouseMoveMonitor.GlobalMouseMoveMonitor.startMonitoring方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript GlobalMouseMoveMonitor.startMonitoring方法的具體用法?TypeScript GlobalMouseMoveMonitor.startMonitoring怎麽用?TypeScript GlobalMouseMoveMonitor.startMonitoring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/browser/globalMouseMoveMonitor.GlobalMouseMoveMonitor
的用法示例。
在下文中一共展示了GlobalMouseMoveMonitor.startMonitoring方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _sliderMouseDown
private _sliderMouseDown(e: IMouseEvent): void {
if (e.leftButton) {
let initialMouseOrthogonalPosition = this._sliderOrthogonalMousePosition(e);
let initialScrollPosition = this._getScrollPosition();
let draggingDelta = this._sliderMousePosition(e) - this._scrollbarState.getSliderPosition();
this.slider.toggleClassName('active', true);
this._mouseMoveMonitor.startMonitoring(
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
let mouseOrthogonalPosition = this._sliderOrthogonalMousePosition(mouseMoveData);
let mouseOrthogonalDelta = Math.abs(mouseOrthogonalPosition - initialMouseOrthogonalPosition);
// console.log(initialMouseOrthogonalPosition + ' -> ' + mouseOrthogonalPosition + ': ' + mouseOrthogonalDelta);
if (Platform.isWindows && mouseOrthogonalDelta > MOUSE_DRAG_RESET_DISTANCE) {
// The mouse has wondered away from the scrollbar => reset dragging
this.setDesiredScrollPosition(initialScrollPosition);
} else {
let desiredSliderPosition = this._sliderMousePosition(mouseMoveData) - draggingDelta;
this.setDesiredScrollPosition(this._scrollbarState.convertSliderPositionToScrollPosition(desiredSliderPosition));
}
},
() => {
this.slider.toggleClassName('active', false);
this._host.onDragEnd();
}
);
e.preventDefault();
this._host.onDragStart();
}
}
示例2: _sliderMouseDown
private _sliderMouseDown(e: ISimplifiedMouseEvent, onDragFinished: () => void): void {
const initialMousePosition = this._sliderMousePosition(e);
const initialMouseOrthogonalPosition = this._sliderOrthogonalMousePosition(e);
const initialScrollbarState = this._scrollbarState.clone();
this.slider.toggleClassName('active', true);
this._mouseMoveMonitor.startMonitoring(
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
const mouseOrthogonalPosition = this._sliderOrthogonalMousePosition(mouseMoveData);
const mouseOrthogonalDelta = Math.abs(mouseOrthogonalPosition - initialMouseOrthogonalPosition);
if (Platform.isWindows && mouseOrthogonalDelta > MOUSE_DRAG_RESET_DISTANCE) {
// The mouse has wondered away from the scrollbar => reset dragging
this._setDesiredScrollPositionNow(initialScrollbarState.getScrollPosition());
return;
}
const mousePosition = this._sliderMousePosition(mouseMoveData);
const mouseDelta = mousePosition - initialMousePosition;
this._setDesiredScrollPositionNow(initialScrollbarState.getDesiredScrollPositionFromDelta(mouseDelta));
},
() => {
this.slider.toggleClassName('active', false);
this._host.onDragEnd();
onDragFinished();
}
);
this._host.onDragStart();
}
示例3: _arrowMouseDown
private _arrowMouseDown(e: StandardMouseEvent): void {
let repeater = () => {
this._parent.onMouseWheel(this._mouseWheelEventFactory());
};
let scheduleRepeater = () => {
this._mousedownRepeatTimer.cancelAndSet(repeater, 1000 / 24);
};
repeater();
this._mousedownRepeatTimer.cancel();
this._mousedownScheduleRepeatTimer.cancelAndSet(scheduleRepeater, 200);
this._mouseMoveMonitor.startMonitoring(
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
/* Intentional empty */
},
() => {
this._mousedownRepeatTimer.cancel();
this._mousedownScheduleRepeatTimer.cancel();
}
);
e.preventDefault();
}
示例4: saturationListener
private saturationListener(e: MouseEvent, monitor: GlobalMouseMoveMonitor<IStandardMouseMoveEventData>): void {
if (e.button !== 0) { // Only left click is allowed
return;
}
const updateModel = (x: number, y: number) => {
const saturationRGBA = this.saturationBox.extractColor(x, y).toRGBA();
this.widget.model.color = Color.fromRGBA(new RGBA(saturationRGBA.r, saturationRGBA.g, saturationRGBA.b, this.widget.model.opacity * 255)); // TODO@Michel store opacity in [0-255] instead
this.saturationBox.focusSaturationSelection({ x: x, y: y });
};
let newSaturationX, newSaturationY;
if (e.target !== this.saturationBox.saturationSelection) {
newSaturationX = e.offsetX;
newSaturationY = e.offsetY;
updateModel(newSaturationX, newSaturationY);
} else { // If clicked on the selection circle
newSaturationX = this.widget.model.saturationSelection.x;
newSaturationY = this.widget.model.saturationSelection.y;
}
const initialMousePosition = e.clientY;
const initialMouseOrthogonalPosition = e.clientX;
monitor.startMonitoring(standardMouseMoveMerger, (mouseMoveData: IStandardMouseMoveEventData) => {
const deltaX = mouseMoveData.posx - initialMouseOrthogonalPosition;
const deltaY = mouseMoveData.posy - initialMousePosition;
const x = newSaturationX + deltaX;
const y = newSaturationY + deltaY;
updateModel(x, y);
}, () => null);
}
示例5: stripListener
private stripListener(element: HTMLElement, e: MouseEvent, monitor: GlobalMouseMoveMonitor<IStandardMouseMoveEventData>) {
if (e.button !== 0) { // Only left click is allowed
return;
}
const slider = element === this.hueStrip ? this.hueSlider : this.opacitySlider;
const strip = element === this.hueStrip ? this.hueStrip : this.opacityStrip;
// Update slider position if clicked on a strip itself
if (e.target === this.hueStrip || e.target === this.opacityStrip) {
slider.top = e.offsetY;
}
const updateModel = () => {
if (slider === this.hueSlider) {
this.widget.model.hue = this.calculateSliderHue(slider);
} else if (slider === this.opacitySlider) {
this.widget.model.opacity = this.calculateOpacity(slider);
}
};
updateModel();
const initialMousePosition = e.clientY;
const initialMouseOrthogonalPosition = e.clientX;
const initialSliderTop = slider.top;
monitor.startMonitoring(standardMouseMoveMerger, (mouseMoveData: IStandardMouseMoveEventData) => {
strip.style.cursor = '-webkit-grabbing';
// Do not move slider on Windows if it's outside of movable bounds
const mouseOrthogonalDelta = Math.abs(mouseMoveData.posx - initialMouseOrthogonalPosition);
if (isWindows && mouseOrthogonalDelta > MOUSE_DRAG_RESET_DISTANCE) {
slider.top = 0;
if (slider === this.hueSlider) {
this.widget.model.hue = 0;
} else if (slider === this.opacitySlider) {
this.widget.model.opacity = 1;
}
return;
}
const mouseDelta = mouseMoveData.posy - initialMousePosition;
slider.top = initialSliderTop + mouseDelta;
updateModel();
}, () => {
strip.style.cursor = '-webkit-grab';
});
}
示例6: _arrowMouseDown
private _arrowMouseDown(e: IMouseEvent): void {
let scheduleRepeater = () => {
this._mousedownRepeatTimer.cancelAndSet(() => this._onActivate(), 1000 / 24);
};
this._onActivate();
this._mousedownRepeatTimer.cancel();
this._mousedownScheduleRepeatTimer.cancelAndSet(scheduleRepeater, 200);
this._mouseMoveMonitor.startMonitoring(
standardMouseMoveMerger,
(mouseMoveData: IStandardMouseMoveEventData) => {
/* Intentional empty */
},
() => {
this._mousedownRepeatTimer.cancel();
this._mousedownScheduleRepeatTimer.cancel();
}
);
e.preventDefault();
}
示例7: startMonitoring
public startMonitoring(merger: EditorMouseEventMerger, mouseMoveCallback: (e: EditorMouseEvent) => void, onStopCallback: () => void): void {
let myMerger: dom.IEventMerger<EditorMouseEvent> = (lastEvent: EditorMouseEvent, currentEvent: MouseEvent): EditorMouseEvent => {
return merger(lastEvent, new EditorMouseEvent(currentEvent, this._editorViewDomNode));
};
this._globalMouseMoveMonitor.startMonitoring(myMerger, mouseMoveCallback, onStopCallback);
}