123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _cc, _decorator, Component, Input, _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _crd, cc, ccclass, property, ClickPenetrate;
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
- return {
- setters: [function (_cc2) {
- _cclegacy = _cc2.cclegacy;
- __checkObsolete__ = _cc2.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc2.__checkObsoleteInNamespace__;
- _cc = _cc2;
- _decorator = _cc2._decorator;
- Component = _cc2.Component;
- Input = _cc2.Input;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "739bfHpcHtB3IXOkilm3JV7", "ClickPenetrate", undefined);
- cc = __checkObsoleteInNamespace__(_cc);
- __checkObsolete__(['_decorator', 'Component', 'Button', 'Input']);
- ({
- ccclass,
- property
- } = _decorator);
- /*** 按钮 点击穿透*/
- _export("ClickPenetrate", ClickPenetrate = (_dec = ccclass('ClickPenetrate'), _dec2 = property({
- tooltip: "滑动会关闭 end 触摸事件"
- }), _dec3 = property({
- tooltip: "触摸开始",
- type: cc.EventHandler
- }), _dec4 = property({
- tooltip: "触摸移动",
- type: cc.EventHandler
- }), _dec5 = property({
- tooltip: "触摸结束",
- type: cc.EventHandler
- }), _dec(_class = (_class2 = class ClickPenetrate extends Component {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "move_began_end", _descriptor, this);
- _initializerDefineProperty(this, "on_touch_began", _descriptor2, this);
- _initializerDefineProperty(this, "on_touch_move", _descriptor3, this);
- _initializerDefineProperty(this, "on_touch_end", _descriptor4, this);
- // @property({ tooltip: "触摸关闭", type: cc.EventHandler })
- // private on_touch_cancel: Array<cc.EventHandler> = [];
- this.has_began = false;
- this.comp_btn = null;
- /** 是移动状态 */
- this.is_move = null;
- /** 本次点击所移动的距离 */
- this.delta = new cc.Vec2(0, 0);
- }
- onLoad() {
- this.comp_btn = this.node.getComponent(cc.Button) || this.node.addComponent(cc.Button);
- this.comp_btn.node.on(Input.EventType.TOUCH_START, this.onTouchBegan, this);
- this.comp_btn.node.on(Input.EventType.TOUCH_MOVE, this.onTouchMoved, this);
- this.comp_btn.node.on(Input.EventType.TOUCH_END, this.onTouchEnded, this);
- this.comp_btn.node.on(Input.EventType.TOUCH_CANCEL, this.onTouchCancelled, this);
- }
- onTouchBegan(touch, param) {
- touch.preventSwallow = true;
- this.has_began = true;
- this.is_move = false;
- this.delta = new cc.Vec2(0, 0);
- this.on_touch_began.forEach((value, key) => {
- value.emit([this.comp_btn]);
- });
- }
- onTouchMoved(touch, param) {
- touch.preventSwallow = true;
- if (!this.has_began) return;
- this.on_touch_move.forEach((value, key) => {
- value.emit([this.comp_btn]);
- });
- var delta = touch.getDelta();
- this.delta.x += delta.x;
- this.delta.y += delta.y;
- var distance = this.delta.length();
- if (distance >= 20) this.is_move = true; // 滑动超过20像素,算作点击
- }
- onTouchEnded(touch, param) {
- touch.preventSwallow = true;
- if (!this.has_began) return;
- if (this.move_began_end && this.is_move) return;
- this.on_touch_end.forEach((value, key) => {
- value.emit([this.comp_btn]);
- });
- this.has_began = false;
- this.is_move = false;
- }
- onTouchCancelled(touch, param) {
- touch.preventSwallow = true;
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "move_began_end", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return false;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_began", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return [];
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_move", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return [];
- }
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_end", [_dec5], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return [];
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=00bc06e1ef9ef9a537acb68ddb8ba0d00efcfee1.js.map
|