Skip to content

Commit

Permalink
fix: watch direction radio is now hidden when resize is not selected (#3
Browse files Browse the repository at this point in the history
)
  • Loading branch information
anandtiwary committed Apr 6, 2021
1 parent 2c0417a commit d2118ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { switchMap } from 'rxjs/operators';
import { switchMap, tap } from 'rxjs/operators';
import { fromResize } from '@twig-it/from-resize';
import { ResizeDirection } from '@twig-it/from-resize';
import { chartJsOptions } from './charts-options/chart-js';
Expand Down Expand Up @@ -40,13 +40,14 @@ const chartObject = new Chart(chartContext, chartJsOptions);

combineLatest([useResizeClicked$, directionClicked$])
.pipe(
tap(([useResize]) => {
!useResize ? watchDirectionElement.classList.add('hidden') : watchDirectionElement.classList.remove('hidden');
}),
switchMap(([useResize, direction]) =>
useResize ? fromResize(chartParentElement, { direction: direction, emitOnStart: false }) : EMPTY
)
)
.subscribe((dimension: ClientRect) => {
chartObject.resize(dimension.width, dimension.height);
console.log(
`From Resize: direction ${ResizeDirection.All} -> Updated dimension ${dimension.width} height: ${dimension.height} ${chartObject.aspectRatio}`
);
console.log(`From Resize: -> Updated dimension ${dimension.width} height: ${dimension.height}`);
});
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ input[type='checkbox'] {
label {
margin-left: 6px;
}

.hidden {
visibility: hidden;
}

0 comments on commit d2118ec

Please sign in to comment.