mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
chore: remove deprecated functionality for v10 (#7077)
* chore: remove deprecated functionality in events files * chore: remove deprecated items in renderers * chore: remove deprecated items in core * chore: remove mixin deprecation * chore: fix tests after removing deprecations
This commit is contained in:
106
core/touch.ts
106
core/touch.ts
@@ -8,19 +8,6 @@ import * as goog from '../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.Touch');
|
||||
|
||||
import type {Gesture} from './gesture.js';
|
||||
import * as deprecation from './utils/deprecation.js';
|
||||
|
||||
/**
|
||||
* A mock event, created from either a mouse or touch event,
|
||||
* with no more than one entry in the changedTouches array.
|
||||
*/
|
||||
interface PseudoEvent {
|
||||
type: string;
|
||||
changedTouches: Touch[];
|
||||
target: Element;
|
||||
stopPropagation: () => void;
|
||||
preventDefault: () => void;
|
||||
}
|
||||
|
||||
/** Length in ms for a touch to become a long press. */
|
||||
const LONGPRESS = 750;
|
||||
@@ -167,96 +154,3 @@ export function checkTouchIdentifier(e: PointerEvent): boolean {
|
||||
// pointer was down.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an event's clientX and clientY from its first changed touch. Use this to
|
||||
* make a touch event work in a mouse event handler.
|
||||
*
|
||||
* @param e A touch event.
|
||||
*/
|
||||
export function setClientFromTouch(e: Event | PseudoEvent) {
|
||||
deprecation.warn('setClientFromTouch()', 'version 9', 'version 10');
|
||||
// AnyDuringMigration because: Property 'changedTouches' does not exist on
|
||||
// type 'PseudoEvent | Event'.
|
||||
if (e.type.startsWith('touch') && (e as AnyDuringMigration).changedTouches) {
|
||||
// Map the touch event's properties to the event.
|
||||
// AnyDuringMigration because: Property 'changedTouches' does not exist on
|
||||
// type 'PseudoEvent | Event'.
|
||||
const touchPoint = (e as AnyDuringMigration).changedTouches[0];
|
||||
// AnyDuringMigration because: Property 'clientX' does not exist on type
|
||||
// 'PseudoEvent | Event'.
|
||||
(e as AnyDuringMigration).clientX = touchPoint.clientX;
|
||||
// AnyDuringMigration because: Property 'clientY' does not exist on type
|
||||
// 'PseudoEvent | Event'.
|
||||
(e as AnyDuringMigration).clientY = touchPoint.clientY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a given event is a mouse, touch, or pointer event.
|
||||
*
|
||||
* @param e An event.
|
||||
* @returns True if it is a mouse, touch, or pointer event; false otherwise.
|
||||
*/
|
||||
export function isMouseOrTouchEvent(e: Event | PseudoEvent): boolean {
|
||||
deprecation.warn('isMouseOrTouchEvent()', 'version 9', 'version 10');
|
||||
return (
|
||||
e.type.startsWith('touch') ||
|
||||
e.type.startsWith('mouse') ||
|
||||
e.type.startsWith('pointer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a given event is a touch event or a pointer event.
|
||||
*
|
||||
* @param e An event.
|
||||
* @returns True if it is a touch or pointer event; false otherwise.
|
||||
*/
|
||||
export function isTouchEvent(e: Event | PseudoEvent): boolean {
|
||||
deprecation.warn('isTouchEvent()', 'version 9', 'version 10');
|
||||
return e.type.startsWith('touch') || e.type.startsWith('pointer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Split an event into an array of events, one per changed touch or mouse
|
||||
* point.
|
||||
*
|
||||
* @param e A mouse event or a touch event with one or more changed touches.
|
||||
* @returns An array of events or pseudo events.
|
||||
* Each pseudo-touch event will have exactly one changed touch and there
|
||||
* will be no real touch events.
|
||||
*/
|
||||
export function splitEventByTouches(e: Event): Array<Event | PseudoEvent> {
|
||||
deprecation.warn('splitEventByTouches()', 'version 9', 'version 10');
|
||||
const events = [];
|
||||
// AnyDuringMigration because: Property 'changedTouches' does not exist on
|
||||
// type 'PseudoEvent | Event'.
|
||||
if ((e as AnyDuringMigration).changedTouches) {
|
||||
// AnyDuringMigration because: Property 'changedTouches' does not exist on
|
||||
// type 'PseudoEvent | Event'.
|
||||
for (let i = 0; i < (e as AnyDuringMigration).changedTouches.length; i++) {
|
||||
const newEvent = {
|
||||
type: e.type,
|
||||
// AnyDuringMigration because: Property 'changedTouches' does not exist
|
||||
// on type 'PseudoEvent | Event'.
|
||||
changedTouches: [(e as AnyDuringMigration).changedTouches[i]],
|
||||
target: e.target,
|
||||
stopPropagation() {
|
||||
e.stopPropagation();
|
||||
},
|
||||
preventDefault() {
|
||||
e.preventDefault();
|
||||
},
|
||||
};
|
||||
events[i] = newEvent;
|
||||
}
|
||||
} else {
|
||||
events.push(e);
|
||||
}
|
||||
// AnyDuringMigration because: Type '(Event | { type: string; changedTouches:
|
||||
// Touch[]; target: EventTarget | null; stopPropagation(): void;
|
||||
// preventDefault(): void; })[]' is not assignable to type '(PseudoEvent |
|
||||
// Event)[]'.
|
||||
return events as AnyDuringMigration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user