Linkd-Inc / ngx-slideshow

An Agular 2+ slideshow component
5 stars 0 forks source link

Resizing the page breaks things when viewport is sized programmatically #7

Closed crutchcorn closed 6 years ago

crutchcorn commented 6 years ago

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

When the viewport is sized programmatically, resizing the page doesn't work as expected.

EG: Infinite growing cards when using flex-grow

OS and Version?

All

Repro steps

<div style="flex-grow: 1">
<ngx-slideshow [cards]="3" [cardSize]="'20%'">
  <li><p>Hi</p></li>
  <li><p>Hi</p></li>
  <li><p>Hi</p></li>
  <li><p>Hi</p></li>
  <li><p>Hi</p></li>
</ngx-slideshow>
</div>

Desired functionality

Allow percentage to be based off of ngx-slideshow size when viewport size is set manually

Mention any other details that might be useful

It will require a new input (with a default to allow previous uses of this library to upgrade without breaking) called resizeViewport or something like that where the input (again, default true) will decide whether or not to resize the viewport based on the card size or whether to make the viewport what the card size is based off of.

if (resizeViewport && unit.includes('%')) {
  // Resize viewport to given percentage, grab px value and set to card size
} else if  (!resizeViewport && unit.includes('%')) {
  trueUnit = unit
}