Skip to content

Commit

Permalink
Revert "#4380 - Refactor (calculatePreviewTop.ts): Update the main fu…
Browse files Browse the repository at this point in the history
…nction"

This reverts commit 22664e6.
  • Loading branch information
DmitriiP-EPAM committed May 21, 2024
1 parent 858e108 commit 2a33631
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import { EditorClassName } from 'ketcher-react';
import { preview } from '../constants';

export const calculateMonomerPreviewTop = createCalculatePreviewTopFunction(
Expand All @@ -31,11 +32,17 @@ function createCalculatePreviewTopFunction(
height: number,
): (target?: DOMRect) => string {
return function calculatePreviewTop(target?: DOMRect): string {
if (!target) {
if (!target || !getEditorDOMRect()) {
return '';
}

const top = calculateTop(target, height);
return `${top}px`;
};
}

function getEditorDOMRect(): DOMRect | undefined {
return document
.getElementsByClassName(EditorClassName)[0]
?.getBoundingClientRect();
}

0 comments on commit 2a33631

Please sign in to comment.