Skip to content

Commit 925f84e

Browse files
committed
cache values that cause forced reflows
will likely do more of those things
1 parent a613644 commit 925f84e

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

blocks/card/card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ window.addEventListener('load', () => {
1616
window.addEventListener('mousemove', (e) => {
1717
CP.doEvent(e);
1818
CM.doEvent(e);
19-
C.doEvent(e);
19+
//C.doEvent(e);
2020
});
2121
});

js/eventControl/EventControlElement.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@ export default class EventControlElement {
2424
}
2525

2626
/**
27+
* only retrieves size from the dom if it's called the first time
28+
* else returns cached value
2729
* @private
2830
* @return {number[]} width and height of the domElement
2931
*/
3032
get _size() {
31-
return [
32-
this.domElement.offsetWidth,
33-
this.domElement.offsetHeight
34-
];
33+
if(this.__size === undefined) {
34+
this.__size = [
35+
this.domElement.offsetWidth,
36+
this.domElement.offsetHeight
37+
];
38+
}
39+
40+
return this.__size;
3541
}
3642

3743
/**

js/transformation/TransformableElement.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,15 @@ export default class TransformableElement extends ECE {
611611

612612
/**
613613
* @returns {string} initial CSS transformation as matrix/matrix3d or
614-
* 'none'.
614+
* 'none' (cached).
615615
*/
616616
get initialTransform() {
617-
return this._getVariable(
618-
'transformable-element', 'initial-transform'
619-
);
617+
if(this._initialTransform === undefined) {
618+
this._initialTransform = this._getVariable(
619+
'transformable-element', 'initial-transform'
620+
);
621+
}
622+
return this._initialTransform;
620623
}
621624

622625
/**

0 commit comments

Comments
 (0)