From 2906e1e0364f84c20b9e2a4e3e3035c6862b2a6f Mon Sep 17 00:00:00 2001 From: Denis Hilt Date: Mon, 19 Apr 2021 23:01:50 +0300 Subject: [PATCH 1/2] issue-8 update padding size only once per clip --- src/processes/clip.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/processes/clip.ts b/src/processes/clip.ts index 819b53f2..d9877f75 100644 --- a/src/processes/clip.ts +++ b/src/processes/clip.ts @@ -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(); From dcb14c544783f2b5672ac2cbf47b756fda4b2e67 Mon Sep 17 00:00:00 2001 From: Denis Hilt Date: Mon, 19 Apr 2021 23:06:05 +0300 Subject: [PATCH 2/2] issue-8 parse styled size as a floating point number to avoid exp notation problem (1e+06px) --- src/classes/domRoutines.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/domRoutines.ts b/src/classes/domRoutines.ts index 10de5ae8..0ea63572 100644 --- a/src/classes/domRoutines.ts +++ b/src/classes/domRoutines.ts @@ -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 {