Skip to content

Commit

Permalink
fix(hdom-components): fix total size calc in slideToggleRect()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 5, 2020
1 parent 7691e5f commit 8f58b09
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/hdom-components/src/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const DEFAULT_OPTS: ToggleOpts = {

export const slideToggleDot = (opts: Partial<ToggleDotOpts> = {}) => {
const _opts: ToggleDotOpts = {
...DEFAULT_OPTS,
r: 5,
...DEFAULT_OPTS,
...opts
};
const { r, pad, margin, vertical } = _opts;
Expand Down Expand Up @@ -77,25 +77,22 @@ export const slideToggleDot = (opts: Partial<ToggleDotOpts> = {}) => {

export const slideToggleRect = (opts: Partial<ToggleRectOpts> = {}) => {
const _opts: ToggleRectOpts = {
...DEFAULT_OPTS,
w: 10,
h: 10,
...DEFAULT_OPTS,
...opts
};
const { w, h, pad, margin, vertical } = _opts;
const m2 = margin * 2;
const pm = pad + margin;
const width = vertical ? w + pad * 2 : (w + pad) * 2;
const height = vertical ? (h + pad) * 2 : h + pad * 2;
const totalW = width + m2;
const totalH = height + m2;
const svgSize = vertical
? { width: totalH, height: totalW }
: { width: totalW, height: totalH };
const svgSize = { width: width + m2, height: height + m2 };
const style = { transition: `all ${_opts.anim}ms ease-out` };
const bgOn = {
...(vertical ? { width: height, height: width } : { width, height }),
..._opts.bgOn,
width,
height,
x: margin,
y: margin
};
Expand Down

0 comments on commit 8f58b09

Please sign in to comment.