Skip to content

Commit

Permalink
Merge pull request #9 from dhilt/issue-8-Wrong-behaviour-when-padding…
Browse files Browse the repository at this point in the history
…-element-size-is-greater-than-1MP

Fix for reading the size of the padding element when it is greater than 1MP
  • Loading branch information
dhilt authored Apr 19, 2021
2 parents 759167f + dcb14c5 commit c43b8bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/classes/domRoutines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Routines {
getSizeStyle(element: HTMLElement): number {
this.checkElement(element);
const size = element.style[this.horizontal ? 'width' : 'height'];
return parseInt(size as string, 10) || 0;
return parseFloat(size as string) || 0;
}

setSizeStyle(element: HTMLElement, value: number): void {
Expand Down
14 changes: 10 additions & 4 deletions src/processes/clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ export default class Clip extends BaseProcessFactory(CommonProcess.clip) {
}
item.hide();
size[item.removeDirection] += item.size;
const padding = paddings.byDirection(item.removeDirection);
padding.size += item.size;
return true;
});

if (scroller.settings.onBeforeClip && itemsToRemove.length) {
scroller.settings.onBeforeClip(itemsToRemove.map(item => item.get()));
if (itemsToRemove.length) {
if (size[Direction.backward]) {
paddings.byDirection(Direction.backward).size += size[Direction.backward];
}
if (size[Direction.forward]) {
paddings.byDirection(Direction.forward).size += size[Direction.forward];
}
if (scroller.settings.onBeforeClip) {
scroller.settings.onBeforeClip(itemsToRemove.map(item => item.get()));
}
}

buffer.clip();
Expand Down

0 comments on commit c43b8bf

Please sign in to comment.