Skip to content

Commit

Permalink
Merge pull request #603 from jonobr1/flag-class
Browse files Browse the repository at this point in the history
Improved Flagging for Class Names
  • Loading branch information
jonobr1 authored Jan 29, 2022
2 parents 51c6b19 + a96c3f0 commit a6cb8f3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 53 deletions.
27 changes: 8 additions & 19 deletions build/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ var Two = (() => {
svg: "SVGRenderer",
canvas: "CanvasRenderer"
},
Version: "v0.8.2",
PublishDate: "2022-01-21T19:48:20.441Z",
Version: "v0.8.3",
PublishDate: "2022-01-29T18:46:24.333Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -1058,20 +1058,11 @@ var Two = (() => {
return this._className;
},
set: function(v) {
this._flagClassName = this._className !== v;
if (this._flagClassName) {
const prev = this._className.split(/\s+?/);
const dest = v.split(/\s+?/);
for (let i = 0; i < prev.length; i++) {
const className = prev[i];
const index = Array.prototype.indexOf.call(this.classList, className);
if (index >= 0) {
this.classList.splice(index, 1);
}
}
this.classList = this.classList.concat(dest);
if (this._className !== v) {
this._flagClassName = true;
this.classList = v.split(/\s+?/);
this._className = v;
}
this._className = v;
}
}
};
Expand Down Expand Up @@ -3369,7 +3360,7 @@ var Two = (() => {
};
var Gradient = _Gradient;
__publicField(Gradient, "Stop", Stop);
__publicField(Gradient, "Properties", ["spread", "stops", "renderer", "id", "units"]);
__publicField(Gradient, "Properties", ["spread", "stops", "renderer", "units"]);
var proto7 = {
spread: {
enumerable: true,
Expand Down Expand Up @@ -3540,7 +3531,7 @@ var Two = (() => {
this._renderer.flagCenter = FlagCenter.bind(this);
this._renderer.flagFocal = FlagFocal.bind(this);
this.center = new Vector();
this.radius = typeof r === "number" ? r : 20;
this.radius = typeof r === "number" ? r : 1;
this.focal = new Vector();
if (typeof cx === "number") {
this.center.x = cx;
Expand Down Expand Up @@ -3791,8 +3782,6 @@ var Two = (() => {
};
var Texture = _Texture;
__publicField(Texture, "Properties", [
"id",
"className",
"src",
"loaded",
"repeat",
Expand Down
2 changes: 1 addition & 1 deletion build/two.min.js

Large diffs are not rendered by default.

27 changes: 8 additions & 19 deletions build/two.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ var Constants = {
svg: "SVGRenderer",
canvas: "CanvasRenderer"
},
Version: "v0.8.2",
PublishDate: "2022-01-21T19:48:20.441Z",
Version: "v0.8.3",
PublishDate: "2022-01-29T18:46:24.333Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -1034,20 +1034,11 @@ var proto3 = {
return this._className;
},
set: function(v) {
this._flagClassName = this._className !== v;
if (this._flagClassName) {
const prev = this._className.split(/\s+?/);
const dest = v.split(/\s+?/);
for (let i = 0; i < prev.length; i++) {
const className = prev[i];
const index = Array.prototype.indexOf.call(this.classList, className);
if (index >= 0) {
this.classList.splice(index, 1);
}
}
this.classList = this.classList.concat(dest);
if (this._className !== v) {
this._flagClassName = true;
this.classList = v.split(/\s+?/);
this._className = v;
}
this._className = v;
}
}
};
Expand Down Expand Up @@ -3345,7 +3336,7 @@ var _Gradient = class extends Element {
};
var Gradient = _Gradient;
__publicField(Gradient, "Stop", Stop);
__publicField(Gradient, "Properties", ["spread", "stops", "renderer", "id", "units"]);
__publicField(Gradient, "Properties", ["spread", "stops", "renderer", "units"]);
var proto7 = {
spread: {
enumerable: true,
Expand Down Expand Up @@ -3516,7 +3507,7 @@ var _RadialGradient = class extends Gradient {
this._renderer.flagCenter = FlagCenter.bind(this);
this._renderer.flagFocal = FlagFocal.bind(this);
this.center = new Vector();
this.radius = typeof r === "number" ? r : 20;
this.radius = typeof r === "number" ? r : 1;
this.focal = new Vector();
if (typeof cx === "number") {
this.center.x = cx;
Expand Down Expand Up @@ -3767,8 +3758,6 @@ var _Texture = class extends Element {
};
var Texture = _Texture;
__publicField(Texture, "Properties", [
"id",
"className",
"src",
"loaded",
"repeat",
Expand Down
17 changes: 4 additions & 13 deletions src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,11 @@ const proto = {
return this._className;
},
set: function(v) {
this._flagClassName = this._className !== v;
if (this._flagClassName) {
const prev = this._className.split(/\s+?/);
const dest = v.split(/\s+?/);
for (let i = 0; i < prev.length; i++) {
const className = prev[i];
const index = Array.prototype.indexOf.call(this.classList, className);
if (index >= 0) {
this.classList.splice(index, 1);
}
}
this.classList = this.classList.concat(dest);
if (this._className !== v) {
this._flagClassName = true;
this.classList = v.split(/\s+?/);
this._className = v;
}
this._className = v;
}
}
};
2 changes: 1 addition & 1 deletion utils/file-sizes.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"development":"56KB","production":"43KB"}
{"development":"56KB","production":"42KB"}
1 change: 1 addition & 0 deletions wiki/change-log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lang: en-US

## Nightly

+ Improved `Two.Element.className` flagging and `classList` construction
+ Manually amended `types.d.ts` for better TypeScript developing

## Jan 19, 2022 v0.8.2
Expand Down

0 comments on commit a6cb8f3

Please sign in to comment.