From 97b241f03804cbdccdccb40735ff10fbaf59bbc5 Mon Sep 17 00:00:00 2001 From: stephenshank Date: Thu, 19 Mar 2020 16:58:59 -0400 Subject: [PATCH] BaseAlignment only draws when pixel is set (bug fix). --- package.json | 2 +- src/components/BaseAlignment.jsx | 5 ++++- src/components/SiteAxis.jsx | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 564b6ee..4ae333a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alignment.js", - "version": "0.2.2", + "version": "0.2.3", "main": "library.js", "license": "MIT", "dependencies": { diff --git a/src/components/BaseAlignment.jsx b/src/components/BaseAlignment.jsx index 23072f9..54bb10c 100644 --- a/src/components/BaseAlignment.jsx +++ b/src/components/BaseAlignment.jsx @@ -24,7 +24,10 @@ class BaseAlignment extends Component { } } componentDidUpdate() { - this.draw(this.props.x_pixel || 0, this.props.y_pixel || 0); + const { x_pixel, y_pixel } = this.props; + if (x_pixel != undefined || y_pixel != undefined) { + this.draw(x_pixel || 0, y_pixel || 0); + } } draw(x_pixel, y_pixel) { if (this.props.disableVerticalScrolling) y_pixel = 0; diff --git a/src/components/SiteAxis.jsx b/src/components/SiteAxis.jsx index 0f3c600..4fcc005 100644 --- a/src/components/SiteAxis.jsx +++ b/src/components/SiteAxis.jsx @@ -30,6 +30,9 @@ class SiteAxis extends Component { $("#alignmentjs-axis-div").scrollLeft(e.detail.x_pixel); }); } + componentDidUpdate(nextProps) { + $("#alignmentjs-axis-div").scrollLeft(this.props.x_pixel); + } handleWheel(e) { e.preventDefault(); this.props.scroll_broadcaster.handleWheel(e, this.props.sender);