Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonrt committed Feb 27, 2022
1 parent a16bad9 commit 8d89b39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 8 additions & 7 deletions _dist/application/internal/position/Position.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Position
* @type {PositionData}
*/
#data = { height: null, left: null, rotateX: null, rotateY: null, rotateZ: null, scale: null, top: null,
transformOrigin: 'top left', width: null, zIndex: null };
transformOrigin: s_TRANSFORM_ORIGIN_DEFAULT, width: null, zIndex: null };

/**
* @type {Map<string, PositionData>}
Expand Down Expand Up @@ -663,15 +663,14 @@ export class Position
const transforms = this.#transforms;
const validators = this.#validators;

let currentTransform = '', styles, updateTransform = false;
let currentTransform = '', updateTransform = false;

const el = parent?.elementTarget;

if (el)
{
currentTransform = el.style.transform ?? '';
styles = globalThis.getComputedStyle(el);
position = this.#updatePosition(position, el, styles);
position = this.#updatePosition(position, el);
}

// If there are any validators allow them to potentially modify position data or reject the update.
Expand Down Expand Up @@ -770,7 +769,7 @@ export class Position
if (typeof position.transformOrigin !== void 0)
{
position.transformOrigin = s_TRANSFORM_ORIGINS.includes(position.transformOrigin) ? position.transformOrigin :
'top left';
s_TRANSFORM_ORIGIN_DEFAULT;

if (data.transformOrigin !== position.transformOrigin)
{
Expand Down Expand Up @@ -934,9 +933,10 @@ export class Position
}

#updatePosition({ left, top, width, height, rotateX, rotateY, rotateZ, scale, transformOrigin, zIndex,
...rest } = {}, el, styles)
...rest } = {}, el)
{
const currentPosition = this.get(rest);
const styles = globalThis.getComputedStyle(el);

// Update width if an explicit value is passed, or if no width value is set on the element.
if (el.style.width === '' || width !== void 0)
Expand Down Expand Up @@ -1012,7 +1012,8 @@ export class Position

if (typeof transformOrigin === 'string')
{
currentPosition.transformOrigin = s_TRANSFORM_ORIGINS.includes(transformOrigin) ? transformOrigin : 'top left';
currentPosition.transformOrigin = s_TRANSFORM_ORIGINS.includes(transformOrigin) ? transformOrigin :
s_TRANSFORM_ORIGIN_DEFAULT;
}

if (typeof zIndex === 'number' || zIndex === null)
Expand Down
15 changes: 8 additions & 7 deletions src/application/internal/position/Position.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Position
* @type {PositionData}
*/
#data = { height: null, left: null, rotateX: null, rotateY: null, rotateZ: null, scale: null, top: null,
transformOrigin: 'top left', width: null, zIndex: null };
transformOrigin: s_TRANSFORM_ORIGIN_DEFAULT, width: null, zIndex: null };

/**
* @type {Map<string, PositionData>}
Expand Down Expand Up @@ -663,15 +663,14 @@ export class Position
const transforms = this.#transforms;
const validators = this.#validators;

let currentTransform = '', styles, updateTransform = false;
let currentTransform = '', updateTransform = false;

const el = parent?.elementTarget;

if (el)
{
currentTransform = el.style.transform ?? '';
styles = globalThis.getComputedStyle(el);
position = this.#updatePosition(position, el, styles);
position = this.#updatePosition(position, el);
}

// If there are any validators allow them to potentially modify position data or reject the update.
Expand Down Expand Up @@ -770,7 +769,7 @@ export class Position
if (typeof position.transformOrigin !== void 0)
{
position.transformOrigin = s_TRANSFORM_ORIGINS.includes(position.transformOrigin) ? position.transformOrigin :
'top left';
s_TRANSFORM_ORIGIN_DEFAULT;

if (data.transformOrigin !== position.transformOrigin)
{
Expand Down Expand Up @@ -934,9 +933,10 @@ export class Position
}

#updatePosition({ left, top, width, height, rotateX, rotateY, rotateZ, scale, transformOrigin, zIndex,
...rest } = {}, el, styles)
...rest } = {}, el)
{
const currentPosition = this.get(rest);
const styles = globalThis.getComputedStyle(el);

// Update width if an explicit value is passed, or if no width value is set on the element.
if (el.style.width === '' || width !== void 0)
Expand Down Expand Up @@ -1012,7 +1012,8 @@ export class Position

if (typeof transformOrigin === 'string')
{
currentPosition.transformOrigin = s_TRANSFORM_ORIGINS.includes(transformOrigin) ? transformOrigin : 'top left';
currentPosition.transformOrigin = s_TRANSFORM_ORIGINS.includes(transformOrigin) ? transformOrigin :
s_TRANSFORM_ORIGIN_DEFAULT;
}

if (typeof zIndex === 'number' || zIndex === null)
Expand Down

0 comments on commit 8d89b39

Please sign in to comment.