Commit 620d3045 authored by rockyl's avatar rockyl

修复遮罩嵌套问题

修改滚动方向
parent e0aba4ed
......@@ -541,6 +541,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
})(exports.GC_MODES || (exports.GC_MODES = {}));
var URL_FILE_EXTENSION = /\.(\w{3,4})(?:$|\?|#)/i;
var DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
(function (SCROLL_DIRECTION) {
SCROLL_DIRECTION["HORIZONTAL"] = "horizontal";
SCROLL_DIRECTION["VERTICAL"] = "vertical";
})(exports.SCROLL_DIRECTION || (exports.SCROLL_DIRECTION = {}));
var Matrix = (function (_super) {
tslib_1.__extends(Matrix, _super);
......@@ -6742,9 +6746,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
gl.colorMask(false, false, false, false);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
graphics.renderable = true;
var tempAlpha = graphics.worldAlpha;
graphics.worldAlpha = 1;
graphics.renderWebGL(this.renderer);
this.renderer.batchManager.flush();
graphics.renderable = false;
graphics.worldAlpha = tempAlpha;
this._useCurrent();
}
};
......@@ -10324,7 +10331,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this._textAlign = exports.TEXT_ALIGN.LEFT;
_this._verticalAlign = exports.VERTICAL_ALIGN.UP;
_this._lineSpacing = 14;
_this._lineType = exports.TEXT_lINETYPE.MULTI;
_this._lineType = exports.TEXT_lINETYPE.SINGLE;
_this._text = "";
_this._font = "Arial";
_this._size = 12;
......@@ -11068,11 +11075,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var ScrollContainer = (function (_super) {
tslib_1.__extends(ScrollContainer, _super);
function ScrollContainer(maxDistance, isVertical, isFull) {
if (isVertical === void 0) { isVertical = true; }
function ScrollContainer(maxDistance, isFull) {
if (isFull === void 0) { isFull = false; }
var _this = _super.call(this) || this;
_this.isVertical = true;
_this.distance = 0;
_this.minDis = 0;
_this.maskObj = new Graphics();
......@@ -11097,7 +11102,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
s.maskObj.isUsedToMask = false;
}
s.maskObj.alpha = 0;
s.updateViewRect(isVertical);
s.updateViewRect();
s.direction = exports.SCROLL_DIRECTION.VERTICAL;
s.addEventListener(Event.ADDED_TO_STAGE, function (e) {
s.stage.addEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
});
......@@ -11188,16 +11194,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
enumerable: true,
configurable: true
});
ScrollContainer.prototype.updateViewRect = function (isVertical) {
Object.defineProperty(ScrollContainer.prototype, "direction", {
get: function () {
return this._direction;
},
set: function (value) {
this._direction = value;
var s = this;
s.maskObj.clear();
s.maskObj.beginFill("#000000");
s.maskObj.drawRect(0, 0, s.width, s.height);
s.maskObj.endFill();
if (isVertical !== undefined) {
s.isVertical = isVertical;
}
if (isVertical) {
if (value === exports.SCROLL_DIRECTION.VERTICAL) {
s.distance = s.height;
s.paramXY = "y";
}
......@@ -11205,6 +11209,16 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
s.distance = s.width;
s.paramXY = "x";
}
},
enumerable: true,
configurable: true
});
ScrollContainer.prototype.updateViewRect = function () {
var s = this;
s.maskObj.clear();
s.maskObj.beginFill("#000000");
s.maskObj.drawRect(0, 0, s.width, s.height);
s.maskObj.endFill();
};
ScrollContainer.prototype.onMouseEvent = function (e) {
var s = this;
......@@ -11216,7 +11230,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
if (s.autoScroll) {
s.autoScroll = false;
}
if (s.isVertical) {
if (s._direction === exports.SCROLL_DIRECTION.VERTICAL) {
s.lastValue = e.localY;
}
else {
......@@ -11233,7 +11247,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
s.isMouseDownState = 2;
var currentValue = void 0;
if (s.isVertical) {
if (s._direction === exports.SCROLL_DIRECTION.VERTICAL) {
currentValue = e.localY;
}
else {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -423,4 +423,7 @@ export const URL_FILE_EXTENSION: any = /\.(\w{3,4})(?:$|\?|#)/i;
*/
export const DATA_URI: any = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
export enum SCROLL_DIRECTION {
HORIZONTAL = 'horizontal',
VERTICAL = 'vertical',
}
......@@ -87,9 +87,12 @@ export default class StencilManager {
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
graphics.renderable = true;
var tempAlpha = graphics.worldAlpha;//因为如果alpha为0,不会渲染,
graphics.worldAlpha = 1;
graphics.renderWebGL(this.renderer);
this.renderer.batchManager.flush();
graphics.renderable = false;
graphics.worldAlpha = tempAlpha;
this._useCurrent();
}
}
......
......@@ -229,7 +229,7 @@ export class TextField extends Sprite {
return this._lineType;
}
private _lineType: TEXT_lINETYPE = TEXT_lINETYPE.MULTI;
private _lineType: TEXT_lINETYPE = TEXT_lINETYPE.SINGLE;
/**
* 文本内容
......@@ -573,7 +573,7 @@ export class TextField extends Sprite {
}
lineWidth += charWidth;
}
if(shouldMeasureTextWidth){
if (shouldMeasureTextWidth) {
textWidth = Math.max(lineWidth, textWidth);
}
}
......
......@@ -2,6 +2,7 @@ import Container from "../display/Container";
import Graphics from "../graphics/Graphics";
import {MouseEvent} from "../events/MouseEvent";
import {Event} from "../events/Event";
import {SCROLL_DIRECTION} from "../const";
// import Tween from "../../tweenSimple/Tween";
......@@ -14,14 +15,14 @@ import {Event} from "../events/Event";
*/
export class ScrollContainer extends Container {
/**
* 横向还是纵向 默认为纵
* @property isVertical
* @type {boolean}
* 滚动方
* @property direction
* @type {SCROLL_DIRECTION}
* @private
* @since 1.0.0
* @default true
*/
protected isVertical: boolean = true;
private _direction: SCROLL_DIRECTION;
/**
* 可见区域的宽
* @property viewWidth
......@@ -148,10 +149,8 @@ export class ScrollContainer extends Container {
/**
* 构造函数
* @method ScrollPage
* @param {number} vW 可视区域宽
* @param {number} vH 可视区域高
* @param {number} maxDistance 最大滚动的长度
* @param {boolean} isVertical 是纵向还是横向,也就是说是滚x还是滚y,默认值为沿y方向滚动
* @param isFull
* @example
* var sPage=new ScrollPage(640,s.stage.viewRect.height,4943);
* sPage.isSpringBack = false;//是否回弹
......@@ -160,7 +159,7 @@ export class ScrollContainer extends Container {
* sPage.y=stage.viewRect.y;
*
*/
constructor(maxDistance?: number, isVertical: boolean = true, isFull = false) {
constructor(maxDistance?: number, isFull = false) {
super();
let s: ScrollContainer = this;
s._instanceType = "ScrollContainer";
......@@ -176,10 +175,11 @@ export class ScrollContainer extends Container {
if (maxDistance !== undefined) {
//s.maxDistance = maxDistance;
}
s.updateViewRect(isVertical);
s.updateViewRect();
s.direction = SCROLL_DIRECTION.VERTICAL;
s.addEventListener(Event.ADDED_TO_STAGE, function (e: Event) {
s.stage.addEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
})
});
s.addEventListener(Event.REMOVED_FROM_STAGE, function (e: Event) {
s.stage.removeEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
});
......@@ -263,31 +263,35 @@ export class ScrollContainer extends Container {
return this.viewPort.height;
}
get direction(): SCROLL_DIRECTION {
return this._direction;
}
set direction(value: SCROLL_DIRECTION) {
this._direction = value;
let s = this;
if (value === SCROLL_DIRECTION.VERTICAL) {
s.distance = s.height;
s.paramXY = "y";
} else {
s.distance = s.width;
s.paramXY = "x";
}
}
/**
* 设置可见区域,可见区域的坐标始终在本地坐标中0,0点位置
* @method setViewRect
* @param {number}w 设置可见区域的宽
* @param {number}h 设置可见区域的高
* @param {boolean} isVertical 方向
* @public
* @since 1.1.1
*/
public updateViewRect(isVertical?: boolean): void {
public updateViewRect(): void {
let s: ScrollContainer = this;
s.maskObj.clear();
s.maskObj.beginFill("#000000");
s.maskObj.drawRect(0, 0, s.width, s.height);
s.maskObj.endFill();
if (isVertical !== undefined) {
s.isVertical = isVertical;
}
if (isVertical) {
s.distance = s.height;
s.paramXY = "y";
} else {
s.distance = s.width;
s.paramXY = "x";
}
}
private onMouseEvent(e: MouseEvent): void {
......@@ -302,7 +306,7 @@ export class ScrollContainer extends Container {
s.autoScroll = false;
// Tween.kill(s._tweenId);
}
if (s.isVertical) {
if (s._direction === SCROLL_DIRECTION.VERTICAL) {
s.lastValue = e.localY;
} else {
s.lastValue = e.localX;
......@@ -316,7 +320,7 @@ export class ScrollContainer extends Container {
}
s.isMouseDownState = 2;
let currentValue: number;
if (s.isVertical) {
if (s._direction === SCROLL_DIRECTION.VERTICAL) {
currentValue = e.localY;
} else {
currentValue = e.localX;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment