Commit 88db356e authored by rockyl's avatar rockyl

ScrollContainer互斥处理

parent 7127aca9
......@@ -1727,7 +1727,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
node[targetKey] = value;
}
function getDataByPath(scope, path, throwException) {
var func = new Function('scope', "return scope" + (path === undefined ? '' : ('.' + path)));
var func = new Function('scope', "return scope" + (path ? ('.' + path) : ''));
try {
return func(scope);
}
......@@ -11073,6 +11073,18 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return EditableText;
}(TextField));
var queue = [];
function registerScrollInstance(scrollContainer) {
while (queue.length > 0) {
var item = queue.shift();
if (scrollContainer) {
item.cancelScroll();
}
}
if (scrollContainer) {
queue.push(scrollContainer);
}
}
var ScrollContainer = (function (_super) {
tslib_1.__extends(ScrollContainer, _super);
function ScrollContainer(maxDistance, isFull) {
......@@ -11228,6 +11240,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
s.maskObj.endFill();
this.updateDirection();
};
ScrollContainer.prototype.cancelScroll = function () {
this.isMouseDownState = 0;
};
ScrollContainer.prototype.onMouseEvent = function (e) {
var s = this;
var view = s.viewPort;
......@@ -11246,8 +11261,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
s.speed = 0;
s.isMouseDownState = 1;
registerScrollInstance(this);
}
else if (e.type == MouseEvent.MOUSE_MOVE) {
console.log(this.name);
if (s.isMouseDownState == 0)
return;
if (s.isMouseDownState == 1) {
......@@ -11294,6 +11311,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
s.dispatchEvent(Event.ON_SCROLL_STOP);
}
s.isMouseDownState = 0;
registerScrollInstance();
}
};
ScrollContainer.prototype.scrollTo = function (dis, time) {
......@@ -12883,6 +12901,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return launchWithConfig(config, onAssetsProgress, onAssetsComplete);
});
}
function launchWithLocalStorage(id, onAssetsProgress, onAssetsComplete) {
var storeKey = 'preview-project-' + id;
var data = localStorage.getItem(storeKey);
var dataObj = JSON.parse(data);
return launchWithConfig(dataObj, onAssetsProgress, onAssetsComplete);
}
function launchWithConfig(config, onAssetsProgress, onAssetsComplete) {
return new Promise(function (resolve) {
var _a = config.options, containerID = _a.containerID, designWidth = _a.designWidth, designHeight = _a.designHeight, frameRate = _a.frameRate, scaleMode = _a.scaleMode, rendererType = _a.rendererType;
......@@ -12973,6 +12997,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports.jsonp = jsonp;
exports.launch = launch;
exports.launchWithConfig = launchWithConfig;
exports.launchWithLocalStorage = launchWithLocalStorage;
exports.linkedFlag = linkedFlag;
exports.md5 = md5;
exports.nodeScheme = nodeScheme;
......
This diff is collapsed.
......@@ -6,6 +6,20 @@ import {SCROLL_DIRECTION} from "../const";
// import Tween from "../../tweenSimple/Tween";
let queue: ScrollContainer[] = [];
function registerScrollInstance(scrollContainer?) {
while (queue.length > 0) {
let item = queue.shift();
if(scrollContainer){
item.cancelScroll();
}
}
if(scrollContainer){
queue.push(scrollContainer);
}
}
/**
* 滚动视图
* @class ScrollPage
......@@ -275,7 +289,7 @@ export class ScrollContainer extends Container {
this.updateDirection();
}
protected updateDirection(){
protected updateDirection() {
let s = this;
if (this._direction === SCROLL_DIRECTION.VERTICAL) {
s.distance = s.height;
......@@ -304,6 +318,10 @@ export class ScrollContainer extends Container {
this.updateDirection();
}
cancelScroll() {
this.isMouseDownState = 0;
}
private onMouseEvent(e: MouseEvent): void {
let s = this;
let view: any = s.viewPort;
......@@ -323,7 +341,10 @@ export class ScrollContainer extends Container {
}
s.speed = 0;
s.isMouseDownState = 1;
registerScrollInstance(this);
} else if (e.type == MouseEvent.MOUSE_MOVE) {
console.log(this.name);
if (s.isMouseDownState == 0) return;
if (s.isMouseDownState == 1) {
s.dispatchEvent(Event.ON_SCROLL_START);
......@@ -365,6 +386,8 @@ export class ScrollContainer extends Container {
s.dispatchEvent(Event.ON_SCROLL_STOP);
}
s.isMouseDownState = 0;
registerScrollInstance();
}
// }
}
......
......@@ -27,6 +27,13 @@ export function launch(url, onAssetsProgress, onAssetsComplete) {
)
}
export function launchWithLocalStorage(id, onAssetsProgress, onAssetsComplete){
const storeKey = 'preview-project-' + id;
let data = localStorage.getItem(storeKey);
let dataObj = JSON.parse(data);
return launchWithConfig(dataObj, onAssetsProgress, onAssetsComplete);
}
export function launchWithConfig(config, onAssetsProgress, onAssetsComplete) {
return new Promise(resolve => {
......
......@@ -45,7 +45,7 @@ export function propertyParse(key, node, properties) {
* @param throwException
*/
export function getDataByPath(scope, path, throwException?) {
let func = new Function('scope', `return scope` + (path === undefined ? '' : ('.' + path)));
let func = new Function('scope', `return scope` + (path ? ('.' + path) : ''));
try {
return func(scope);
} catch (e) {
......
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