You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
import {
|
|
createElementID,
|
|
getExpressionInterfaces,
|
|
} from '../utils/common';
|
|
import getBlendMode from '../utils/helpers/blendModes';
|
|
import EffectsManager from '../EffectsManager';
|
|
|
|
function BaseElement() {
|
|
}
|
|
|
|
BaseElement.prototype = {
|
|
checkMasks: function () {
|
|
if (!this.data.hasMask) {
|
|
return false;
|
|
}
|
|
var i = 0;
|
|
var len = this.data.masksProperties.length;
|
|
while (i < len) {
|
|
if ((this.data.masksProperties[i].mode !== 'n' && this.data.masksProperties[i].cl !== false)) {
|
|
return true;
|
|
}
|
|
i += 1;
|
|
}
|
|
return false;
|
|
},
|
|
initExpressions: function () {
|
|
const expressionsInterfaces = getExpressionInterfaces();
|
|
if (!expressionsInterfaces) {
|
|
return;
|
|
}
|
|
const LayerExpressionInterface = expressionsInterfaces('layer');
|
|
const EffectsExpressionInterface = expressionsInterfaces('effects');
|
|
const ShapeExpressionInterface = expressionsInterfaces('shape');
|
|
const TextExpressionInterface = expressionsInterfaces('text');
|
|
const CompExpressionInterface = expressionsInterfaces('comp');
|
|
this.layerInterface = LayerExpressionInterface(this);
|
|
if (this.data.hasMask && this.maskManager) {
|
|
this.layerInterface.registerMaskInterface(this.maskManager);
|
|
}
|
|
var effectsInterface = EffectsExpressionInterface.createEffectsInterface(this, this.layerInterface);
|
|
this.layerInterface.registerEffectsInterface(effectsInterface);
|
|
|
|
if (this.data.ty === 0 || this.data.xt) {
|
|
this.compInterface = CompExpressionInterface(this);
|
|
} else if (this.data.ty === 4) {
|
|
this.layerInterface.shapeInterface = ShapeExpressionInterface(this.shapesData, this.itemsData, this.layerInterface);
|
|
this.layerInterface.content = this.layerInterface.shapeInterface;
|
|
} else if (this.data.ty === 5) {
|
|
this.layerInterface.textInterface = TextExpressionInterface(this);
|
|
this.layerInterface.text = this.layerInterface.textInterface;
|
|
}
|
|
},
|
|
setBlendMode: function () {
|
|
var blendModeValue = getBlendMode(this.data.bm);
|
|
var elem = this.baseElement || this.layerElement;
|
|
|
|
elem.style['mix-blend-mode'] = blendModeValue;
|
|
},
|
|
initBaseData: function (data, globalData, comp) {
|
|
this.globalData = globalData;
|
|
this.comp = comp;
|
|
this.data = data;
|
|
this.layerId = createElementID();
|
|
|
|
// Stretch factor for old animations missing this property.
|
|
if (!this.data.sr) {
|
|
this.data.sr = 1;
|
|
}
|
|
// effects manager
|
|
this.effectsManager = new EffectsManager(this.data, this, this.dynamicProperties);
|
|
},
|
|
getType: function () {
|
|
return this.type;
|
|
},
|
|
sourceRectAtTime: function () {},
|
|
};
|
|
|
|
export default BaseElement;
|